Skip to content

Commit

Permalink
Working relayer cmds light client add and keys add (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
andynog committed Dec 4, 2020
1 parent 7140f3b commit 8581255
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 37 deletions.
29 changes: 16 additions & 13 deletions ci/bootstrap_gaia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
gaiad start --home "$home" --pruning=nothing
3 changes: 3 additions & 0 deletions ci/gaia.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions ci/relayer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand All @@ -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"]
36 changes: 25 additions & 11 deletions ci/setup_relayer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
rrly -c "$CONFIG_PATH" tx raw create-client "$CHAIN_A" "$CHAIN_B" "$CHAIN_B"_client
6 changes: 3 additions & 3 deletions ci/simple_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
20 changes: 15 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ version: '3'
services:
ibc0:
container_name: ibc0
logging:
driver: none
build:
context: .
dockerfile: ci/gaia.Dockerfile
Expand All @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 8581255

Please sign in to comment.