diff --git a/ci/bootstrap_gaia.sh b/ci/bootstrap_gaia.sh index 58fb6cc0e5..930b21570e 100644 --- a/ci/bootstrap_gaia.sh +++ b/ci/bootstrap_gaia.sh @@ -26,48 +26,51 @@ echo "Initialize chain $CHAIN_ID" echo "-------------------------------------------------------------------------------------------------------------------" gaiad init "$MONIKER" --chain-id "$CHAIN_ID" --home "$home" +echo "-------------------------------------------------------------------------------------------------------------------" +echo "Replace addresses and ports in the config file" +echo "-------------------------------------------------------------------------------------------------------------------" +sed -i 's#"tcp://127.0.0.1:26657"#"tcp://'"$CHAIN_ID"':'"$RPC_PORT"'"#g' "$home"/config/config.toml +sed -i 's#"tcp://0.0.0.0:26656"#"tcp://'"$CHAIN_ID"':'"$P2P_PORT"'"#g' "$home"/config/config.toml +sed -i 's/grpc_laddr = ""/grpc_laddr = "'"$CHAIN_ID"':'"$GRPC_PORT"'"/g' /tmp/chain/config/config.toml + echo "-------------------------------------------------------------------------------------------------------------------" echo "Adding validator key" echo "-------------------------------------------------------------------------------------------------------------------" -gaiad keys add validator --keyring-backend="test" --home $home --output json > "$home/validator_seed.json" -cat "$home/validator_seed.json" +gaiad keys add validator --keyring-backend="test" --home "$home" --output json > "$home"/validator_seed.json +cat "$home"/validator_seed.json echo "-------------------------------------------------------------------------------------------------------------------" echo "Adding use key" echo "-------------------------------------------------------------------------------------------------------------------" -gaiad keys add user --keyring-backend="test" --home $home --output json > "$home/key_seed.json" -cat "$home/key_seed.json" +gaiad keys add user --keyring-backend="test" --home $home --output json > "$home"/key_seed.json +cat "$home"/key_seed.json echo "-------------------------------------------------------------------------------------------------------------------" echo "Adding user account to genesis" echo "-------------------------------------------------------------------------------------------------------------------" -# shellcheck disable=SC2046 -gaiad --home $home add-genesis-account $(gaiad --home $home keys --keyring-backend="test" show user -a) $coins +gaiad --home "$home" add-genesis-account $(gaiad --home "$home" keys --keyring-backend="test" show user -a) $coins echo "Done!" echo "-------------------------------------------------------------------------------------------------------------------" echo "Adding validator account to genesis" echo "-------------------------------------------------------------------------------------------------------------------" # shellcheck disable=SC2046 -gaiad --home $home add-genesis-account $(gaiad --home $home keys --keyring-backend="test" show validator -a) $coins +gaiad --home "$home" add-genesis-account $(gaiad --home "$home" keys --keyring-backend="test" show validator -a) $coins echo "Done!" echo "-------------------------------------------------------------------------------------------------------------------" echo "Generate a genesis transaction that creates a validator with a self-delegation" echo "-------------------------------------------------------------------------------------------------------------------" -gaiad --home $home gentx validator --keyring-backend="test" --chain-id $CHAIN_ID +gaiad --home "$home" gentx validator --keyring-backend="test" --chain-id "$CHAIN_ID" echo "Done!" echo "-------------------------------------------------------------------------------------------------------------------" echo "Collect genesis txs and output a genesis.json file" echo "-------------------------------------------------------------------------------------------------------------------" -gaiad collect-gentxs --home $home +gaiad collect-gentxs --home "$home" echo "Done!" -TODO -> Add more sed -sed -i 's#"tcp://127.0.0.1:26657"#"tcp://'"$CHAIN_ID"':'"$RPC_PORT"'"#g' $home/config/config.toml - echo "-------------------------------------------------------------------------------------------------------------------" echo "Start the node" echo "-------------------------------------------------------------------------------------------------------------------" -gaiad start --home $home --address tcp://"$CHAIN_ID":"$RPC_PORT" --p2p.laddr tcp://"$CHAIN_ID":"$P2P_PORT" --grpc.address="$CHAIN_ID":"$GRPC_PORT" --pruning=nothing \ No newline at end of file +gaiad start --home "$home" --pruning=nothing \ No newline at end of file diff --git a/ci/gaia.Dockerfile b/ci/gaia.Dockerfile index 3f6e5d6025..9b93b41077 100644 --- a/ci/gaia.Dockerfile +++ b/ci/gaia.Dockerfile @@ -32,6 +32,9 @@ ENV GAIA /gaia # Install ca-certificates RUN apk add --update ca-certificates +# Add jq for debugging +RUN apk add --no-cache jq curl + WORKDIR $GAIA # Copy over binaries from the build-env diff --git a/ci/relayer.Dockerfile b/ci/relayer.Dockerfile index f2eba48d3d..16633b389d 100644 --- a/ci/relayer.Dockerfile +++ b/ci/relayer.Dockerfile @@ -23,9 +23,8 @@ FROM rust:slim # Copy relayer executable COPY --from=build-env /repo/target/debug/rrly /usr/bin/rrly -ENV RELAYER /relayer - -WORKDIR $RELAYER +# Relayer folder +WORKDIR /relayer # Copy configuration file COPY ci/simple_config.toml . @@ -36,5 +35,4 @@ COPY ci/setup_relayer.sh . # Make it executable RUN chmod +x setup_relayer.sh -# Entrypoint -ENTRYPOINT ["/bin/sh", "-c", "/relayer/setup_relayer.sh"] +ENTRYPOINT ["/bin/sh"] diff --git a/ci/setup_relayer.sh b/ci/setup_relayer.sh index 09085c7508..b838676474 100644 --- a/ci/setup_relayer.sh +++ b/ci/setup_relayer.sh @@ -5,24 +5,38 @@ CONFIG_PATH="$RELAYER_DIR"/"$CONFIG" echo Config: "$CONFIG_PATH" echo "Setting up relayer for chains:" -echo Chain: "$CHAIN_A" -echo Chain: "$CHAIN_B" +echo => Chain: "$CHAIN_A" [$CHAIN_A_HOME] +echo => Chain: "$CHAIN_B" [$CHAIN_B_HOME] +echo Waiting 30 seconds for chains to generate blocks... +sleep 30 +echo Done waiting, proceeding... echo "-------------------------------------------------------------------------------------------------------------------" -echo " Show relayer version" +echo "Show relayer version" echo "-------------------------------------------------------------------------------------------------------------------" rrly version echo "-------------------------------------------------------------------------------------------------------------------" -echo " Add light client configuration for chains" +echo "Add light clients configuration for chains" echo "-------------------------------------------------------------------------------------------------------------------" -rrly -c "$CONFIG_PATH" light add tcp://$CHAIN_A:26657 -c $CHAIN_A -s /data/$CHAIN_A -p -rrly -c "$CONFIG_PATH" light add tcp://$CHAIN_A:26657 -c $CHAIN_A -s /data/$CHAIN_A -rrly -c "$CONFIG_PATH" light add tcp://$CHAIN_B:26557 -c $CHAIN_B -s /data/$CHAIN_B -p -rrly -c "$CONFIG_PATH" light add tcp://$CHAIN_B:26557 -c $CHAIN_B -s /data/$CHAIN_B +rrly -c "$CONFIG_PATH" light add tcp://"$CHAIN_A":26657 -c "$CHAIN_A" -s "$CHAIN_A_HOME" -p -y --force +sleep 5 +echo "-------------------------------------------------------------------------------------------------------------------" +rrly -c "$CONFIG_PATH" light add tcp://"$CHAIN_B":26557 -c "$CHAIN_B" -s "$CHAIN_B_HOME" -p -y --force +sleep 5 +echo "-------------------------------------------------------------------------------------------------------------------" +rrly -c "$CONFIG_PATH" light add tcp://"$CHAIN_B":26557 -c "$CHAIN_A" -s "$CHAIN_A_HOME" -y --force +sleep 5 +echo "-------------------------------------------------------------------------------------------------------------------" +rrly -c "$CONFIG_PATH" light add tcp://"$CHAIN_A":26657 -c "$CHAIN_B" -s "$CHAIN_B_HOME" -y --force +sleep 5 +echo "-------------------------------------------------------------------------------------------------------------------" +echo "Add keys for chains" +echo "-------------------------------------------------------------------------------------------------------------------" +rrly -c "$CONFIG_PATH" keys add "$CHAIN_A" "$CHAIN_A_HOME"/key_seed.json +rrly -c "$CONFIG_PATH" keys add "$CHAIN_B" "$CHAIN_A_HOME"/key_seed.json echo "-------------------------------------------------------------------------------------------------------------------" -echo " Add keys for chains" +echo "Create client transactions" echo "-------------------------------------------------------------------------------------------------------------------" -rrly -c "$CONFIG_PATH" keys add "$CHAIN_A" /data/"$CHAIN_A"/key_seed.json -rrly -c "$CONFIG_PATH" keys add "$CHAIN_B" /data/"$CHAIN_B"/key_seed.json \ No newline at end of file +rrly -c "$CONFIG_PATH" tx raw create-client "$CHAIN_A" "$CHAIN_B" "$CHAIN_B"_client diff --git a/ci/simple_config.toml b/ci/simple_config.toml index bccea9abd7..135d16fd6c 100644 --- a/ci/simple_config.toml +++ b/ci/simple_config.toml @@ -5,7 +5,7 @@ strategy = 'naive' [[chains]] id = 'ibc0' rpc_addr = 'tcp://ibc0:26657' -grpc_addr = 'tcp://localhost:9090' +grpc_addr = 'tcp://ibc0:9090' account_prefix = 'cosmos' key_name = 'testkey' store_prefix = 'ibc' @@ -16,8 +16,8 @@ trusting_period = '14days' [[chains]] id = 'ibc1' -rpc_addr = 'tcp://localhost:26557' -grpc_addr = 'tcp://localhost:9090' +rpc_addr = 'tcp://ibc1:26557' +grpc_addr = 'tcp://ibc1:9091' account_prefix = 'cosmos' key_name = 'testkey' store_prefix = 'ibc' diff --git a/docker-compose.yml b/docker-compose.yml index c0fe003710..6881c2ac4f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,8 @@ version: '3' services: ibc0: container_name: ibc0 + logging: + driver: none build: context: . dockerfile: ci/gaia.Dockerfile @@ -20,10 +22,12 @@ services: volumes: - chain-data:/data networks: - - relaynet -# ipv4_address: 192.168.10.2 + relaynet: + ipv4_address: 192.168.10.2 ibc1: container_name: ibc1 + logging: + driver: none build: context: . dockerfile: ci/gaia.Dockerfile @@ -41,25 +45,31 @@ services: volumes: - chain-data:/data networks: - - relaynet -# ipv4_address: 192.168.10.3 + relaynet: + ipv4_address: 192.168.10.3 relayer: depends_on: - ibc0 - ibc1 container_name: relayer + stdin_open: true + tty: true + command: ["-c", "/relayer/setup_relayer.sh"] build: context: . dockerfile: ci/relayer.Dockerfile environment: - CHAIN_A=ibc0 + - CHAIN_A_HOME=/data/ibc0 - CHAIN_B=ibc1 + - CHAIN_B_HOME=/data/ibc1 - CONFIG=simple_config.toml - RELAYER_DIR=/relayer volumes: - chain-data:/data networks: - - relaynet + relaynet: + ipv4_address: 192.168.10.4 networks: relaynet: