Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remove docker sentry nodes #410

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 27 additions & 37 deletions docker/02-init-chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,61 @@ source ./common.sh

$DC stop geth
$DC rm -f geth
$DC stop chain-{0..3}-{validator,sentry} chain-seed
$DC rm -f chain-{0..3}-{validator,sentry} chain-seed
$DC stop chain-{0..3}-validator chain-seed
$DC rm -f chain-{0..3}-validator chain-seed

${BB} rm -rf data/geth
${BB} rm -rf data/chain-{0..3}-{validator,sentry} data/chain-seed
${BB} mkdir -p data/chain-{0..3}-{validator,sentry}/config data/chain-seed/config
${BB} chmod -R a+rwX data/chain-{0..3}-{validator,sentry}/config data/chain-seed/config
${BB} rm -rf data/chain-{0..3}-validator data/chain-seed
${BB} mkdir -p data/chain-{0..3}-validator/config data/chain-seed/config
${BB} chmod -R a+rwX data/chain-{0..3}-validator/config data/chain-seed/config
${BB} rm -rf data/deployments

# has geth as dependency
$DC up deploy-contracts

# setup chain-seed
$DC run --rm --no-deps chain-seed init \
--root /chain \
--blocktime 1 \
--listen-address tcp://127.0.0.1:${TM_RPC_PORT} \
--listen-address tcp://0.0.0.0:${TM_RPC_PORT} \
--role seed

for num in 0 1 2 3; do
validator_cmd=chain-$num-validator
sentry_cmd=chain-$num-sentry
seed_node=$(cat data/chain-seed/config/node_key.json.id)@chain-seed:${TM_P2P_PORT}

$DC run --rm --no-deps ${sentry_cmd} init \
--root /chain \
--blocktime 1 \
--listen-address tcp://0.0.0.0:${TM_RPC_PORT} \
--role sentry
${BB} sed -i "/^moniker/c\moniker = \"chain-seed\"" data/chain-seed/config/config.toml

# configure validators and keypers 0-3
for num in {0..3}; do
validator_cmd=chain-$num-validator

# TODO: check if validator can have listen-address tcp://127.0.0.1...
$DC run --rm --no-deps ${validator_cmd} init \
--root /chain \
--genesis-keyper 0x440Dc6F164e9241F04d282215ceF2780cd0B755e \
--blocktime 1 \
--listen-address tcp://127.0.0.1:${TM_RPC_PORT} \
--listen-address tcp://0.0.0.0:${TM_RPC_PORT} \
--role validator

${BB} sed -i "/ValidatorPublicKey/c\ValidatorPublicKey = \"$(cat data/${validator_cmd}/config/priv_validator_pubkey.hex)\"" /config/keyper-${num}.toml
validator_id=$(cat data/${validator_cmd}/config/node_key.json.id)
validator_node=${validator_id}@${validator_cmd}:${TM_P2P_PORT}
validator_config_path=data/${validator_cmd}/config/config.toml

# share genesis
if [ $num -eq 0 ]; then
for destination in data/chain-seed/config/ data/chain-{1..3}-validator/config/ data/chain-{0..3}-sentry/config/; do
for destination in data/chain-seed/config/ data/chain-{1..3}-validator/config/; do
${BB} cp -v data/chain-0-validator/config/genesis.json "${destination}"
done
fi
done

seed_node=$(cat data/chain-seed/config/node_key.json.id)@chain-seed:${TM_P2P_PORT}

for num in 0 1 2 3; do
sentry_cmd=chain-$num-sentry
validator_cmd=chain-$num-validator

validator_id=$(cat data/${validator_cmd}/config/node_key.json.id)
validator_node=${validator_id}@${validator_cmd}:${TM_P2P_PORT}
sentry_node=$(cat data/${sentry_cmd}/config/node_key.json.id)@${sentry_cmd}:${TM_P2P_PORT}
# set validator publickey for keyper
${BB} sed -i "/ValidatorPublicKey/c\ValidatorPublicKey = \"$(cat data/${validator_cmd}/config/priv_validator_pubkey.hex)\"" /config/keyper-${num}.toml

# set seed node for sentry
${BB} sed -i "/^persistent_peers =/c\persistent_peers = \"${seed_node}\"" data/${sentry_cmd}/config/config.toml
# set validator node for sentry
${BB} sed -i "/^private_peer_ids =/c\private_peer_ids = \"${validator_id}\"" data/${sentry_cmd}/config/config.toml
${BB} sed -i "/^unconditional_peer_ids =/c\unconditional_peer_ids = \"${validator_id}\"" data/${sentry_cmd}/config/config.toml
${BB} sed -i "/^external_address =/c\external_address = \"${sentry_cmd}:${TM_P2P_PORT}\"" data/${sentry_cmd}/config/config.toml
# set seed node for chain bootstrap
${BB} sed -i "/^bootstrap_peers =/c\bootstrap_peers = \"${seed_node}\"" "${validator_config_path}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the 0.0.37-rc2 this is call seeds now

