Skip to content

Instantly share code, notes, and snippets.

@papyasha
Last active July 2, 2020 16:33
Show Gist options
  • Save papyasha/49925cf882545dada27b3f3fb7f48304 to your computer and use it in GitHub Desktop.
Save papyasha/49925cf882545dada27b3f3fb7f48304 to your computer and use it in GitHub Desktop.
Deploy a Keep Random Beacon and ECDSA nodes on the Keep Testnet in 15 minutes

How to deploy a Keep Random Beacon and ECDSA nodes on the Keep Testnet in 15 minutes

Preliminary requirements (10 minutes)

  • Created keystore wallet file
  • Installed and configured Metamask
  • Received Ropsten ETH from the faucet
  • Received Keep testnet tokens grant
  • Delegated tokens, authorized contracts and bonded ETH in the Keep dashboard
  • Created and configured Infura account (PROJECT ID will be required)
  • Created linux server with SSH access configured (can be Digitalocean droplet or anything else)

Node Setup (5 minutes)

Just replace CAPITALIZED data (remove brackets[]) and enter into your terminal app in batches.

Login to your server using SSH

ssh -i [REPLACE_WITH_YOUR_SSH_KEY_NAME] root@[REPLACE_WITH_YOUR_SERVER_IP]

Setup firewall

sudo ufw allow 22/tcp
sudo ufw allow 3919/tcp
yes | sudo ufw enable

Install Docker

sudo apt-get update
sudo apt-get remove docker docker-engine docker.io
sudo apt install docker.io curl -y
sudo systemctl start docker
sudo systemctl enable docker

Pull required Docker images

docker pull keepnetwork/keep-client:v1.2.4-rc
docker pull keepnetwork/keep-ecdsa-client:v1.1.2-rc

Create required directories

mkdir -p $HOME/keep-client/{config,keystore,persistence}
mkdir -p $HOME/keep-ecdsa/{config,keystore,persistence}

Set local variables

export SERVER_IP=\$(curl ifconfig.me)
export INFURA_PROJECT_ID="[REPLACE_WITH_INFURA_PROJECT_ID]"
export ETH_WALLET="[REPLACE_WITH_ETH_WALLET_ADDRESS_0x....]"
export KEEP_CLIENT_ETHEREUM_PASSWORD=[REPLACE_WITH_ETH_WALLET_PASSWORD]

Create configs for both nodes

cat <<EOF >>$HOME/keep-client/config/config.toml
# Ethereum host connection info.
[ethereum]
 URL = "wss://ropsten.infura.io/ws/v3/$INFURA_PROJECT_ID"
 URLRPC = "https://ropsten.infura.io/v3/$INFURA_PROJECT_ID"
[ethereum.account]
  Address = "$ETH_WALLET"
  KeyFile = "/mnt/keystore/keep_wallet.json"# Keep contract addresses configuration.
# This address might change and need to be replaced from time to time. If it does, the new contract address will be listed here:
# https://docs.keep.network/run-random-beacon.html#_testnet
[ethereum.ContractAddresses]
  KeepRandomBeaconOperator = "0x9233Fd6C58e37dab223EF1dFD5e33eD69FD1f93b"
 TokenStaking = "0x88B3D0Bfb8F207292Dc4Cee7C923d0E7C3078a18"
 KeepRandomBeaconService = "0xa5018dbeB6920A04e0CFd3D8F0F45BC851838b0D"# Keep network configuration.
[LibP2P]
  Peers = ["/dns4/bootstrap-3.test.keep.network/tcp/3919/ipfs/16Uiu2HAm8KJX32kr3eYUhDuzwTucSfAfspnjnXNf9veVhB12t6Vf",
  "/dns4/bootstrap-2.test.keep.network/tcp/3919/ipfs/16Uiu2HAmNNuCp45z5bgB8KiTHv1vHTNAVbBgxxtTFGAndageo9Dp"]
  Port = 3919
  # Override the node's default addresses announced in the network
  AnnouncedAddresses = ["/ip4/$SERVER_IP/tcp/3919"]# Storage is encrypted
[Storage]
  DataDir = "/mnt/persistence"
EOF
cat <<EOF >>$HOME/keep-ecdsa/config/config.toml
# Ethereum host connection info.
[ethereum]
  URL = "wss://ropsten.infura.io/ws/v3/$INFURA_PROJECT_ID"
  URLRPC = "https://ropsten.infura.io/v3/$INFURA_PROJECT_ID"
