-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripts for IBC connection setup, update README
- Loading branch information
1 parent
ce6ec99
commit 08b9b29
Showing
23 changed files
with
528 additions
and
8 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ release/ | |
.idea/ | ||
.vscode/ | ||
.DS_Store | ||
data |
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
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,44 @@ | ||
# Hermes Relayer | ||
|
||
[Hermes](https://hermes.informal.systems/) is a Rust implementation of a relayer for the [Inter-Blockchain Communication (IBC)](https://ibcprotocol.org/) protocol. | ||
|
||
> The Inter-Blockchain Communication protocol is an end-to-end, connection-oriented, stateful protocol for reliable, ordered, and authenticated communication between modules on separate distributed ledgers. | ||
## Getting started | ||
|
||
- Install [Rust](https://www.rust-lang.org/tools/install) | ||
- Install [Hermes](https://hermes.informal.systems/installation.html) | ||
|
||
The following directory contains a basic executable script which handles creation of clients, connections and channels in order to facilitate packet relaying between distributed ledgers using the IBC protocol. | ||
This serves as a basis for demonstration of interchain accounts e2e functionality validation. | ||
|
||
## Usage | ||
|
||
- Before attempting to create clients, connections and channels, the private keys for existing chains must be restored. Please note - currently the relayer does NOT support a keyring store to securely store the private key file. The key file will be stored on the local file system in the user `$HOME` folder under `$HOME/.hermes` | ||
``` | ||
hermes -c config.toml keys restore $CHAIN_ID -m $MNEMONIC | ||
hermes -c config.toml keys restore $CHAIN_ID -m $MNEMONIC | ||
``` | ||
|
||
- Execute the script | ||
``` | ||
./hermes.sh | ||
``` | ||
|
||
- Useful commands | ||
``` | ||
# Query client state | ||
hermes query client state $CHAIN_ID 07-tendermint-0 | ||
# Update client state by sending an update-client transaction | ||
hermes tx raw update-client $CHAIN_ID 07-tendermint-0 | ||
# Query a connection end | ||
hermes query connection end $CHAIN_ID connection-0 | ||
# Query channel ends | ||
hermes query channel end $CHAIN_ID transfer channel-0 | ||
hermes query channel end $CHAIN_ID ibcaccount channel-1 | ||
``` | ||
|
||
Please refer to the [Hermes documentation](https://hermes.informal.systems/) for more information regarding various commands. |
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,132 @@ | ||
# The global section has parameters that apply globally to the relayer operation. | ||
[global] | ||
|
||
# Specify the verbosity for the relayer logging output. Default: 'info' | ||
# Valid options are 'error', 'warn', 'info', 'debug', 'trace'. | ||
log_level = 'trace' | ||
|
||
|
||
# Specify the mode to be used by the relayer. [Required] | ||
[mode] | ||
|
||
# Specify the client mode. | ||
[mode.clients] | ||
|
||
# Whether or not to enable the client workers. [Required] | ||
enabled = true | ||
|
||
# Whether or not to enable periodic refresh of clients. [Default: true] | ||
# Note: Even if this is disabled, clients will be refreshed automatically if | ||
# there is activity on a connection or channel they are involved with. | ||
refresh = true | ||
|
||
# Whether or not to enable misbehaviour detection for clients. [Default: false] | ||
misbehaviour = true | ||
|
||
# Specify the connections mode. | ||
[mode.connections] | ||
|
||
# Whether or not to enable the connection workers for handshake completion. [Required] | ||
enabled = true | ||
|
||
# Specify the channels mode. | ||
[mode.channels] | ||
|
||
# Whether or not to enable the channel workers for handshake completion. [Required] | ||
enabled = true | ||
|
||
# Specify the packets mode. | ||
[mode.packets] | ||
|
||
# Whether or not to enable the packet workers. [Required] | ||
enabled = true | ||
|
||
# Parametrize the periodic packet clearing feature. | ||
# Interval (in number of blocks) at which pending packets | ||
# should be eagerly cleared. A value of '0' will disable | ||
# periodic packet clearing. [Default: 100] | ||
clear_interval = 100 | ||
|
||
# Whether or not to clear packets on start. [Default: false] | ||
clear_on_start = true | ||
|
||
# Toggle the transaction confirmation mechanism. | ||
# The tx confirmation mechanism periodically queries the `/tx_search` RPC | ||
# endpoint to check that previously-submitted transactions | ||
# (to any chain in this config file) have delivered successfully. | ||
# Experimental feature. Affects telemetry if set to false. | ||
# [Default: true] | ||
tx_confirmation = true | ||
|
||
# The REST section defines parameters for Hermes' built-in RESTful API. | ||
# https://hermes.informal.systems/rest.html | ||
[rest] | ||
|
||
# Whether or not to enable the REST service. Default: false | ||
enabled = true | ||
|
||
# Specify the IPv4/6 host over which the built-in HTTP server will serve the RESTful | ||
# API requests. Default: 127.0.0.1 | ||
host = '127.0.0.1' | ||
|
||
# Specify the port over which the built-in HTTP server will serve the restful API | ||
# requests. Default: 3000 | ||
port = 3000 | ||
|
||
|
||
# The telemetry section defines parameters for Hermes' built-in telemetry capabilities. | ||
# https://hermes.informal.systems/telemetry.html | ||
[telemetry] | ||
|
||
# Whether or not to enable the telemetry service. Default: false | ||
enabled = false | ||
|
||
# Specify the IPv4/6 host over which the built-in HTTP server will serve the metrics | ||
# gathered by the telemetry service. Default: 127.0.0.1 | ||
host = '127.0.0.1' | ||
|
||
# Specify the port over which the built-in HTTP server will serve the metrics gathered | ||
# by the telemetry service. Default: 3001 | ||
port = 3001 | ||
|
||
[[chains]] | ||
id = 'test-1' | ||
rpc_addr = 'http://127.0.0.1:16657' | ||
grpc_addr = 'http://127.0.0.1:8090' | ||
websocket_addr = 'ws://127.0.0.1:16657/websocket' | ||
rpc_timeout = '10s' | ||
account_prefix = 'cosmos' | ||
key_name = 'testkey' | ||
store_prefix = 'ibc' | ||
default_gas = 100000 | ||
max_gas = 3000000 | ||
gas_price = { price = 0.001, denom = 'stake' } | ||
gas_adjustment = 0.1 | ||
max_msg_num = 30 | ||
max_tx_size = 2097152 | ||
clock_drift = '5s' | ||
max_block_time = '10s' | ||
trusting_period = '14days' | ||
trust_threshold = { numerator = '1', denominator = '3' } | ||
address_type = { derivation = 'cosmos' } | ||
|
||
[[chains]] | ||
id = 'test-2' | ||
rpc_addr = 'http://127.0.0.1:26657' | ||
grpc_addr = 'http://127.0.0.1:9090' | ||
websocket_addr = 'ws://127.0.0.1:26657/websocket' | ||
rpc_timeout = '10s' | ||
account_prefix = 'cosmos' | ||
key_name = 'testkey' | ||
store_prefix = 'ibc' | ||
default_gas = 100000 | ||
max_gas = 3000000 | ||
gas_price = { price = 0.001, denom = 'stake' } | ||
gas_adjustment = 0.1 | ||
max_msg_num = 30 | ||
max_tx_size = 2097152 | ||
clock_drift = '5s' | ||
max_block_time = '10s' | ||
trusting_period = '14days' | ||
trust_threshold = { numerator = '1', denominator = '3' } | ||
address_type = { derivation = 'cosmos' } |
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,11 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Load shell variables | ||
. ./network/hermes/variables.sh | ||
|
||
### Configure the clients and connection | ||
echo "Initiating connection handshake..." | ||
$HERMES_BINARY -c $CONFIG_DIR create connection test-1 test-2 | ||
|
||
sleep 2 |
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,14 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Load shell variables | ||
. ./network/hermes/variables.sh | ||
|
||
### Sleep is needed otherwise the relayer crashes when trying to init | ||
sleep 1 | ||
### Restore Keys | ||
$HERMES_BINARY -c ./network/hermes/config.toml keys restore test-1 -m "alley afraid soup fall idea toss can goose become valve initial strong forward bright dish figure check leopard decide warfare hub unusual join cart" | ||
sleep 5 | ||
|
||
$HERMES_BINARY -c ./network/hermes/config.toml keys restore test-2 -m "record gift you once hip style during joke field prize dust unique length more pencil transfer quit train device arrive energy sort steak upset" | ||
sleep 5 |
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,8 @@ | ||
#!/bin/bash | ||
|
||
# Load shell variables | ||
. ./network/hermes/variables.sh | ||
|
||
# Start the hermes relayer in multi-paths mode | ||
echo "Starting hermes relayer..." | ||
$HERMES_BINARY -c $CONFIG_DIR start |
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,4 @@ | ||
#!/bin/bash | ||
HERMES_BINARY=hermes | ||
HERMES_DIRECTORY=./network/hermes/ | ||
CONFIG_DIR=./network/hermes/config.toml |
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,91 @@ | ||
#!/bin/bash | ||
|
||
BINARY=gaia-wasm-zoned | ||
CHAIN_DIR=./data | ||
CHAINID_1=test-1 | ||
CHAINID_2=test-2 | ||
VAL_MNEMONIC_1="clock post desk civil pottery foster expand merit dash seminar song memory figure uniform spice circle try happy obvious trash crime hybrid hood cushion" | ||
VAL_MNEMONIC_2="angry twist harsh drastic left brass behave host shove marriage fall update business leg direct reward object ugly security warm tuna model broccoli choice" | ||
DEMO_MNEMONIC_1="banner spread envelope side kite person disagree path silver will brother under couch edit food venture squirrel civil budget number acquire point work mass" | ||
DEMO_MNEMONIC_2="veteran try aware erosion drink dance decade comic dawn museum release episode original list ability owner size tuition surface ceiling depth seminar capable only" | ||
RLY_MNEMONIC_1="alley afraid soup fall idea toss can goose become valve initial strong forward bright dish figure check leopard decide warfare hub unusual join cart" | ||
RLY_MNEMONIC_2="record gift you once hip style during joke field prize dust unique length more pencil transfer quit train device arrive energy sort steak upset" | ||
P2PPORT_1=16656 | ||
P2PPORT_2=26656 | ||
RPCPORT_1=16657 | ||
RPCPORT_2=26657 | ||
RESTPORT_1=1316 | ||
RESTPORT_2=1317 | ||
ROSETTA_1=8080 | ||
ROSETTA_2=8081 | ||
|
||
# Stop if it is already running | ||
if pgrep -x "$BINARY" >/dev/null; then | ||
echo "Terminating $BINARY..." | ||
killall $BINARY | ||
fi | ||
|
||
echo "Removing previous data..." | ||
rm -rf $CHAIN_DIR/$CHAINID_1 &> /dev/null | ||
rm -rf $CHAIN_DIR/$CHAINID_2 &> /dev/null | ||
|
||
# Add directories for both chains, exit if an error occurs | ||
if ! mkdir -p $CHAIN_DIR/$CHAINID_1 2>/dev/null; then | ||
echo "Failed to create chain folder. Aborting..." | ||
exit 1 | ||
fi | ||
|
||
if ! mkdir -p $CHAIN_DIR/$CHAINID_2 2>/dev/null; then | ||
echo "Failed to create chain folder. Aborting..." | ||
exit 1 | ||
fi | ||
|
||
echo "Initializing $CHAINID_1..." | ||
echo "Initializing $CHAINID_2..." | ||
$BINARY init test --home $CHAIN_DIR/$CHAINID_1 --chain-id=$CHAINID_1 | ||
$BINARY init test --home $CHAIN_DIR/$CHAINID_2 --chain-id=$CHAINID_2 | ||
|
||
echo "Adding genesis accounts..." | ||
echo $VAL_MNEMONIC_1 | $BINARY keys add val1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test | ||
echo $VAL_MNEMONIC_2 | $BINARY keys add val2 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test | ||
echo $DEMO_MNEMONIC_1 | $BINARY keys add demowallet1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test | ||
echo $DEMO_MNEMONIC_2 | $BINARY keys add demowallet2 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test | ||
echo $RLY_MNEMONIC_1 | $BINARY keys add rly1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test | ||
echo $RLY_MNEMONIC_2 | $BINARY keys add rly2 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test | ||
|
||
$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show val1 --keyring-backend test -a) 100000000000stake --home $CHAIN_DIR/$CHAINID_1 | ||
$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_2 keys show val2 --keyring-backend test -a) 100000000000stake --home $CHAIN_DIR/$CHAINID_2 | ||
$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show demowallet1 --keyring-backend test -a) 100000000000stake --home $CHAIN_DIR/$CHAINID_1 | ||
$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_2 keys show demowallet2 --keyring-backend test -a) 100000000000stake --home $CHAIN_DIR/$CHAINID_2 | ||
$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_1 keys show rly1 --keyring-backend test -a) 100000000000stake --home $CHAIN_DIR/$CHAINID_1 | ||
$BINARY add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAINID_2 keys show rly2 --keyring-backend test -a) 100000000000stake --home $CHAIN_DIR/$CHAINID_2 | ||
|
||
echo "Creating and collecting gentx..." | ||
$BINARY gentx val1 7000000000stake --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --keyring-backend test | ||
$BINARY gentx val2 7000000000stake --home $CHAIN_DIR/$CHAINID_2 --chain-id $CHAINID_2 --keyring-backend test | ||
$BINARY collect-gentxs --home $CHAIN_DIR/$CHAINID_1 | ||
$BINARY collect-gentxs --home $CHAIN_DIR/$CHAINID_2 | ||
|
||
echo "Changing defaults and ports in app.toml and config.toml files..." | ||
sed -i -e 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT_1"'"#g' $CHAIN_DIR/$CHAINID_1/config/config.toml | ||
sed -i -e 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT_1"'"#g' $CHAIN_DIR/$CHAINID_1/config/config.toml | ||
sed -i -e 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAIN_DIR/$CHAINID_1/config/config.toml | ||
sed -i -e 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAIN_DIR/$CHAINID_1/config/config.toml | ||
sed -i -e 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/$CHAINID_1/config/config.toml | ||
sed -i -e 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml | ||
sed -i -e 's/swagger = false/swagger = true/g' $CHAIN_DIR/$CHAINID_1/config/app.toml | ||
sed -i -e 's#"tcp://0.0.0.0:1317"#"tcp://0.0.0.0:'"$RESTPORT_1"'"#g' $CHAIN_DIR/$CHAINID_1/config/app.toml | ||
sed -i -e 's#":8080"#":'"$ROSETTA_1"'"#g' $CHAIN_DIR/$CHAINID_1/config/app.toml | ||
|
||
sed -i -e 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT_2"'"#g' $CHAIN_DIR/$CHAINID_2/config/config.toml | ||
sed -i -e 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT_2"'"#g' $CHAIN_DIR/$CHAINID_2/config/config.toml | ||
sed -i -e 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAIN_DIR/$CHAINID_2/config/config.toml | ||
sed -i -e 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAIN_DIR/$CHAINID_2/config/config.toml | ||
sed -i -e 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/$CHAINID_2/config/config.toml | ||
sed -i -e 's/enable = false/enable = true/g' $CHAIN_DIR/$CHAINID_2/config/app.toml | ||
sed -i -e 's/swagger = false/swagger = true/g' $CHAIN_DIR/$CHAINID_2/config/app.toml | ||
sed -i -e 's#"tcp://0.0.0.0:1317"#"tcp://0.0.0.0:'"$RESTPORT_2"'"#g' $CHAIN_DIR/$CHAINID_2/config/app.toml | ||
sed -i -e 's#":8080"#":'"$ROSETTA_2"'"#g' $CHAIN_DIR/$CHAINID_2/config/app.toml | ||
|
||
# Update host chain genesis to allow x/bank/MsgSend ICA tx execution | ||
sed -i -e 's/\"allow_messages\":.*/\"allow_messages\": [\"\/cosmos.bank.v1beta1.MsgSend\", \"\/cosmos.staking.v1beta1.MsgDelegate\"]/g' $CHAIN_DIR/$CHAINID_2/config/genesis.json |
Oops, something went wrong.