# fix external address for docker internal communication
${BB} sed -i "/^external_address =/c\external_address = \"${validator_cmd}:${TM_P2P_PORT}\"" "${validator_config_path}"
# give a nice name
${BB} sed -i "/^moniker/c\moniker = \"${validator_cmd}\"" "${validator_config_path}"

# set sentry node for validator
${BB} sed -i "/^persistent_peers =/c\persistent_peers = \"${sentry_node}\"" data/${validator_cmd}/config/config.toml
${BB} sed -i "/^external_address =/c\external_address = \"${validator_cmd}:${TM_P2P_PORT}\"" data/${validator_cmd}/config/config.toml
done

$DC stop -t 30
2 changes: 1 addition & 1 deletion docker/04-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ echo "Submitting bootstrap transaction"
$DC run --rm --no-deps --entrypoint /rolling-shutter chain-0-validator bootstrap \
--deployment-dir /deployments/dockerGeth \
--ethereum-url http://geth:8545 \
--shuttermint-url http://chain-0-sentry:${TM_RPC_PORT} \
--shuttermint-url http://chain-0-validator:${TM_RPC_PORT} \
--signing-key 479968ffa5ee4c84514a477a8f15f3db0413964fd4c20b08a55fed9fed790fad
11 changes: 8 additions & 3 deletions docker/05-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
source ./common.sh
set +ex

echo "Testing decryption key generation"
EPOCH_ID=$(LC_ALL=C tr -dc 'a-f0-9' </dev/urandom | head -c64)
json_body="{\"jsonrpc\": \"2.0\", \"method\": \"get_decryption_key\", \"id\": 1, \"params\": [\"1\", \"${EPOCH_ID}\"]}"
EON_ID=$($DC exec db psql -U postgres -d keyper-0 -t -c 'select max(eon) from eons;' | tr -d '[:space:]')
if [[ -z $EON_ID ]]; then
echo "No eonId found in keyper-0 db. Did you run bootstrap?"
exit 1
fi
json_body="{\"jsonrpc\": \"2.0\", \"method\": \"get_decryption_key\", \"id\": 1, \"params\": [\"${EON_ID}\", \"${EPOCH_ID}\"]}"
echo "Testing decryption key generation for eonId ${EON_ID} and epoch ${EPOCH_ID}"
curl -XGET http://localhost:8754/api/v1/rpc -d "${json_body}"
sleep 3
sleep 5
DECRYPTION_KEY_MSGS=$(${DC} logs snapshot | grep ${EPOCH_ID} | grep -c decryptionKey)
if [[ $DECRYPTION_KEY_MSGS -gt 0 ]]; then
echo "Decryption successful with $DECRYPTION_KEY_MSGS / 3 nodes"
Expand Down
2 changes: 1 addition & 1 deletion docker/config.example/keyper-0.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DeploymentDir = "./deployments/dockerGeth/"
EthereumURL = "http://geth:8545/"

[Shuttermint]
ShuttermintURL = "http://chain-0-sentry:26657"
ShuttermintURL = "http://chain-0-validator:26657"
ValidatorPublicKey = '720accc33c2bce1319d12b5f23f81b39a33f487e21c4a4d7ca1e1f7954a24172'
EncryptionKey = 'e5c124eb4d3c13fa46532107b69b5abfa11e8aaf3a7a86d11ef370470834e076'
DKGPhaseLength = 8
Expand Down
2 changes: 1 addition & 1 deletion docker/config.example/keyper-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DeploymentDir = "./deployments/dockerGeth/"
EthereumURL = "http://geth:8545/"

[Shuttermint]
ShuttermintURL = "http://chain-1-sentry:26657"
ShuttermintURL = "http://chain-1-validator:26657"
ValidatorPublicKey = '720accc33c2bce1319d12b5f23f81b39a33f487e21c4a4d7ca1e1f7954a24172'
EncryptionKey = '8972bbbcf5b4a9eaef0030b1eff64332e7188ff4dd523314176956b5c624ca8b'
DKGPhaseLength = 8
Expand Down
2 changes: 1 addition & 1 deletion docker/config.example/keyper-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DeploymentDir = "./deployments/dockerGeth/"
EthereumURL = "http://geth:8545/"

