diff --git a/docker/02-init-chain.sh b/docker/02-init-chain.sh index 4b2c4d1d..e1130baf 100755 --- a/docker/02-init-chain.sh +++ b/docker/02-init-chain.sh @@ -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}" + # 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 diff --git a/docker/04-bootstrap.sh b/docker/04-bootstrap.sh index 59ab9788..fb6481f9 100755 --- a/docker/04-bootstrap.sh +++ b/docker/04-bootstrap.sh @@ -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 diff --git a/docker/05-test.sh b/docker/05-test.sh index 60ca2e64..72e00a73 100755 --- a/docker/05-test.sh +++ b/docker/05-test.sh @@ -3,11 +3,16 @@ source ./common.sh set +ex -echo "Testing decryption key generation" EPOCH_ID=$(LC_ALL=C tr -dc 'a-f0-9'