Simulate activity in a test network of the Remme blockchain (core) to show how it works.
For production AWS Lambda is used. AWS Lambda
is a serverless compute
service that runs your code in response to events and automatically manages the underlying compute resources.
It runs:
- On
CloudWatch
events, so lambda is executed once per specified time, e.g. 5 minutes. - Also
Amazon CloudWatch Logs
feature is enable to collect the lambdas logs. - Runtime is
Node.js 8.10
.
To build an environment for lambdas and bundle each to own zip-archive
, build the container first:
$ docker build -t lambdas . -f ops/Dockerfile.buildLambdasToProduction
Afterwards, run the container, export zip-archives
from container to host and stop the container with the following
commands:
$ docker run -d --name lambdas lambdas
$ docker cp lambdas:/lambdas/transferTokensLambda/transferTokensLambda.zip .
$ docker cp lambdas:/lambdas/storePublicKeyLambda/storePublicKeyLambda.zip .
$ docker cp lambdas:/lambdas/revokePublicKeyLambda/revokePublicKeyLambda.zip .
$ docker stop lambdas
Now you can upload it to the AWS Lambda
service and test with the following command:
$ aws lambda update-function-code --function-name activitySimulationTrasferTokens --zip-file fileb:/$pwd/transferTokensLambda.zip
The production requires the following environment variables on the AWS Lambda
environment:
NODE_ADDRESS
— the address of the node to work with (e.g.node-27-testnet.remme.io
or139.59.148.55
).MASTER_ACCOUNT_PRIVATE_KEY
— private key from the account on the blockchain that is accessible by the node address that could be a faucet for the transactions execution (have tokens on the account).AMOUNT_OF_TOKENS_TO_SEND
— amount of tokens to send for transfer tokens lambda.
Clean containers and images with the following commands:
$ docker rm $(docker ps -a -q) -f
$ docker rmi $(docker images -q) -f
To build an environment for lambda that transfer tokens, build the container first:
$ docker build \
--build-arg MASTER_ACCOUNT_PRIVATE_KEY=ad2dc65ca66706aa4b5a2b63a10472c91e113b7f82614260f3bb3a2cd28a0cdc \
--build-arg NODE_ADDRESS=node-27-testnet.remme.io \
--build-arg AMOUNT_OF_TOKENS_TO_SEND=1000 \
-f Dockerfile.transferTokensLambda \
-t transfer-tokens-lambda .
Then you could execute the lambda like it should be executed in the production with the following command. This command execute lambda in the container, that container is destroyed, so you can do it again immediately.
$ docker run \
-v $PWD/src/callers/transferTokensLambdaHandlerCaller.js:/lambdas/transferTokensLambda/transferTokensLambdaHandlerCaller.js \
-v $PWD/src/lambdas/transferTokensLambdaHandler.js:/lambdas/transferTokensLambda/transferTokensLambdaHandler.js \
--name transfer-tokens-lambda --rm transfer-tokens-lambda
To build an environment for lambda that store public key, build the container first:
$ docker build \
--build-arg MASTER_ACCOUNT_PRIVATE_KEY=ad2dc65ca66706aa4b5a2b63a10472c91e113b7f82614260f3bb3a2cd28a0cdc \
--build-arg NODE_ADDRESS=node-27-testnet.remme.io \
-f Dockerfile.storePublicKeyLambda \
-t store-public-key-lambda .
Then you could execute the lambda like it should be executed in the production with the following command. This command execute lambda in the container, that container is destroyed, so you can do it again immediately.
$ docker run \
-v $PWD/src/callers/storePublicKeyLambdaHandlerCaller.js:/lambdas/storePublicKeyLambda/storePublicKeyLambdaHandlerCaller.js \
-v $PWD/src/lambdas/storePublicKeyLambdaHandler.js:/lambdas/storePublicKeyLambda/storePublicKeyLambdaHandler.js \
--name store-public-key-lambda --rm store-public-key-lambda
To build an environment for lambda that revoke public key, build the container first:
$ docker build \
--build-arg MASTER_ACCOUNT_PRIVATE_KEY=ad2dc65ca66706aa4b5a2b63a10472c91e113b7f82614260f3bb3a2cd28a0cdc \
--build-arg NODE_ADDRESS=node-27-testnet.remme.io \
-f Dockerfile.revokePublicKeyLambda \
-t revoke-public-key-lambda .
Then you could execute the lambda like it should be executed in the production with the following command. This command execute lambda in the container, that container is destroyed, so you can do it again immediately.
$ docker run \
-v $PWD/src/callers/revokePublicKeyLambdaHandlerCaller.js:/lambdas/revokePublicKeyLambda/revokePublicKeyLambdaHandlerCaller.js \
-v $PWD/src/lambdas/revokePublicKeyLambdaHandler.js:/lambdas/revokePublicKeyLambda/revokePublicKeyLambdaHandler.js \
--name revoke-public-key-lambda --rm revoke-public-key-lambda