[Shuttermint]
ShuttermintURL = "http://chain-2-sentry:26657"
ShuttermintURL = "http://chain-2-validator:26657"
ValidatorPublicKey = '720accc33c2bce1319d12b5f23f81b39a33f487e21c4a4d7ca1e1f7954a24172'
EncryptionKey = 'ee014227e5b6209682f31c967b4a21c6617a02bc5f11f644f5f54f6d613906b9'
DKGPhaseLength = 8
Expand Down
2 changes: 1 addition & 1 deletion docker/config.example/keyper-3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DeploymentDir = "./deployments/dockerGeth/"
EthereumURL = "http://geth:8545/"

[Shuttermint]
ShuttermintURL = "http://chain-3-sentry:26657"
ShuttermintURL = "http://chain-3-validator:26657"
ValidatorPublicKey = '8ad31f4e77c5092977d57e578b47dc23a86762933a4c09bcb055456805c84096'
EncryptionKey = '13c24d4a50e53bdb4cf8ae328491fd10fbf1bc0118ff6adad1340fa77eaf9c3c'
DKGPhaseLength = 8
Expand Down
92 changes: 12 additions & 80 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,6 @@ services:
depends_on:
geth:
condition: service_healthy
chain-0-sentry:
condition: service_started
logging: *logging

chain-0-sentry:
image: snapshutter
restart: always
entrypoint:
- /rolling-shutter
- chain
volumes:
- ./data/chain-0-sentry:/chain
- ./data/deployments:/deployments
command: "--config /chain/config/config.toml"
depends_on:
chain-seed:
condition: service_started
logging: *logging

chain-1-validator:
Expand All @@ -107,23 +90,6 @@ services:
depends_on:
geth:
condition: service_healthy
chain-1-sentry:
condition: service_started
logging: *logging

chain-1-sentry:
image: snapshutter
restart: always
entrypoint:
- /rolling-shutter
- chain
volumes:
- ./data/chain-1-sentry:/chain
- ./data/deployments:/deployments
command: "--config /chain/config/config.toml"
depends_on:
chain-seed:
condition: service_started
logging: *logging

chain-2-validator:
Expand All @@ -139,23 +105,6 @@ services:
depends_on:
geth:
condition: service_healthy
chain-2-sentry:
condition: service_started
logging: *logging

chain-2-sentry:
image: snapshutter
restart: always
entrypoint:
- /rolling-shutter
- chain
volumes:
- ./data/chain-2-sentry:/chain
- ./data/deployments:/deployments
command: "--config /chain/config/config.toml"
depends_on:
chain-seed:
condition: service_started
logging: *logging

chain-3-validator:
Expand All @@ -171,23 +120,6 @@ services:
depends_on:
geth:
condition: service_healthy
chain-3-sentry:
condition: service_started
logging: *logging

chain-3-sentry:
image: snapshutter
restart: always
entrypoint:
- /rolling-shutter
- chain
volumes:
- ./data/chain-3-sentry:/chain
- ./data/deployments:/deployments
command: "--config /chain/config/config.toml"
depends_on:
chain-seed:
condition: service_started
logging: *logging

chain-seed:
Expand Down Expand Up @@ -242,13 +174,13 @@ services:
depends_on:
db:
condition: service_healthy
chain-0-sentry:
chain-0-validator:
condition: service_started
chain-1-sentry:
chain-1-validator:
condition: service_started
chain-2-sentry:
chain-2-validator:
condition: service_started
chain-3-sentry:
chain-3-validator:
condition: service_started
geth:
condition: service_healthy
Expand All @@ -267,13 +199,13 @@ services:
depends_on:
db:
condition: service_healthy
chain-0-sentry:
chain-0-validator:
condition: service_started
chain-1-sentry:
chain-1-validator:
condition: service_started
chain-2-sentry:
chain-2-validator:
condition: service_started
chain-3-sentry:
chain-3-validator:
condition: service_started
geth:
condition: service_healthy
Expand All @@ -295,7 +227,7 @@ services:
depends_on:
db:
condition: service_healthy
chain-0-sentry:
chain-0-validator:
condition: service_started
bootnode-0:
condition: service_started
Expand All @@ -321,7 +253,7 @@ services:
depends_on:
db:
condition: service_healthy
chain-1-sentry:
chain-1-validator:
condition: service_started
bootnode-0:
condition: service_started
Expand All @@ -347,7 +279,7 @@ services:
depends_on:
db:
condition: service_healthy
chain-2-sentry:
chain-2-validator:
condition: service_started
bootnode-0:
condition: service_started
Expand All @@ -371,7 +303,7 @@ services:
depends_on:
db:
condition: service_healthy
chain-3-sentry:
chain-3-validator:
condition: service_started
bootnode-0:
condition: service_started
Expand Down
Loading