Skip to content

Commit

Permalink
Adding support for proper networking so containers can communicate (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
andynog committed Dec 3, 2020
1 parent 1de1f7c commit 9ccef34
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 32 deletions.
44 changes: 24 additions & 20 deletions ci/bootstrap_gaia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,71 @@
# coins to add to each account
coins="100000000000stake,100000000000samoleans"

home="/data/$CHAIN_ID"

echo Node: "$MONIKER"
echo Chain: "$CHAIN_ID"
echo Home_Dir: "$home"

# Clean home dir if exists
rm -Rf "$home"

# Create home dir
mkdir -p "$home"

# Check gaia version
echo "-------------------------------------------------------------------------------------------------------------------"
echo "Gaiad version"
echo "-------------------------------------------------------------------------------------------------------------------"
gaiad version --long

# Create home dir
mkdir -p "$HOME_DIR"

echo "-------------------------------------------------------------------------------------------------------------------"
echo "Initialize chain $CHAIN_ID"
echo "-------------------------------------------------------------------------------------------------------------------"
gaiad init "$MONIKER" --chain-id "$CHAIN_ID" --home "$HOME_DIR"
gaiad init "$MONIKER" --chain-id "$CHAIN_ID" --home "$home"

echo "-------------------------------------------------------------------------------------------------------------------"
echo "Adding validator key"
echo "-------------------------------------------------------------------------------------------------------------------"
gaiad keys add validator --keyring-backend="test" --home $HOME_DIR --output json > "$HOME_DIR/validator_seed.json"
cat "$HOME_DIR/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_DIR --output json > "$HOME_DIR/key_seed.json"
cp "$HOME_DIR/key_seed.json" /data/key_seed_$CHAIN_ID.json
cat "$HOME_DIR/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 "-------------------------------------------------------------------------------------------------------------------"
gaiad --home $HOME_DIR add-genesis-account $(gaiad --home $HOME_DIR keys --keyring-backend="test" show user -a) $coins
# shellcheck disable=SC2046
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 "-------------------------------------------------------------------------------------------------------------------"
gaiad --home $HOME_DIR add-genesis-account $(gaiad --home $HOME_DIR keys --keyring-backend="test" show validator -a) $coins
# shellcheck disable=SC2046
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_DIR 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_DIR
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_DIR \
--address tcp://0.0.0.0:$RPC_PORT \
--p2p.laddr tcp://0.0.0.0:$P2P_PORT \
--grpc.address="0.0.0.0:$GRPC_PORT" \
--pruning=nothing

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
4 changes: 3 additions & 1 deletion ci/gaia.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN git clone https://github.com/cosmos/gaia /go/src/github.com/cosmos/gaia
# Set working directory for the build
WORKDIR /go/src/github.com/cosmos/gaia

# Checkout branch (TODO make this a parameter)
# Checkout branch
RUN git checkout $release

# Install minimum necessary dependencies, build Cosmos SDK, remove packages
Expand Down Expand Up @@ -43,5 +43,7 @@ COPY ci/bootstrap_gaia.sh .
# Make it executable
RUN chmod +x bootstrap_gaia.sh

EXPOSE 26657 26656 9090

# Entrypoint
ENTRYPOINT ["/bin/sh", "-c", "/gaia/bootstrap_gaia.sh"]
22 changes: 18 additions & 4 deletions ci/setup_relayer.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
#!/bin/sh

# Configuration file
CONFIG_PATH="$RELAYER_DIR"/"$CONFIG"
echo Config: "$CONFIG_PATH"

echo "Setting up relayer for chains:"
echo Chain: "$CHAIN_A"
echo Chain: "$CHAIN_B"

# Check gaia version
echo "-------------------------------------------------------------------------------------------------------------------"
echo "Relayer version"
echo " Show relayer version"
echo "-------------------------------------------------------------------------------------------------------------------"
rrly
rrly version

ls -allh /data
echo "-------------------------------------------------------------------------------------------------------------------"
echo " Add light client 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

echo "-------------------------------------------------------------------------------------------------------------------"
echo " Add keys for chains"
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
15 changes: 8 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ services:
environment:
- CHAIN_ID=ibc0
- MONIKER=node01
- HOME_DIR=/gaia/ibc0
- RPC_PORT=26657
- P2P_PORT=26656
- GRPC_PORT=9090
volumes:
- chain-data:/data
networks:
relaynet:
ipv4_address: 192.168.10.2
- relaynet
# ipv4_address: 192.168.10.2
ibc1:
container_name: ibc1
build:
Expand All @@ -36,15 +35,14 @@ services:
environment:
- CHAIN_ID=ibc1
- MONIKER=node01
- HOME_DIR=/gaia/ibc1
- RPC_PORT=26557
- P2P_PORT=26556
- GRPC_PORT=9091
volumes:
- chain-data:/data
networks:
relaynet:
ipv4_address: 192.168.10.3
- relaynet
# ipv4_address: 192.168.10.3
relayer:
depends_on:
- ibc0
Expand All @@ -57,8 +55,11 @@ services:
- CHAIN_A=ibc0
- CHAIN_B=ibc1
- CONFIG=simple_config.toml
- RELAYER_DIR=/relayer
volumes:
- chain-data:/data
- chain-data:/data
networks:
- relaynet

networks:
relaynet:
Expand Down

0 comments on commit 9ccef34

Please sign in to comment.