-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,750 additions
and
3 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 |
---|---|---|
|
@@ -97,4 +97,4 @@ networks: | |
driver: default | ||
config: | ||
- | ||
subnet: 192.168.10.0/16 | ||
subnet: 192.168.10.0/24 # 254 hosts |
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,5 @@ | ||
/node* | ||
gaia/ | ||
test.sh | ||
|
||
hermes |
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,77 @@ | ||
## Test IBC gaia <-> e-money local testnets | ||
|
||
### Components installation | ||
|
||
#### Gaia v5.0.5+ (sdk 0.42.9 including fix for Cosmos #9800) | ||
|
||
Install `gaiad` and place in path | ||
|
||
``` shell | ||
git clone https://github.com/cosmos/gaia | ||
git checkout v5.0.5 | ||
make build | ||
cp build/gaiad $GOBIN | ||
``` | ||
|
||
#### Hermes v0.6.2+ | ||
Please download the latest Hermes 0.6.x binary release from the [hermes releases](https://github.com/informalsystems/ibc-rs/releases). As of this writing hermes 0.6.2 was the latest. | ||
|
||
Copy the binary `hermes` in github.com/e-money/em-ledger/networks/ibc | ||
There is a dependency with the `gm` script in the same folder requiring the Hermes binary to be in the same folder. | ||
|
||
There is a `.gitignore` for the `hermes` binary. | ||
|
||
TODO look to the possibility of reusing hermes from the path. | ||
|
||
### Launch e-money with predictable chain-id | ||
|
||
``` shell | ||
cd em-ledger | ||
docker-compose kill | ||
make clean | ||
REUSE=1 make local-testnet | ||
``` | ||
|
||
### Relay bi-directionally tokens between a 4-node gaia and e-money local testnets with hermes | ||
|
||
```shell | ||
cd networks/ibc | ||
./run.sh #ignore errors* | ||
``` | ||
###* | ||
Ignore errors that do not halt the script. `run.sh` tests the existence of IBC primitives before creating new ones and thus the errors within if test brackets. However, the script should complete in its **entirety**. | ||
|
||
### run.sh performs these functions: | ||
1. Launches gaia with 4 full-node + 1 validator-node local testnet | ||
2. Imports the testnets keys into the hermes configuration | ||
3. Establishes the channel, port, connection handshakes | ||
4. Relays and Refunds tokens bi-directionally in both chains. | ||
|
||
### Side note gm script | ||
|
||
The gm script is a bootstrapping script for launching IBC compatible gaia n-node testnets. | ||
Being versatile it allows launching multiple gaia testnets. | ||
It offers start, stop, reset functionality similarly to docker-compose. | ||
|
||
### 3rd IBC testnet | ||
Within the peer ../emibctokens folder there is a Stargate IBC compatible chain to test a 3rd hop if needed. It is a Starport created chain from scratch, however parallel to its IBC module there is a POC swap module in progress. In any case its tokens relay functions are operable. Please look into its **../emibctokens/readme.md** for details to launch it. | ||
|
||
### Test Cases | ||
[List as a docs.google.com/spreadsheets](https://docs.google.com/spreadsheets/d/16u6TO6a-XddMoYzI1RwEyWndKAV00lbV97_A-dHrWfQ/edit?usp=sharing) | ||
|
||
### Scripts | ||
|
||
| name | description | | ||
|---|---| | ||
| `start` | Starts a local gaia network using `gm` and initialize an IBC connection between a local e-money net and the local gaia net. | | ||
| `run.sh` | Perform a test of fungible token transfers between a local e-money net and a local gaia net. | | ||
| `gm` | The Gaiad Manager from Informal Systems. https://github.com/informalsystems/ibc-rs/tree/v0.6.2/scripts/gm | | ||
| `ibc-relay.sh` | Used by `run.sh`. Uses `hermes` to perform IBC transactions across test networks | | ||
| `gaia-denom-path` | Look up human-readable denomination of an IBC asset on the gaia chain. | | ||
| `denom-path` | | | ||
| `emkey-2-hermes.sh` | | | ||
| `q-gaia-client` | | | ||
| `q-client` | | | ||
| `e-money.sh` | Configures the e-Money testnet with quicker block times etc. Used by `run.sh` and `start` | | ||
| `gaia_client_upd` | | | ||
| `client-upd` | | |
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,7 @@ | ||
{ | ||
"name": "authority", | ||
"type": "local", | ||
"address": "emoney1n5ggspeff4fxc87dvmg0ematr3qzw5l4v20mdv", | ||
"pubkey": "emoneypub1addwnpepqggnt28j2qe28tfc7gqujt2kmyg3nu9gkkpn2hrxvldug4mq4jwh5tf4z6u", | ||
"mnemonic": "play witness auto coast domain win tiny dress glare bamboo rent mule delay exact arctic vacuum laptop hidden siren sudden six tired fragile penalty" | ||
} |
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,18 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
EMONEY_CHAIN_ID="localnet_reuse" | ||
|
||
# update IBC client state | ||
CLIENT_ID="07-tendermint-0" | ||
|
||
function client_update() { | ||
local dst="$1" | ||
|
||
if hermes -c ./emoney-config.toml query client state "$dst" $CLIENT_ID ; then | ||
hermes -c ./emoney-config.toml tx raw update-client "$dst" $CLIENT_ID | ||
fi | ||
} | ||
|
||
client_update $EMONEY_CHAIN_ID |
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,31 @@ | ||
#!/bin/bash | ||
|
||
set +x | ||
|
||
usage() { | ||
echo "Usage: $0 <hash>" | ||
echo "Example IBC denomination hash ibc/93FF02E702BE88DE6309464BA7ABCC9932964FA348726B04B06EEE79ECB35768" | ||
echo "enter -> $0 93FF02E702BE88DE6309464BA7ABCC9932964FA348726B04B06EEE79ECB35768" | ||
echo " | ||
denom_trace: | ||
base_denom: samoleans | ||
path: transfer/channel-0 | ||
" | ||
exit 1 | ||
} | ||
|
||
missing() { | ||
echo "Missing $1 parameter. Please check if all parameters were specified." | ||
usage | ||
} | ||
|
||
if [ -z "$1" ]; then | ||
missing "denom-hash" | ||
fi | ||
|
||
if [ "$#" -gt 1 ]; then | ||
echo "Incorrect number of parameters." | ||
usage | ||
fi | ||
|
||
../../build/emd q ibc-transfer denom-trace "$1" |
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,33 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
EMONEY_HOME="../.." | ||
EMONEY_DC_YML="$EMONEY_HOME/docker-compose.yml" | ||
|
||
# Check platform | ||
platform='unknown' | ||
unamestr=$(uname) | ||
if [ "$unamestr" = 'Linux' ]; then | ||
platform='linux' | ||
fi | ||
|
||
# Set proper defaults and change ports (use a different sed for Mac or Linux) | ||
echo "Stopping the e-money testnet to make IBC appropriate genesis edits..." | ||
set -x | ||
docker-compose -f $EMONEY_DC_YML stop || true | ||
for (( i = 0; i < 4; i++ )); do | ||
if [ $platform = 'linux' ]; then | ||
sed -i 's#"172800s"#"200s"#g' $EMONEY_HOME/build/node$i/config/genesis.json | ||
sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $EMONEY_HOME/build/node$i/config/config.toml | ||
sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $EMONEY_HOME/build/node$i/config/config.toml | ||
sed -i 's/index_all_keys = false/index_all_keys = true/g' $EMONEY_HOME/build/node$i/config/config.toml | ||
else | ||
sed -i '' 's#"172800s"#"200s"#g' $EMONEY_HOME/build/node$i/config/genesis.json | ||
sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $EMONEY_HOME/build/node$i/config/config.toml | ||
sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $EMONEY_HOME/build/node$i/config/config.toml | ||
sed -i '' 's/index_all_keys = false/index_all_keys = true/g' $EMONEY_HOME/build/node$i/config/config.toml | ||
fi | ||
done | ||
docker-compose -f $EMONEY_DC_YML start | ||
sleep 13 |
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,7 @@ | ||
{ | ||
"name": "key1", | ||
"type": "local", | ||
"address": "emoney1gjudpa2cmwd27cjzespu2khrvy2ukje6zfevk5", | ||
"pubkey": "emoneypub1addwnpepqt9p2rj043zyg74ql87wlxafpe3ke6geqmxenu4gll3sj4wc06um7wymlju", | ||
"mnemonic": "document weekend believe whip diesel earth hope elder quiz pact assist quarter public deal height pulp roof organ animal health month holiday front pencil" | ||
} |
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,49 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
usage() { | ||
echo "Usage: $0 CONFIG_FILE e-money-chain-id" | ||
echo "Example: $0 ./emoney-config.toml localnet_reuse" | ||
exit 1 | ||
} | ||
|
||
missing() { | ||
echo "Missing $1 parameter. Please check if all parameters were specified." | ||
usage | ||
} | ||
|
||
if [ -z "$1" ]; then | ||
missing "CONFIG_FILE" | ||
fi | ||
|
||
if [ -z "$2" ]; then | ||
missing "EMONEY_ID" | ||
fi | ||
|
||
if [ "$#" -gt 2 ]; then | ||
echo "Incorrect number of parameters." | ||
usage | ||
fi | ||
|
||
if ! [ -f ./hermes ]; then | ||
echo "Error: hermes is not found within the same folder: install from https://hermes.informal.systems/installation.html" >&2 | ||
exit 1 | ||
fi | ||
|
||
CONFIG_FILE="$1" | ||
EMONEY_ID="$2" | ||
|
||
if ! [ -f "$CONFIG_FILE" ]; then | ||
echo "[CONFIG_FILE] ($1) does not exist or is not a file." | ||
usage | ||
fi | ||
|
||
if ! grep -q -s "$EMONEY_ID" "$CONFIG_FILE"; then | ||
echo "error: configuration for chain [$EMONEY_ID] does not exist in file $CONFIG_FILE." | ||
usage | ||
fi | ||
|
||
# add the key seeds to the keyring of each chain | ||
echo "Importing keys..." | ||
hermes -c "$CONFIG_FILE" keys add "$EMONEY_ID" -f "./em-key1.json" |
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,48 @@ | ||
[global] | ||
# Valid strategies: | ||
# 'packets': restricts relaying to packets only, or | ||
# 'all': relay from all types of events | ||
strategy = 'packets' | ||
log_level = 'info' | ||
|
||
[telemetry] | ||
enabled = false | ||
host = '127.0.0.1' | ||
port = 3001 | ||
|
||
[[chains]] | ||
id = 'gaia' | ||
rpc_addr = 'http://localhost:26767' | ||
grpc_addr = 'http://localhost:26769' | ||
websocket_addr = 'ws://localhost:26767/websocket' | ||
rpc_timeout = '10s' | ||
account_prefix = 'cosmos' | ||
key_name = 'wallet' | ||
store_prefix = 'ibc' | ||
max_gas = 500000 | ||
# Specify by ratio to increase the gas estimate used to compute the fee, | ||
# to account for potential estimation error. Default: 0.1, ie. 10%. | ||
gas_adjustment = 0.1 | ||
gas_price = { price = 0.001, denom = 'stake' } | ||
clock_drift = '5s' | ||
trusting_period = '14days' | ||
trust_threshold = { numerator = '1', denominator = '3' } | ||
|
||
[[chains]] | ||
id = 'localnet_reuse' | ||
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 = 'emoney' | ||
# this is on the ibc side | ||
key_name = 'key1' | ||
store_prefix = 'ibc' | ||
max_gas = 500000 | ||
# Specify by ratio to increase the gas estimate used to compute the fee, | ||
# to account for potential estimation error. Default: 0.1, ie. 10%. | ||
gas_adjustment = 0.1 | ||
gas_price = { price = 0.001, denom = 'ungm' } | ||
clock_drift = '5s' | ||
trusting_period = '14days' | ||
trust_threshold = { numerator = '1', denominator = '3' } |
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,31 @@ | ||
#!/bin/bash | ||
|
||
set +x | ||
|
||
usage() { | ||
echo "Usage: $0 <hash>" | ||
echo "Example IBC denomination hash ibc/27A6394C3F9FF9C9DCF5DFFADF9BB5FE9A37C7E92B006199894CF1824DF9AC7C" | ||
echo "enter -> $0 27A6394C3F9FF9C9DCF5DFFADF9BB5FE9A37C7E92B006199894CF1824DF9AC7C" | ||
echo " | ||
denom_trace: | ||
base_denom: ungm | ||
path: transfer/channel-0 | ||
" | ||
exit 1 | ||
} | ||
|
||
missing() { | ||
echo "Missing $1 parameter. Please check if all parameters were specified." | ||
usage | ||
} | ||
|
||
if [ -z "$1" ]; then | ||
missing "denom-hash" | ||
fi | ||
|
||
if [ "$#" -gt 1 ]; then | ||
echo "Incorrect number of parameters." | ||
usage | ||
fi | ||
|
||
gaiad q ibc-transfer denom-trace "$1" --node tcp://localhost:26757 |
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,20 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
GAIA_ID="gaia" | ||
EMONEY_CHAIN_ID="localnet_reuse" | ||
|
||
#----------------------- ibc primitives creation functions | ||
CLIENT_ID="07-tendermint-0" | ||
CONNECTION_ID="connection-0" | ||
|
||
function client_update() { | ||
local dst="$1" | ||
|
||
if hermes -c ./emoney-config.toml query client state "$dst" $CLIENT_ID ; then | ||
hermes -c ./emoney-config.toml tx raw update-client "$dst" $CLIENT_ID | ||
fi | ||
} | ||
|
||
client_update $EMONEY_CHAIN_ID |
Oops, something went wrong.