[ethereum.account]
  Address = "$ETH_WALLET"
  KeyFile = "/mnt/keep-ecdsa/keystore/keep_wallet.json"
# This address might change and need to be replaced from time to time. If it does, the new contract address will be listed here:
# https://github.com/keep-network/keep-ecdsa/blob/master/docs/run-keep-ecdsa.adoc#723-contracts
[ethereum.ContractAddresses]
  BondedECDSAKeepFactory = "0xe7BF8421fBE80c3Bf67082370D86C8D81D1D77F4"
# This addresses might change and need to be replaced from time to time. If it does, the new contract address will be listed here:
# https://github.com/keep-network/keep-ecdsa/blob/master/docs/run-keep-ecdsa.adoc#723-contracts
# Addresses of applications approved by the operator.
[SanctionedApplications]
  Addresses = [
    "0x25B60668E7a0967a86223828D20f93714D91Ee4B",
]
[Storage]
  DataDir = "/mnt/keep-ecdsa/persistence"
[LibP2P]
  Peers = ["/dns4/ecdsa-2.test.keep.network/tcp/3919/ipfs/16Uiu2HAmNNuCp45z5bgB8KiTHv1vHTNAVbBgxxtTFGAndageo9Dp",
  "/dns4/ecdsa-3.test.keep.network/tcp/3919/ipfs/16Uiu2HAm8KJX32kr3eYUhDuzwTucSfAfspnjnXNf9veVhB12t6Vf"]
Port = 3919
 # Override the node’s default addresses announced in the network
 AnnouncedAddresses = ["/ip4/$SERVER_IP/tcp/5678"]
[TSS]
# Timeout for TSS protocol pre-parameters generation. The value
# should be provided based on resources available on the machine running the client.
# This is an optional parameter, if not provided timeout for TSS protocol
# pre-parameters generation will be set to .
  PreParamsGenerationTimeout = "2m30s"
EOF

Add keystore wallet to your node

vim ~/keep-client/keystore/keep_wallet.json

Then press i to enter edit mode.

Copy keystore file content by pasting everything into the editor.

Press esc to exit edit mode.

Press :wq to save file.

Repeat for ECDSA node:

vim ~/keep-ecdsa/keystore/keep_wallet.json

Start both nodes

sudo docker run -dit \
--restart always \
--volume $HOME/keep-client:/mnt \
--env KEEP_ETHEREUM_PASSWORD=$KEEP_CLIENT_ETHEREUM_PASSWORD \
--env LOG_LEVEL=debug \
--name keep-client \
-p 3919:3919 \
keepnetwork/keep-client:v1.2.4-rc --config /mnt/config/config.toml start
sudo docker run -d \
 --restart always \
 --entrypoint /usr/local/bin/keep-ecdsa \
 --volume $HOME/keep-ecdsa:/mnt/keep-ecdsa \
  --env KEEP_ETHEREUM_PASSWORD=$KEEP_CLIENT_ETHEREUM_PASSWORD \
 --env LOG_LEVEL=debug \
 --name ecdsa \
 -p 3920:3919 \
 keepnetwork/keep-ecdsa-client:v1.1.2-rc \
 --config /mnt/keep-ecdsa/config/config.toml start

Check if both nodes are running

docker ps -a

The output should look similar to:

root@keep-testnet:~# docker ps -a
CONTAINER ID        IMAGE                                     COMMAND                  CREATED             STATUS              PORTS                    NAMES
90edca53bc48        keepnetwork/keep-ecdsa-client:v1.1.2-rc   "/usr/local/bin/keep…"   3 hours ago         Up 3 hours          0.0.0.0:3920->3919/tcp   ecdsa
d7ed828e495a        keepnetwork/keep-client:v1.2.4-rc         "keep-client -config…"   3 hours ago         Up 3 hours          0.0.0.0:3919->3919/tcp   keep-client

Check number of connected peers to see if everything works as expected

sudo docker logs keep-client --tail 100 | grep "number of connected peers:"
sudo docker logs ecdsa --tail 1000 2>&1 | grep "number of connected peers:"

Debug

In case you have 0 peers after some time you can take a look at the logs to see the problem.

sudo docker logs keep-client --tail 1000
sudo docker logs ecdsa --tail 1000

Node Update

In case Docker images or Keep contracts has been updated please use this guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment