-
Notifications
You must be signed in to change notification settings - Fork 357
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
Scripts for Gaiad network with full-mesh IBC connections #898
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
docker-compose.gaiad.yml | ||
docker-compose.yml | ||
paths | ||
network*/ | ||
.hermes/ | ||
.gaia/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/sh | ||
|
||
############################## | ||
## Script setup | ||
############################## | ||
|
||
# Fail if there are any errors | ||
set -eu | ||
|
||
# Run in a subfolder, not in your $HOME (safeguard against accidental .gaia-deletions) | ||
test "$HOME" != "$(pwd)" | ||
|
||
EXPECTED_GAIAD_VERSION=4.2.1 | ||
DOCKER_IMAGE="cephalopodequipment/gaiad:${EXPECTED_GAIAD_VERSION}" | ||
GAIAD="docker run --rm -v $(pwd):/home/gaiad --entrypoint /usr/bin/gaiad ${DOCKER_IMAGE}" | ||
N="${1:-5}" | ||
echo "N=$N" | ||
|
||
############################## | ||
## Create gaiad config | ||
############################## | ||
|
||
for i in $(seq 1 "$N") | ||
do | ||
test -d "network$i" && continue | ||
echo "i=$i" | ||
$GAIAD testnet --chain-id "network$i" --keyring-backend test --node-dir-prefix "network${i}v" -o . --node-daemon-home . --v 1 | ||
mv "network${i}v0" "network$i" | ||
mv "gentxs" "network$i" | ||
$GAIAD keys add "network${i}c0" --keyring-backend test --keyring-dir "network$i" --output json > "network${i}/client_wallet_seed.json" | ||
$GAIAD add-genesis-account "network${i}c0" "10000000stake,10000network${i}coin" --keyring-backend test --home "network$i" | ||
done | ||
|
||
############################## | ||
## Create docker-compose.gaiad.yml | ||
############################## | ||
|
||
cat <<EOF > docker-compose.gaiad.yml | ||
services: | ||
EOF | ||
|
||
for i in $(seq 1 "$N") | ||
do | ||
RPC="$((26000 + 10 * i))" | ||
LEET="$((RPC + 1))" | ||
GRPC="$((RPC + 2))" | ||
PP="$((RPC + 3))" | ||
|
||
cat <<EOF >> docker-compose.gaiad.yml | ||
network${i}: | ||
container_name: network${i} | ||
image: "$DOCKER_IMAGE" | ||
entrypoint: "/usr/bin/gaiad" | ||
command: start --x-crisis-skip-assert-invariants | ||
ports: | ||
- "$RPC:26657" | ||
- "$LEET:1317" | ||
- "$GRPC:9090" | ||
- "$PP:26656" | ||
volumes: | ||
- $(pwd)/network${i}:/home/gaiad/.gaia | ||
EOF | ||
|
||
done | ||
|
||
############################## | ||
## Create full-mesh (default) networks connection graph | ||
############################## | ||
|
||
echo "# IBC full-mesh connection graph" > paths | ||
|
||
for i in $(seq 1 "$((N-1))") | ||
do | ||
for j in $(seq "$((i+1))" "$N") | ||
do | ||
test $i -eq $j && continue | ||
echo "$i $j" >> paths | ||
done | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/sh | ||
|
||
############################## | ||
## Script setup | ||
############################## | ||
|
||
# Fail if there are any errors | ||
set -eu | ||
|
||
# Run in a subfolder, not in your $HOME (safeguard against accidental .hermes-deletions) | ||
test "$HOME" != "$(pwd)" | ||
# But if hermes was not run locally, we're going to overcome the issue of not having a --home parameter | ||
ln -s $(pwd)/.hermes $HOME/.hermes || echo "$HOME/.hermes is already set, make sure you link it to .hermes here if you run things locally" | ||
|
||
EXPECTED_HERMES_VERSION=0.2.0 | ||
DOCKER_IMAGE="informaldev/hermes:${EXPECTED_HERMES_VERSION}" | ||
HERMES="docker run --rm -v $(pwd):/home/hermes --entrypoint /usr/bin/hermes ${DOCKER_IMAGE}" | ||
N="${1:-5}" | ||
echo "N=$N" | ||
|
||
############################## | ||
## Create config.toml | ||
############################## | ||
|
||
rm -rf .hermes && mkdir .hermes | ||
|
||
cat <<EOF > .hermes/config.toml | ||
[global] | ||
strategy = 'naive' | ||
log_level = 'info' | ||
|
||
EOF | ||
|
||
for i in $(seq 1 "$N") | ||
do | ||
RPC="$((26000 + 10 * i))" | ||
GRPC="$((RPC + 2))" | ||
|
||
cat <<EOF >> .hermes/config.toml | ||
[[chains]] | ||
id='network${i}' | ||
rpc_addr='http://localhost:${RPC}' | ||
grpc_addr='https://localhost:${GRPC}' | ||
websocket_addr='ws://localhost:${RPC}/websocket' | ||
rpc_timeout='1s' | ||
account_prefix='cosmos' | ||
key_name='network${i}c0' | ||
store_prefix='ibc' | ||
fee_denom='stake' | ||
|
||
[chains.trust_threshold] | ||
numerator = '1' | ||
denominator = '3' | ||
|
||
EOF | ||
|
||
done | ||
|
||
############################## | ||
## Add keys to hermes | ||
############################## | ||
|
||
for i in $(seq 1 "$N") | ||
do | ||
$HERMES keys add "network$i" -f "network${i}/client_wallet_seed.json" | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
############################## | ||
## Script setup | ||
############################## | ||
|
||
# Fail if there are any errors | ||
set -eu | ||
|
||
# Run in a subfolder, not in your $HOME (safeguard against accidental .hermes-deletions) | ||
test "$HOME" != "$(pwd)" | ||
# But if hermes was not run locally, we're going to overcome the issue of not having a --home parameter | ||
ln -s $(pwd)/.hermes $HOME/.hermes || echo "$HOME/.hermes is already set, make sure you link it to .hermes here if you run things locally" | ||
|
||
EXPECTED_HERMES_VERSION=0.2.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we update this to 0.3.0? |
||
DOCKER_IMAGE="informaldev/hermes:${EXPECTED_HERMES_VERSION}" | ||
HERMES="docker run --rm -v $(pwd)/.hermes:/home/hermes/.hermes --net=host --entrypoint /usr/bin/hermes ${DOCKER_IMAGE}" | ||
|
||
############################## | ||
## Create paths on the networks | ||
############################## | ||
|
||
while read -r line; | ||
do | ||
VALID="$(echo "$line" | grep '^[ ]*[0-9]\+[ ]\+[0-9]\+[ ]*$' || echo "")" | ||
test -n "$VALID" || continue | ||
i="$(echo "$line" | grep -o '[0-9]\+' | head -1)" | ||
j="$(echo "$line" | grep -o '[0-9]\+' | tail -1)" | ||
echo "Connecting network$i and network$j" | ||
$HERMES create channel "network$i" "network$j" --port-a transfer --port-b transfer | ||
done < paths | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/sh | ||
|
||
############################## | ||
## Script setup | ||
############################## | ||
|
||
# Fail if there are any errors | ||
set -eu | ||
|
||
# Run in a subfolder, not in your $HOME (safeguard against accidental .hermes-deletions) | ||
test "$HOME" != "$(pwd)" | ||
|
||
EXPECTED_HERMES_VERSION=0.2.0 | ||
DOCKER_IMAGE="informaldev/hermes:${EXPECTED_HERMES_VERSION}" | ||
|
||
############################## | ||
## Create docker-compose.yml (set of hermes relayers) | ||
############################## | ||
|
||
cat <<EOF > docker-compose.yml | ||
services: | ||
EOF | ||
|
||
while read -r line; | ||
do | ||
VALID="$(echo "$line" | grep '^[ ]*[0-9]\+[ ]\+[0-9]\+[ ]*$' || echo "")" | ||
test -n "$VALID" || continue | ||
i="$(echo "$line" | grep -o '[0-9]\+' | head -1)" | ||
j="$(echo "$line" | grep -o '[0-9]\+' | tail -1)" | ||
|
||
cat <<EOF >> docker-compose.yml | ||
hermes-${i}-${j}: | ||
container_name: hermes-${i}-${j} | ||
network_mode: "host" | ||
image: "$DOCKER_IMAGE" | ||
entrypoint: "/usr/bin/hermes" | ||
command: start network$i network$j -p transfer -c channel-0 | ||
volumes: | ||
- $(pwd)/.hermes:/home/hermes/.hermes | ||
EOF | ||
|
||
done < paths | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Number of nodes | ||
N?=5 | ||
|
||
all: setup-network setup-relay | ||
|
||
setup-network: config-files network-up | ||
setup-relay: config-onchain relay-up | ||
|
||
config-files: | ||
./1-create-network-config.sh $(N) | ||
./2-create-hermes-config.sh $(N) | ||
|
||
network-up: | ||
docker compose -f docker-compose.gaiad.yml -p gaiad up -d | ||
sleep 5 | ||
|
||
network-start: | ||
docker compose -f docker-compose.gaiad.yml -p gaiad start | ||
|
||
network-stop: | ||
docker compose -f docker-compose.gaiad.yml -p gaiad stop | ||
|
||
network-down: | ||
docker compose -f docker-compose.gaiad.yml -p gaiad down || true | ||
|
||
config-onchain: paths | ||
./3-create-onchain-config.sh | ||
./4-create-relayer-config.sh | ||
|
||
# If this command fails with aliases, you need to upgrade Docker CLI to 1.0.14 or above. | ||
relay-up: | ||
docker compose up -d | ||
|
||
relay-down: | ||
docker compose down || true | ||
|
||
clean: relay-down network-down | ||
@rm -rf gentxs network[0-9]* docker-compose.gaiad.yml docker-compose.yml paths .gaia .hermes | ||
@echo DONE | ||
|
||
.PHONY: config-files network-up network-down config-onchain relay-up relay-start relay-stop relay-down clean all |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wonderful! Looking forward to trying it out!
I'd love to be able to spin up a mesh with chains using different versions of gaia to test IBC and relayer compatibility between them. Testing that a gaia v4 chain can interact with gaia v5 using the same relayer binary
Another wishlist item is using non-gaia docker images, so chains could test out their docker image before upgrading on mainnet, but I think it might be best to let non-gaia chains copy the script and replace its relevant info rather than maintaining scripts for several chains
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! There were a lot of good points from the IBC-rs team about this, including non-gaia docker images. I'm not sure yet how we move forward because I find the current configuration fairly inflexible. We have another tool in the works that is much more flexible for developer work and allows you to choose your binaries on a per-node basis. (Issue #902 .)
So, we might continue expanding the configuration here or maybe we end up merging the two tools. But I'll definitely keep this in mind.
Small trick right now: you can do
and edit the gaiad images that will be used before they are started.