diff --git a/.github/workflows/namada.yaml b/.github/workflows/namada.yaml index 5fce603fc1..706c35ad5e 100644 --- a/.github/workflows/namada.yaml +++ b/.github/workflows/namada.yaml @@ -44,7 +44,7 @@ jobs: uses: actions/checkout@v4 with: repository: anoma/namada - ref: v0.45.1 + ref: v0.46.0 path: namada - name: Retrieve Namada repository path id: namada-repo-path @@ -87,7 +87,7 @@ jobs: env: OPERATING_SYSTEM: Linux run: | - release_url=$(curl -s "https://api.github.com/repos/anoma/namada/releases/184186214" | grep "browser_download_url" | cut -d '"' -f 4 | grep "$OPERATING_SYSTEM") + release_url=$(curl -s "https://api.github.com/repos/anoma/namada/releases/186743588" | grep "browser_download_url" | cut -d '"' -f 4 | grep "$OPERATING_SYSTEM") wget "$release_url" tar -xzvf namada*.tar.gz cp ./namada*/namadac ~/local/bin/namadac @@ -162,7 +162,7 @@ jobs: env: OPERATING_SYSTEM: Linux run: | - release_url=$(curl -s "https://api.github.com/repos/anoma/namada/releases/184186214" | grep "browser_download_url" | cut -d '"' -f 4 | grep "$OPERATING_SYSTEM") + release_url=$(curl -s "https://api.github.com/repos/anoma/namada/releases/186743588" | grep "browser_download_url" | cut -d '"' -f 4 | grep "$OPERATING_SYSTEM") wget "$release_url" tar -xzvf namada*.tar.gz cp ./namada*/namadac ~/local/bin/namadac diff --git a/Cargo.lock b/Cargo.lock index 2c1859de32..8be7e6e256 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4350,8 +4350,8 @@ checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" [[package]] name = "namada_account" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "namada_core", @@ -4362,8 +4362,8 @@ dependencies = [ [[package]] name = "namada_controller" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "namada_core", "smooth-operator", @@ -4372,8 +4372,8 @@ dependencies = [ [[package]] name = "namada_core" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "bech32 0.8.1", "borsh", @@ -4422,8 +4422,8 @@ dependencies = [ [[package]] name = "namada_ethereum_bridge" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "ethers", @@ -4450,8 +4450,8 @@ dependencies = [ [[package]] name = "namada_events" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "namada_core", @@ -4464,8 +4464,8 @@ dependencies = [ [[package]] name = "namada_gas" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "namada_core", @@ -4477,8 +4477,8 @@ dependencies = [ [[package]] name = "namada_governance" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "itertools 0.12.1", @@ -4500,8 +4500,8 @@ dependencies = [ [[package]] name = "namada_ibc" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "data-encoding", @@ -4530,8 +4530,8 @@ dependencies = [ [[package]] name = "namada_io" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "async-trait", "kdam", @@ -4543,8 +4543,8 @@ dependencies = [ [[package]] name = "namada_macros" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "data-encoding", "proc-macro2", @@ -4555,8 +4555,8 @@ dependencies = [ [[package]] name = "namada_merkle_tree" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "eyre", @@ -4570,8 +4570,8 @@ dependencies = [ [[package]] name = "namada_parameters" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "namada_core", "namada_macros", @@ -4585,8 +4585,8 @@ dependencies = [ [[package]] name = "namada_proof_of_stake" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "itertools 0.12.1", @@ -4609,16 +4609,16 @@ dependencies = [ [[package]] name = "namada_replay_protection" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "namada_core", ] [[package]] name = "namada_sdk" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "async-trait", "bimap", @@ -4687,8 +4687,8 @@ dependencies = [ [[package]] name = "namada_shielded_token" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "async-trait", "borsh", @@ -4728,8 +4728,8 @@ dependencies = [ [[package]] name = "namada_state" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "clru", @@ -4751,8 +4751,8 @@ dependencies = [ [[package]] name = "namada_storage" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "itertools 0.12.1", @@ -4770,8 +4770,8 @@ dependencies = [ [[package]] name = "namada_systems" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "namada_core", "namada_events", @@ -4780,8 +4780,8 @@ dependencies = [ [[package]] name = "namada_token" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "namada_core", @@ -4798,8 +4798,8 @@ dependencies = [ [[package]] name = "namada_trans_token" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "konst", "namada_core", @@ -4815,8 +4815,8 @@ dependencies = [ [[package]] name = "namada_tx" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "ark-bls12-381", "bitflags 2.6.0", @@ -4844,8 +4844,8 @@ dependencies = [ [[package]] name = "namada_tx_env" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "namada_core", "namada_events", @@ -4854,8 +4854,8 @@ dependencies = [ [[package]] name = "namada_vm" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "clru", @@ -4876,8 +4876,8 @@ dependencies = [ [[package]] name = "namada_vote_ext" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "borsh", "namada_core", @@ -4888,8 +4888,8 @@ dependencies = [ [[package]] name = "namada_vp" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "namada_core", "namada_events", @@ -4904,8 +4904,8 @@ dependencies = [ [[package]] name = "namada_vp_env" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "derivative", "masp_primitives", @@ -4919,8 +4919,8 @@ dependencies = [ [[package]] name = "namada_wallet" -version = "0.45.1" -source = "git+https://github.com/anoma/namada?tag=v0.45.1#207fe50a8fab63e0c84a0e6b4a4ef31de7f4ce98" +version = "0.46.0" +source = "git+https://github.com/anoma/namada?tag=v0.46.0#cc531ec513b8ade85b221dd0a6c11818927fd247" dependencies = [ "bimap", "borsh", diff --git a/Cargo.toml b/Cargo.toml index bf7a0c868a..e9187839da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,14 +41,13 @@ tendermint-light-client-verifier = { version = "0.40.0", default-features = fals tendermint-proto = { version = "0.40.0" } tendermint-rpc = { version = "0.40.0" } tendermint-testgen = { version = "0.40.0" } -# for Namada -namada-tendermint = { package = "tendermint", version = "0.38.0", default-features = false } -namada-tendermint-proto = { package = "tendermint-proto", version = "0.38.0" } -namada-tendermint-rpc = { package = "tendermint-rpc", version = "0.38.0" } - # Namada dependencies -namada_sdk = { git = "https://github.com/anoma/namada", tag = "v0.45.1" } +namada_sdk = { git = "https://github.com/anoma/namada", tag = "v0.46.0" } +# Different tendermint-rs version for Namada +namada-tendermint = { package = "tendermint", version = "0.38.0", default-features = false } +namada-tendermint-proto = { package = "tendermint-proto", version = "0.38.0" } +namada-tendermint-rpc = { package = "tendermint-rpc", version = "0.38.0" } # Other dependencies abscissa_core = "=0.6.0" diff --git a/e2e/namada-gaia-simple-transfers b/e2e/namada-gaia-simple-transfers deleted file mode 100755 index c15ff7e5f8..0000000000 --- a/e2e/namada-gaia-simple-transfers +++ /dev/null @@ -1,371 +0,0 @@ -#!/bin/bash - -# This script sets up Namada and Gaia locally -# `make build` and `make build-wasm-scripts` on Namada directory in advance -# Run with `namada-gaia-simple-transfers ${namada_dir}` - -set -e - -NAMADA_DIR=$1 -if [ -z "${NAMADA_DIR}" ] -then - echo "ERROR: Namada directory should be given" - exit 1 -fi -cd $(dirname $0) -HERMES_DIR=${PWD%/e2e*} - -# edit for your environment -NAMADAC="${NAMADA_DIR}/target/debug/namadac" -NAMADAN="${NAMADA_DIR}/target/debug/namadan" -NAMADAW="${NAMADA_DIR}/target/debug/namadaw" -DATA_DIR="${HERMES_DIR}/data" -IBC_TOKEN="transfer/channel-0/samoleans" - -SHIELDED_ALIAS_A="shielded_a" -SHIELDED_ALIAS_B="shielded_b" -PAYMENT_ALIAS_A="payment_a" -PAYMENT_ALIAS_B="payment_b" -NAMADA_LEDGER_ADDR="http://127.0.0.1:27657" - -GAIA_CHAIN_CONFIG=" -[[chains]] -id = 'gaia-0' -type = 'CosmosSdk' -rpc_addr = 'http://127.0.0.1:26657' -grpc_addr = 'http://127.0.0.1:9090' -event_source = { mode = 'push', url = 'ws://127.0.0.1:26657/websocket', batch_delay = '500ms' } -account_prefix = 'cosmos' -key_name = 'testkey' -store_prefix = 'ibc' -gas_price = { price = 0.001, denom = 'stake' } -" - -#### main #### -mkdir -p ${DATA_DIR} - -# Gaia -rm -rf ${DATA_DIR}/gaia-0 - -${HERMES_DIR}/scripts/one-chain gaiad gaia-0 ${DATA_DIR} \ - 26657 26656 6060 9090 10000 - -# Namada -${HERMES_DIR}/scripts/setup-namada-single-node ${NAMADA_DIR} -base_dir=${DATA_DIR}/namada - -cd ${HERMES_DIR} -chain_id=$(grep id config_for_namada.toml | sed -e s/\'//g | awk '{print $3}') - -# Add Gaia chain config -echo "${GAIA_CHAIN_CONFIG}" >> config_for_namada.toml - -# add Gaia key -cargo run -q --bin hermes -- --config config_for_namada.toml \ - keys add --chain gaia-0 --key-file ${DATA_DIR}/gaia-0/user_seed.json --overwrite - -# setup Namada shielded keys -${NAMADAW} --base-dir ${base_dir} gen --shielded --alias ${SHIELDED_ALIAS_A} --unsafe-dont-encrypt -${NAMADAW} --base-dir ${base_dir} gen-payment-addr --alias ${PAYMENT_ALIAS_A} --key ${SHIELDED_ALIAS_A} -payment_addr_a=$(${NAMADAW} --base-dir ${base_dir} find --alias ${PAYMENT_ALIAS_A} | awk -v paymentAlias="${PAYMENT_ALIAS_A}" '{if($1 ~ paymentAlias) {print $2}}') - -${NAMADAW} --base-dir ${base_dir} gen --shielded --alias ${SHIELDED_ALIAS_B} --unsafe-dont-encrypt -${NAMADAW} --base-dir ${base_dir} gen-payment-addr --alias ${PAYMENT_ALIAS_B} --key ${SHIELDED_ALIAS_B} -payment_addr_b=$(${NAMADAW} --base-dir ${base_dir} find --alias ${PAYMENT_ALIAS_B} | awk -v paymentAlias="${PAYMENT_ALIAS_B}" '{if($1 ~ paymentAlias) {print $2}}') - -# Initialize Relayer's balance on Namada -${NAMADAC} --base-dir ${base_dir} \ - transparent-transfer \ - --source albert \ - --target relayer \ - --token nam \ - --amount 10000 \ - --node ${NAMADA_LEDGER_ADDR} - -${NAMADAC} --base-dir ${base_dir} \ - transparent-transfer \ - --source albert \ - --target relayer \ - --token apfel \ - --amount 1000 \ - --node ${NAMADA_LEDGER_ADDR} - -# create a channel -cargo run --bin hermes -- --config config_for_namada.toml \ - create channel --a-chain ${chain_id} \ - --b-chain gaia-0 \ - --a-port transfer \ - --b-port transfer \ - --new-client-connection --yes - -echo "~~ Transfer 100 samoleans from Gaia to Namada ~~" -namada_receiver=$(${NAMADAW} --base-dir ${base_dir} find --alias relayer | awk '/"relayer":/{print $3}') -cargo run --bin hermes -- --config config_for_namada.toml \ - tx ft-transfer \ - --dst-chain ${chain_id} \ - --src-chain gaia-0 \ - --src-port transfer \ - --src-channel channel-0 \ - --amount 100 \ - --receiver ${namada_receiver} \ - --denom samoleans \ - --timeout-height-offset 1000 - -# packet-recv -cargo run --bin hermes -- --config config_for_namada.toml \ - tx packet-recv \ - --dst-chain ${chain_id} \ - --src-chain gaia-0 \ - --src-port transfer \ - --src-channel channel-0 - -# packet-ack -cargo run --bin hermes -- --config config_for_namada.toml \ - tx packet-ack \ - --dst-chain gaia-0 \ - --src-chain ${chain_id} \ - --src-port transfer \ - --src-channel channel-0 - -echo "==== Balances on Namada ====" -balance=$(${NAMADAC} --base-dir ${base_dir} balance \ - --token ${IBC_TOKEN} \ - --owner relayer \ - --node ${NAMADA_LEDGER_ADDR}) -echo "${balance}" -if [ "${balance}" != "${IBC_TOKEN}: 100" ]; then - echo "The balance on Namada is wrong" - exit 1 -fi - -echo "==== Balances on Gaia ====" -gaia_user=$(gaiad --home ${DATA_DIR}/gaia-0 \ - keys --keyring-backend="test" show user -a) -balance=$(gaiad query bank balances ${gaia_user}) -echo "${balance}" -balance=$(echo "${balance}" | grep samoleans -B 1 | tr -d '\n') -if [ "${balance}" != "- amount: \"9900\" denom: samoleans" ]; then - echo "The balance on Gaia is wrong" - exit 1 -fi - -echo "~~ Transfer back 50 samoleans from Namada to Gaia ~~" -${NAMADAC} --base-dir ${base_dir} ibc-transfer \ - --source relayer \ - --receiver ${gaia_user} \ - --token ${IBC_TOKEN} \ - --amount 50 \ - --signing-keys relayer \ - --channel-id channel-0 \ - --gas-limit 150000 \ - --node ${NAMADA_LEDGER_ADDR} - -# packet-recv -cargo run --bin hermes -- --config config_for_namada.toml \ - tx packet-recv \ - --dst-chain gaia-0 \ - --src-chain ${chain_id} \ - --src-port transfer \ - --src-channel channel-0 - -# packet-ack -cargo run --bin hermes -- --config config_for_namada.toml \ - tx packet-ack \ - --dst-chain ${chain_id} \ - --src-chain gaia-0 \ - --src-port transfer \ - --src-channel channel-0 - -echo "==== Balances on Namada ====" -balance=$(${NAMADAC} --base-dir ${base_dir} balance \ - --token ${IBC_TOKEN} \ - --owner relayer \ - --node ${NAMADA_LEDGER_ADDR}) -echo "${balance}" -if [ "${balance}" != "${IBC_TOKEN}: 50" ]; then - echo "The balance on Namada is wrong" - exit 1 -fi - -echo "==== Balances on Gaia ====" -balance=$(gaiad query bank balances ${gaia_user}) -echo "${balance}" -balance=$(echo "${balance}" | grep samoleans -B 1 | tr -d '\n') -if [ "${balance}" != "- amount: \"9950\" denom: samoleans" ]; then - echo "The balance on Gaia is wrong" - exit 1 -fi - -echo "==== Start Hermes ====" -cargo run --bin hermes -- --config config_for_namada.toml \ - start > ${HERMES_DIR}/e2e/hermes.log 2>&1 & - -echo "~~ Transfer 200 apfel from Namada to Gaia ~~" -${NAMADAC} --base-dir ${base_dir} ibc-transfer \ - --source relayer \ - --receiver ${gaia_user} \ - --token apfel \ - --amount 200 \ - --signing-keys relayer \ - --channel-id channel-0 \ - --gas-limit 150000 \ - --node ${NAMADA_LEDGER_ADDR} - -# wait for relaying -sleep 15 - -echo "==== Balances on Namada ====" -balance=$(${NAMADAC} --base-dir ${base_dir} balance \ - --token apfel \ - --owner relayer \ - --node ${NAMADA_LEDGER_ADDR}) -echo "${balance}" -if [ "${balance}" != "apfel: 800" ]; then - echo "The balance on Namada is wrong" - exit 1 -fi - -echo "==== Balances on Gaia ====" -balance=$(gaiad query bank balances ${gaia_user}) -echo "${balance}" -balance=$(echo "${balance}" | grep ibc -B 1 | tr -d '\n') -if [[ "${balance}" != *"- amount: \"200000000\" denom: ibc/"* ]]; then - echo "The balance on Gaia is wrong" - exit 1 -fi - -echo "~~ Generate the proof from Namada for the following transfer ~~" -resp=$(${NAMADAC} --base-dir ${base_dir} ibc-gen-shielding \ - --output-folder-path ${base_dir} \ - --target ${payment_addr_a} \ - --token samoleans \ - --amount 10 \ - --port-id transfer \ - --channel-id channel-0 \ - --node ${NAMADA_LEDGER_ADDR}) -memo_path=$(echo $resp | awk '{print $8}') - -echo "~~ Shielding transfer 10 samoleans from Gaia to Namada ~~" -cargo run --bin hermes -- --config config_for_namada.toml \ - tx ft-transfer \ - --dst-chain ${chain_id} \ - --src-chain gaia-0 \ - --src-port transfer \ - --src-channel channel-0 \ - --amount 10 \ - --receiver ${payment_addr_a} \ - --denom samoleans \ - --timeout-height-offset 1000 \ - --memo $(cat ${memo_path}) - -# wait for relaying -sleep 40 - -echo "==== Balance of shielded_a on Namada ====" -${NAMADAC} --base-dir ${base_dir} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS_A} \ - --node ${NAMADA_LEDGER_ADDR} -balance=$(${NAMADAC} --base-dir ${base_dir} balance \ - --token ${IBC_TOKEN} \ - --owner ${SHIELDED_ALIAS_A} \ - --node ${NAMADA_LEDGER_ADDR}) -echo "${balance}" -if [[ "${balance}" != *"${IBC_TOKEN}: 10" ]]; then - echo "The balance of shielded_a on Namada is wrong" - exit 1 -fi - -echo "==== Balances on Gaia ====" -balance=$(gaiad query bank balances ${gaia_user}) -echo "${balance}" -balance=$(echo "${balance}" | grep samoleans -B 1 | tr -d '\n') -if [ "${balance}" != "- amount: \"9940\" denom: samoleans" ]; then - echo "The balance on Gaia is wrong" - exit 1 -fi - -echo "~~ Shielded transfer 5 apfel from shielded_a to shielded_b ~~" -${NAMADAC} --base-dir ${base_dir} transfer \ - --source ${SHIELDED_ALIAS_A} \ - --target ${payment_addr_b} \ - --token ${IBC_TOKEN} \ - --amount 5 \ - --signing-keys relayer \ - --node ${NAMADA_LEDGER_ADDR} - -echo "==== Balance of shielded_a on Namada ====" -${NAMADAC} --base-dir ${base_dir} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS_A} ${SHIELDED_ALIAS_B} \ - --node ${NAMADA_LEDGER_ADDR} -balance=$(${NAMADAC} --base-dir ${base_dir} balance \ - --token ${IBC_TOKEN} \ - --owner ${SHIELDED_ALIAS_A} \ - --node ${NAMADA_LEDGER_ADDR}) -echo "${balance}" -if [[ "${balance}" != *"${IBC_TOKEN}: 5" ]]; then - echo "The balance of shielded_a on Namada is wrong" - exit 1 -fi - -echo "==== Balance of shielded_b on Namada ====" -balance=$(${NAMADAC} --base-dir ${base_dir} balance \ - --token ${IBC_TOKEN} \ - --owner ${SHIELDED_ALIAS_B} \ - --node ${NAMADA_LEDGER_ADDR}) -echo "${balance}" -if [[ "${balance}" != *"${IBC_TOKEN}: 5"* ]]; then - echo "The balance of shielded_b on Namada is wrong" - exit 1 -fi - -echo "~~ Transfer back 5 samoleans from Namada to Gaia ~~" -${NAMADAC} --base-dir ${base_dir} ibc-transfer \ - --source ${SHIELDED_ALIAS_B} \ - --receiver ${gaia_user} \ - --token ${IBC_TOKEN} \ - --amount 5 \ - --signing-keys relayer \ - --channel-id channel-0 \ - --gas-limit 150000 \ - --node ${NAMADA_LEDGER_ADDR} - -# wait for relaying -sleep 40 - -echo "==== Balances of shielded_a on Namada ====" -${NAMADAC} --base-dir ${base_dir} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS_A} ${SHIELDED_ALIAS_B} \ - --node ${NAMADA_LEDGER_ADDR} -balance=$(${NAMADAC} --base-dir ${base_dir} balance \ - --token ${IBC_TOKEN} \ - --owner ${SHIELDED_ALIAS_A} \ - --node ${NAMADA_LEDGER_ADDR}) -echo "${balance}" -if [[ "${balance}" != *"${IBC_TOKEN}: 5"* ]]; then - echo "The balance of shielded_a on Namada is wrong" - exit 1 -fi - -echo "==== Balances of shielded_b on Namada ====" -balance=$(${NAMADAC} --base-dir ${base_dir} balance \ - --token ${IBC_TOKEN} \ - --owner ${SHIELDED_ALIAS_B} \ - --node ${NAMADA_LEDGER_ADDR}) -echo "${balance}" -if [[ "${balance}" != *"${IBC_TOKEN}: 0"* ]]; then - echo "The balance of shielded_b on Namada is wrong" - exit 1 -fi - -echo "==== Balances on Gaia ====" -balance=$(gaiad query bank balances ${gaia_user}) -echo "${balance}" -balance=$(echo "${balance}" | grep samoleans -B 1 | tr -d '\n') -if [ "${balance}" != "- amount: \"9945\" denom: samoleans" ]; then - echo "The balance on Gaia is wrong" - exit 1 -fi - -killall hermes -killall gaiad -killall namadan diff --git a/e2e/namada-simple-transfers b/e2e/namada-simple-transfers deleted file mode 100755 index 444273a720..0000000000 --- a/e2e/namada-simple-transfers +++ /dev/null @@ -1,469 +0,0 @@ -#!/bin/bash - -# This script executes simple transfers between Namada instances locally -# `make build` and `make build-wasm-scripts` on Namada directory in advance -# Run with `namada-simple-transfers ${namada_dir}` - -set -e - -NAMADA_DIR=$1 -if [ -z "${NAMADA_DIR}" ] -then - echo "ERROR: Namada directory should be given" - exit 1 -fi -cd $(dirname $0) -HERMES_DIR=${PWD%/e2e*} - -NAMADAC="${NAMADA_DIR}/target/debug/namadac" -NAMADAW="${NAMADA_DIR}/target/debug/namadaw" -DATA_DIR="${HERMES_DIR}/data" -IBC_TOKEN="transfer/channel-0/apfel" - -SHIELDED_ALIAS_A="shielded_a" -SHIELDED_ALIAS_B="shielded_b" -SHIELDED_ALIAS_B_2="shielded_b_2" -PAYMENT_ALIAS_A="payment_a" -PAYMENT_ALIAS_B="payment_b" -PAYMENT_ALIAS_B_2="payment_b_2" -LEDGER_ADDR_A="http://127.0.0.1:27657" -LEDGER_ADDR_B="http://127.0.0.1:28657" -INITIAL_BALANCE=5000 - -function init_relayer_balance() { - local suffix=$1 - local ledger_addr=$2 - - local base_dir=${DATA_DIR}/namada-${suffix} - - ${NAMADAC} --base-dir ${base_dir} \ - transparent-transfer \ - --source albert \ - --target relayer \ - --token nam \ - --amount ${INITIAL_BALANCE} \ - --node ${ledger_addr} -} - -function wait_for_relaying() { - local chain_id=$1 - - for i in {1..20} - do - result=$(cargo run --bin hermes -- --config config_for_namada.toml \ - query packet pending \ - --chain ${chain_id} \ - --channel channel-0 \ - --port transfer) - - echo ${result} - if [[ "${result}" =~ "=" ]]; - then - echo "Waiting for packet relaying..." - sleep 5 - else - echo "All packets have been relayed!" - break - fi - done -} - -# ==== main ==== - -# Run 2 Namada chains -${HERMES_DIR}/scripts/setup-namada ${NAMADA_DIR} -sleep 5 - -cd ${HERMES_DIR} -ids=$(grep "id" config_for_namada.toml | awk -F"'" '/^id/ {print $2}') -chain_a=$(echo ${ids} | awk '{print $1}') -chain_b=$(echo ${ids} | awk '{print $2}') - -# Initialize the balances -init_relayer_balance "a" ${LEDGER_ADDR_A} -sleep 5 -init_relayer_balance "b" ${LEDGER_ADDR_B} - -# Create a channel -cargo run --bin hermes -- --config config_for_namada.toml \ - create channel \ - --a-chain ${chain_a} \ - --b-chain ${chain_b} \ - --a-port transfer \ - --b-port transfer \ - --new-client-connection --yes - -base_dir_a=${DATA_DIR}/namada-a -base_dir_b=${DATA_DIR}/namada-b - -# Setup shielded keys -${NAMADAW} --base-dir ${base_dir_a} gen --shielded --alias ${SHIELDED_ALIAS_A} --unsafe-dont-encrypt -${NAMADAW} --base-dir ${base_dir_a} gen-payment-addr --alias ${PAYMENT_ALIAS_A} --key ${SHIELDED_ALIAS_A} -payment_addr_a=$(${NAMADAW} --base-dir ${base_dir_a} find --alias ${PAYMENT_ALIAS_A} | awk -v paymentAlias="${PAYMENT_ALIAS_A}" '{if($1 ~ paymentAlias) {print $2}}') - -${NAMADAW} --base-dir ${base_dir_b} gen --shielded --alias ${SHIELDED_ALIAS_B} --unsafe-dont-encrypt -${NAMADAW} --base-dir ${base_dir_b} gen-payment-addr --alias ${PAYMENT_ALIAS_B} --key ${SHIELDED_ALIAS_B} -payment_addr_b=$(${NAMADAW} --base-dir ${base_dir_b} find --alias ${PAYMENT_ALIAS_B} | awk -v paymentAlias="${PAYMENT_ALIAS_B}" '{if($1 ~ paymentAlias) {print $2}}') - -${NAMADAW} --base-dir ${base_dir_b} gen --shielded --alias ${SHIELDED_ALIAS_B_2} --unsafe-dont-encrypt -${NAMADAW} --base-dir ${base_dir_b} gen-payment-addr --alias ${PAYMENT_ALIAS_B_2} --key ${SHIELDED_ALIAS_B_2} -payment_addr_b_2=$(${NAMADAW} --base-dir ${base_dir_b} find --alias ${PAYMENT_ALIAS_B_2} | awk -v paymentAlias="${PAYMENT_ALIAS_B_2}" '{if($1 ~ paymentAlias) {print $2}}') - -# Faucet apfel on chain A and chain B -${NAMADAC} --base-dir ${base_dir_a} transparent-transfer \ - --source albert \ - --target relayer \ - --token apfel \ - --amount 1000 \ - --signing-keys albert-key \ - --node ${LEDGER_ADDR_A} - -${NAMADAC} --base-dir ${base_dir_b} transparent-transfer \ - --source albert \ - --target relayer \ - --token apfel \ - --amount 1000 \ - --signing-keys albert-key \ - --node ${LEDGER_ADDR_B} - -# Faucet apfel for shielded_a -${NAMADAC} --base-dir ${base_dir_a} shield \ - --source albert \ - --target ${payment_addr_a} \ - --token apfel \ - --amount 1000 \ - --signing-keys albert-key \ - --node ${LEDGER_ADDR_A} -${NAMADAC} --base-dir ${base_dir_a} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS_A} \ - --node ${LEDGER_ADDR_A} - -# Get the receiver addresses -receiver_a=$(${NAMADAW} --base-dir ${base_dir_a} find --alias relayer | awk '/"relayer":/{print $3}') -receiver_b=$(${NAMADAW} --base-dir ${base_dir_b} find --alias relayer | awk '/"relayer":/{print $3}') - -echo "~~ Transfer 100 apfel from chain A to chain B ~~" -${NAMADAC} --base-dir ${base_dir_a} ibc-transfer \ - --source relayer \ - --receiver ${receiver_b} \ - --token apfel \ - --amount 100 \ - --signing-keys relayer \ - --channel-id channel-0 \ - --gas-limit 200000 \ - --node ${LEDGER_ADDR_A} - -# packet-recv -cargo run --bin hermes -- --config config_for_namada.toml \ - tx packet-recv \ - --dst-chain ${chain_b} \ - --src-chain ${chain_a} \ - --src-port transfer \ - --src-channel channel-0 - -# packet-ack -cargo run --bin hermes -- --config config_for_namada.toml \ - tx packet-ack \ - --dst-chain ${chain_a} \ - --src-chain ${chain_b} \ - --src-port transfer \ - --src-channel channel-0 - -echo "==== Balances on chain A ====" -balance=$(${NAMADAC} --base-dir ${base_dir_a} balance \ - --token apfel \ - --owner relayer \ - --node ${LEDGER_ADDR_A}) -echo ${balance} -if [ "${balance}" != "apfel: 900" ]; then - echo "The balance on chain A is wrong" - exit 1 -fi - -echo "==== Balances on chain B ====" -balance=$(${NAMADAC} --base-dir ${base_dir_b} balance \ - --token ${IBC_TOKEN} \ - --owner relayer \ - --node ${LEDGER_ADDR_B}) -echo ${balance} -if [ "${balance}" != "${IBC_TOKEN}: 100000000" ]; then - echo "The balance on chain B is wrong" - exit 1 -fi - -echo "~~ Transfer back 50 apfel from chain B to chain A ~~" -${NAMADAC} --base-dir ${base_dir_b} ibc-transfer \ - --source relayer \ - --receiver ${receiver_a} \ - --token ${IBC_TOKEN} \ - --amount 50000000 \ - --signing-keys relayer \ - --channel-id channel-0 \ - --gas-limit 200000 \ - --node ${LEDGER_ADDR_B} - -# packet-recv -cargo run --bin hermes -- --config config_for_namada.toml \ - tx packet-recv \ - --dst-chain ${chain_a} \ - --src-chain ${chain_b} \ - --src-port transfer \ - --src-channel channel-0 - -# packet-ack -cargo run --bin hermes -- --config config_for_namada.toml \ - tx packet-ack \ - --dst-chain ${chain_b} \ - --src-chain ${chain_a} \ - --src-port transfer \ - --src-channel channel-0 - -echo "==== Balances on chain A ====" -balance=$(${NAMADAC} --base-dir ${base_dir_a} balance \ - --token apfel \ - --owner relayer \ - --node ${LEDGER_ADDR_A}) -echo ${balance} -if [ "${balance}" != "apfel: 950" ]; then - echo "The balance on chain A is wrong" - exit 1 -fi - -echo "==== Balances on chain B ====" -balance=$(${NAMADAC} --base-dir ${base_dir_b} balance \ - --token ${IBC_TOKEN} \ - --owner relayer \ - --node ${LEDGER_ADDR_B}) -echo ${balance} -if [ "${balance}" != "${IBC_TOKEN}: 50000000" ]; then - echo "The balance on chain B is wrong" - exit 1 -fi - -echo "==== Start Hermes ====" -cargo run --bin hermes -- --config config_for_namada.toml \ - start > ${HERMES_DIR}/e2e/hermes.log 2>&1 & - -echo "~~ Transfer 200 apfel from chain A to chain B ~~" -${NAMADAC} --base-dir ${base_dir_a} ibc-transfer \ - --source relayer \ - --receiver ${receiver_b} \ - --token apfel \ - --amount 200 \ - --signing-keys relayer \ - --channel-id channel-0 \ - --gas-limit 200000 \ - --node ${LEDGER_ADDR_A} - -echo "~~ Transfer 300 apfel from chain B to chain A ~~" -${NAMADAC} --base-dir ${base_dir_b} ibc-transfer \ - --source relayer \ - --receiver ${receiver_a} \ - --token apfel \ - --amount 300 \ - --signing-keys relayer \ - --channel-id channel-0 \ - --gas-limit 200000 \ - --node ${LEDGER_ADDR_B} - -wait_for_relaying ${chain_a} - -echo "==== Balances on chain A ====" -balance=$(${NAMADAC} --base-dir ${base_dir_a} balance \ - --token apfel \ - --owner relayer \ - --node ${LEDGER_ADDR_A}) -echo ${balance} -if [ "${balance}" != "apfel: 750" ]; then - echo "The balance on chain A is wrong" - exit 1 -fi - -balance=$(${NAMADAC} --base-dir ${base_dir_a} balance \ - --token ${IBC_TOKEN} \ - --owner relayer \ - --node ${LEDGER_ADDR_A}) -echo ${balance} -if [ "${balance}" != "${IBC_TOKEN}: 300000000" ]; then - echo "The balance on chain A is wrong" - exit 1 -fi - -echo "==== Balances on chain B ====" -balance=$(${NAMADAC} --base-dir ${base_dir_b} balance \ - --token apfel \ - --owner relayer \ - --node ${LEDGER_ADDR_B}) -echo ${balance} -if [ "${balance}" != "apfel: 700" ]; then - echo "The balance on chain B is wrong" - exit 1 -fi - -balance=$(${NAMADAC} --base-dir ${base_dir_b} balance \ - --token ${IBC_TOKEN} \ - --owner relayer \ - --node ${LEDGER_ADDR_B}) -echo ${balance} -if [ "${balance}" != "${IBC_TOKEN}: 250000000" ]; then - echo "The balance on chain B is wrong" - exit 1 -fi - -echo "==== Shielded transfer tests ====" - -echo "~~ Generate the proof from chain_b for the following transfer ~~" -apfel_addr=$(${NAMADAW} --base-dir ${base_dir_a} find --alias apfel | awk '/"apfel":/{print $3}') -resp=$(${NAMADAC} --base-dir ${base_dir_b} ibc-gen-shielding \ - --output-folder-path ${base_dir_b} \ - --target ${payment_addr_b} \ - --token ${apfel_addr} \ - --amount 100000000 \ - --port-id transfer \ - --channel-id channel-0 \ - --node ${LEDGER_ADDR_B}) -memo_path=$(echo $resp | awk '{print $8}') - -echo "~~ Shielded transfer 100 apfel from chain A to chain B ~~" -${NAMADAC} --base-dir ${base_dir_a} ibc-transfer \ - --source ${SHIELDED_ALIAS_A} \ - --receiver ${payment_addr_b} \ - --token apfel \ - --amount 100 \ - --channel-id channel-0 \ - --ibc-shielding-data ${memo_path} \ - --gas-payer relayer \ - --gas-limit 200000 \ - --node ${LEDGER_ADDR_A} - -wait_for_relaying ${chain_a} - -echo "==== Balance of shielded_a on chain A ====" -${NAMADAC} --base-dir ${base_dir_a} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS_A} \ - --node ${LEDGER_ADDR_A} -balance=$(${NAMADAC} --base-dir ${base_dir_a} balance \ - --token apfel \ - --owner ${SHIELDED_ALIAS_A} \ - --node ${LEDGER_ADDR_A}) -echo "${balance}" -if [[ "${balance}" != *"apfel: 900" ]]; then - echo "The balance of shielded_a on chain A is wrong" - exit 1 -fi - -echo "==== Balance of shielded_b on chain B ====" -${NAMADAC} --base-dir ${base_dir_b} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS_B} \ - --node ${LEDGER_ADDR_B} -balance=$(${NAMADAC} --base-dir ${base_dir_b} balance \ - --token ${IBC_TOKEN} \ - --owner ${SHIELDED_ALIAS_B} \ - --node ${LEDGER_ADDR_B}) -echo "${balance}" -if [[ "${balance}" != *"${IBC_TOKEN}: 100000000" ]]; then - echo "The balance of shielded_b on chain B is wrong" - exit 1 -fi - -echo "~~ Shielded transfer 50 apfel from shielded_b to shielded_b_2 ~~" -${NAMADAC} --base-dir ${base_dir_b} transfer \ - --source ${SHIELDED_ALIAS_B} \ - --target ${payment_addr_b_2} \ - --token ${IBC_TOKEN} \ - --amount 50000000 \ - --signing-keys relayer \ - --node ${LEDGER_ADDR_B} - -echo "==== Balance of shielded_b on chain B ====" -${NAMADAC} --base-dir ${base_dir_b} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS_B} \ - --node ${LEDGER_ADDR_B} -balance=$(${NAMADAC} --base-dir ${base_dir_b} balance \ - --token ${IBC_TOKEN} \ - --owner ${SHIELDED_ALIAS_B} \ - --node ${LEDGER_ADDR_B}) -echo "${balance}" -if [[ "${balance}" != *"${IBC_TOKEN}: 50000000" ]]; then - echo "The balance of shielded_b on chain B is wrong" - exit 1 -fi - -echo "==== Balance of shielded_b_2 on chain B ====" -${NAMADAC} --base-dir ${base_dir_b} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS_B_2} \ - --node ${LEDGER_ADDR_B} -balance=$(${NAMADAC} --base-dir ${base_dir_b} balance \ - --token ${IBC_TOKEN} \ - --owner ${SHIELDED_ALIAS_B_2} \ - --node ${LEDGER_ADDR_B}) -echo "${balance}" -if [[ "${balance}" != *"${IBC_TOKEN}: 50000000" ]]; then - echo "The balance of shielded_b_2 on chain B is wrong" - exit 1 -fi - -echo "~~ Generate the proof from chain A for the following transfer ~~" -ibc_token="transfer/channel-0/${apfel_addr}" -resp=$(${NAMADAC} --base-dir ${base_dir_a} ibc-gen-shielding \ - --output-folder-path ${base_dir_a} \ - --target ${payment_addr_a} \ - --token ${ibc_token} \ - --amount 50 \ - --port-id transfer \ - --channel-id channel-0 \ - --node ${LEDGER_ADDR_A}) -memo_path=$(echo $resp | awk '{print $8}') - -echo "~~ Transfer back 50 apfel from shielded_b_2 on chain B to chain A ~~" -${NAMADAC} --base-dir ${base_dir_b} ibc-transfer \ - --source ${SHIELDED_ALIAS_B_2} \ - --receiver ${payment_addr_a} \ - --token ${IBC_TOKEN} \ - --amount 50000000 \ - --signing-keys relayer \ - --channel-id channel-0 \ - --ibc-shielding-data ${memo_path} \ - --gas-limit 200000 \ - --node ${LEDGER_ADDR_B} - -wait_for_relaying ${chain_a} - -echo "==== Balances of shielded_a on chain A ====" -${NAMADAC} --base-dir ${base_dir_a} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS_A} \ - --node ${LEDGER_ADDR_A} -balance=$(${NAMADAC} --base-dir ${base_dir_a} balance \ - --token apfel \ - --owner ${SHIELDED_ALIAS_A} \ - --node ${LEDGER_ADDR_A}) -echo "${balance}" -if [[ "${balance}" != *"apfel: 950" ]]; then - echo "The balance of shielded_a on chain A is wrong" - exit 1 -fi - -echo "==== Balances of shielded_b on chain B ====" -balance=$(${NAMADAC} --base-dir ${base_dir_b} balance \ - --token ${IBC_TOKEN} \ - --owner ${SHIELDED_ALIAS_B} \ - --node ${LEDGER_ADDR_B}) -echo "${balance}" -if [[ "${balance}" != *"${IBC_TOKEN}: 50000000" ]]; then - echo "The balance of shielded_b on chain B is wrong" - exit 1 -fi - -echo "==== Balance of shielded_b_2 on chain B ====" -balance=$(${NAMADAC} --base-dir ${base_dir_b} balance \ - --token ${IBC_TOKEN} \ - --owner ${SHIELDED_ALIAS_B_2} \ - --node ${LEDGER_ADDR_B}) -echo "${balance}" -if [[ "${balance}" != *"${IBC_TOKEN}: 0" ]]; then - echo "The balance of shielded_b_2 on chain B is wrong" - exit 1 -fi - -killall hermes -killall namadan diff --git a/e2e/namada-stargaze-transfer b/e2e/namada-stargaze-transfer deleted file mode 100755 index 203c76db29..0000000000 --- a/e2e/namada-stargaze-transfer +++ /dev/null @@ -1,268 +0,0 @@ -#!/bin/bash - -# This script tests NFT transfers between a local Namada and Stargaze testnet -# Need to create an account and an NFT on Stargaze testnet. -# `make build` and `make build-wasm-scripts` on Namada directory, -# set up a local Namada with `scripts/setup-namada-single-node`, -# edit `config_namada_stargaze.toml` -# Then Run with `namada-stargaze-transfers ${namada_dir}` -# -# Set a key as "relayer" -# starsd keys add relayer --recover -# -# Add Stargaze key as a relayer -#cargo run -q --bin hermes -- --config config_namada_stargaze.toml \ -# keys add --chain ${STARGAZE_CHAIN_ID} --mnemonic-file /dev/stdin - -set -ex - - -NAMADA_DIR=$1 -if [ -z "${NAMADA_DIR}" ] -then - echo "ERROR: Namada directory should be given" - exit 1 -fi - -cd $(dirname $0) -HERMES_DIR=${PWD%/e2e*} - -# edit for your environment -NAMADA_CHAIN_ID="namada-test.8adce119ebc4d7efe9" -NAMADAC="${NAMADA_DIR}/target/debug/namadac" -NAMADAN="${NAMADA_DIR}/target/debug/namadan" -NAMADAW="${NAMADA_DIR}/target/debug/namadaw" -DATA_DIR="${HERMES_DIR}/data" -NAMADA_LEDGER_ADDR="http://127.0.0.1:27657" - -TOKEN_ID="5" - -CONFIG_FILE="${HERMES_DIR}/config_namada_stargaze.toml" - -STARGAZE_CHAIN_ID="elgafar-1" -ICS721_CONTRACT="stars1ve46fjrhcrum94c7d8yc2wsdz8cpuw73503e8qn9r44spr6dw0lsvmvtqh" -SG721_CONTRACT="stars1exh83tyv29g374yhs6cktwsd2sen50gjpuq2jhfn6p7e6nqsejfq2p0v7z" -STARGAZE_NODE="https://rpc.elgafar-1.stargaze-apis.com:443" -STARGAZE_PORT="wasm.${ICS721_CONTRACT}" - -TX_ARGS="--from relayer --node ${STARGAZE_NODE} --chain-id ${STARGAZE_CHAIN_ID} --gas auto --gas-prices 0.01ustars --gas-adjustment 1.1 -y" - -NAMADA_BASE="${DATA_DIR}/namada" -SHIELDED_ALIAS="shielded-1" -PAYMENT_ALIAS="payment-1" - -SHIELDED_ALIAS_2="shielded-2" -PAYMENT_ALIAS_2="payment-2" - -#### main #### -echo "==== Check the minted NFT on Stargaze ====" -starsd query wasm contract-state smart ${SG721_CONTRACT} \ - "{\"owner_of\": {\"token_id\": \"${TOKEN_ID}\"}}" \ - --node ${STARGAZE_NODE} - -# Create a channel -resp=$(cargo run --bin hermes -- --config ${CONFIG_FILE} \ - create channel \ - --a-chain ${NAMADA_CHAIN_ID} \ - --b-chain ${STARGAZE_CHAIN_ID} \ - --a-port nft-transfer \ - --b-port ${STARGAZE_PORT} \ - --channel-version ics721-1 \ - --new-client-connection --yes) - -namada_channel=$(echo "$resp" | grep "a_side" -A 19 | grep "channel-" | sed 's/"//g' | awk -F',' '{print $1}' | sed 's/ //g') -stargaze_channel=$(echo "$resp" | grep "b_side" -A 19 | grep "channel-" | sed 's/"//g' | awk -F',' '{print $1}' | sed 's/ //g') - -echo "==== Send the NFT from Stargaze to Namada ====" -current_height=$(starsd status --node ${STARGAZE_NODE} | jq .SyncInfo.latest_block_height | sed 's/"//g') -timeout_height=$((${current_height} + 100)) -namada_receiver=$(${NAMADAW} --base-dir ${NAMADA_BASE} find --alias relayer | awk '/"relayer":/{print $3}') -msg="{\"receiver\": \"${namada_receiver}\", \"channel_id\": \"${stargaze_channel}\", \"timeout\": {\"block\": { \"revision\": 0, \"height\": ${timeout_height}}}}" -encoded_msg=$(echo ${msg} | base64) -starsd tx wasm execute ${SG721_CONTRACT} \ - "{\"send_nft\": {\"contract\":\"${ICS721_CONTRACT}\", \"token_id\": \"${TOKEN_ID}\", \"msg\": \"${encoded_msg}\"}}" \ - ${TX_ARGS} - -sleep 5 - -echo "==== Packet relaying ====" -cargo run --bin hermes -- --config ${CONFIG_FILE} clear packets \ - --chain ${STARGAZE_CHAIN_ID} \ - --port wasm.${ICS721_CONTRACT} \ - --channel ${stargaze_channel} - -echo "==== Check the escrowed NFT on Stargaze ====" -starsd query wasm contract-state smart ${SG721_CONTRACT} \ - "{\"owner_of\": {\"token_id\": \"${TOKEN_ID}\"}}" \ - --node ${STARGAZE_NODE} - -echo "==== Check the NFT on Namada ====" -token="nft-transfer/${namada_channel}/${SG721_CONTRACT}/${TOKEN_ID}" -${NAMADAC} --base-dir ${NAMADA_BASE} balance \ - --token ${token} \ - --owner relayer \ - --node ${NAMADA_LEDGER_ADDR} - -echo "==== Send back the NFT from Namada to Stargaze ====" -stargaze_receiver=$(starsd keys show relayer -a) -${NAMADAC} --base-dir ${NAMADA_BASE} ibc-transfer \ - --source relayer \ - --receiver ${stargaze_receiver} \ - --token ${token}\ - --amount 1 \ - --signing-keys relayer \ - --channel-id ${namada_channel} \ - --port-id nft-transfer \ - --gas-limit 150000 \ - --node ${NAMADA_LEDGER_ADDR} - -sleep 5 - -echo "==== Packet relaying ====" -cargo run --bin hermes -- --config ${CONFIG_FILE} clear packets \ - --chain ${STARGAZE_CHAIN_ID} \ - --port wasm.${ICS721_CONTRACT} \ - --channel ${stargaze_channel} - -echo "==== Check the NFT on Stargaze ====" -starsd query wasm contract-state smart ${SG721_CONTRACT} \ - "{\"owner_of\": {\"token_id\": \"${TOKEN_ID}\"}}" \ - --node ${STARGAZE_NODE} - -echo "==== Check the NFT on Namada ====" -token="nft-transfer/${namada_channel}/${SG721_CONTRACT}/${TOKEN_ID}" -${NAMADAC} --base-dir ${NAMADA_BASE} balance \ - --token ${token} \ - --owner relayer \ - --node ${NAMADA_LEDGER_ADDR} - - -echo "======== Try shielded transfer ========" - -# setup shielded keys for Namada -${NAMADAW} --base-dir ${NAMADA_BASE} gen --shielded --alias ${SHIELDED_ALIAS} \ - --unsafe-dont-encrypt --alias-force -${NAMADAW} --base-dir ${NAMADA_BASE} gen-payment-addr --alias ${PAYMENT_ALIAS} \ - --key ${SHIELDED_ALIAS} -payment_addr=$(${NAMADAW} --base-dir ${NAMADA_BASE} find --alias ${PAYMENT_ALIAS} \ - | awk -v paymentAlias="${PAYMENT_ALIAS}" '{if($1 ~ paymentAlias) {print $2}}') - -# another one -${NAMADAW} --base-dir ${NAMADA_BASE} gen --shielded --alias ${SHIELDED_ALIAS_2} \ - --unsafe-dont-encrypt --alias-force -${NAMADAW} --base-dir ${NAMADA_BASE} gen-payment-addr --alias ${PAYMENT_ALIAS_2} \ - --key ${SHIELDED_ALIAS_2} -payment_addr_2=$(${NAMADAW} --base-dir ${NAMADA_BASE} find --alias ${PAYMENT_ALIAS_2} \ - | awk -v paymentAlias="${PAYMENT_ALIAS_2}" '{if($1 ~ paymentAlias) {print $2}}') - -echo "~~ Generate the proof from Namada for the following transfer ~~" -token="${SG721_CONTRACT}/${TOKEN_ID}" -resp=$(${NAMADAC} --base-dir ${NAMADA_BASE} ibc-gen-shielding \ - --output-folder-path ${NAMADA_BASE} \ - --target ${payment_addr} \ - --token "${token}" \ - --amount 1 \ - --port-id nft-transfer \ - --channel-id ${namada_channel} \ - --node ${NAMADA_LEDGER_ADDR}) -memo_path=$(echo ${resp} | awk '{print $8}') -memo=$(cat ${memo_path}) - -echo "==== Shielding transfer from Stargaze to Namada ====" -current_height=$(starsd status --node ${STARGAZE_NODE} | jq .SyncInfo.latest_block_height | sed 's/"//g') -timeout_height=$((${current_height} + 100)) -msg="{\"receiver\": \"${payment_addr}\", \"channel_id\": \"${stargaze_channel}\", \"timeout\": {\"block\": { \"revision\": 0, \"height\": ${timeout_height}}}, \"memo\": \"${memo}\"}" -encoded_msg=$(echo ${msg} | base64) -starsd tx wasm execute ${SG721_CONTRACT} \ - "{\"send_nft\": {\"contract\":\"${ICS721_CONTRACT}\", \"token_id\": \"${TOKEN_ID}\", \"msg\": \"${encoded_msg}\"}}" \ - ${TX_ARGS} - -sleep 5 - -echo "==== Packet relaying ====" -cargo run --bin hermes -- --config ${CONFIG_FILE} clear packets \ - --chain ${STARGAZE_CHAIN_ID} \ - --port wasm.${ICS721_CONTRACT} \ - --channel ${stargaze_channel} - -echo "==== Check the escrowed NFT on Stargaze ====" -starsd query wasm contract-state smart ${SG721_CONTRACT} \ - "{\"owner_of\": {\"token_id\": \"${TOKEN_ID}\"}}" \ - --node ${STARGAZE_NODE} - -echo "==== Check the NFT on Namada ====" -${NAMADAC} --base-dir ${NAMADA_BASE} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS} \ - --node ${NAMADA_LEDGER_ADDR} -token="nft-transfer/${namada_channel}/${SG721_CONTRACT}/${TOKEN_ID}" -${NAMADAC} --base-dir ${NAMADA_BASE} balance \ - --token ${token} \ - --owner ${SHIELDED_ALIAS} \ - --node ${NAMADA_LEDGER_ADDR} - -echo "==== Shielded transfer in Namada ====" -${NAMADAC} --base-dir ${NAMADA_BASE} transfer \ - --source ${SHIELDED_ALIAS} \ - --target ${PAYMENT_ALIAS_2} \ - --token ${token}\ - --amount 1 \ - --signing-keys relayer \ - --node ${NAMADA_LEDGER_ADDR} - -echo "==== Check the shielded NFT on Namada ====" -echo "== shielded-1 balance ==" -${NAMADAC} --base-dir ${NAMADA_BASE} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS} ${SHIELDED_ALIAS_2}\ - --node ${NAMADA_LEDGER_ADDR} -${NAMADAC} --base-dir ${NAMADA_BASE} balance \ - --token ${token} \ - --owner ${SHIELDED_ALIAS} \ - --node ${NAMADA_LEDGER_ADDR} - -echo "== shielded-2 balance ==" -${NAMADAC} --base-dir ${NAMADA_BASE} balance \ - --token ${token} \ - --owner ${SHIELDED_ALIAS_2} \ - --node ${NAMADA_LEDGER_ADDR} - -echo "==== Unshielding transfer from Namada to Stargaze ====" -${NAMADAC} --base-dir ${NAMADA_BASE} ibc-transfer \ - --source ${SHIELDED_ALIAS_2} \ - --receiver ${stargaze_receiver} \ - --token ${token}\ - --amount 1 \ - --signing-keys relayer \ - --channel-id ${namada_channel} \ - --port-id nft-transfer \ - --gas-limit 150000 \ - --node ${NAMADA_LEDGER_ADDR} - -sleep 5 - -echo "==== Packet relaying ====" -cargo run --bin hermes -- --config ${CONFIG_FILE} clear packets \ - --chain ${STARGAZE_CHAIN_ID} \ - --port wasm.${ICS721_CONTRACT} \ - --channel ${stargaze_channel} - -echo "==== Check the shielded NFT on Stargaze ====" -starsd query wasm contract-state smart ${SG721_CONTRACT} \ - "{\"owner_of\": {\"token_id\": \"${TOKEN_ID}\"}}" \ - --node ${STARGAZE_NODE} - -echo "==== Check the NFT on Namada ====" -${NAMADAC} --base-dir ${NAMADA_BASE} shielded-sync \ - --viewing-keys ${SHIELDED_ALIAS} \ - --node ${NAMADA_LEDGER_ADDR} -token="nft-transfer/${namada_channel}/${SG721_CONTRACT}/${TOKEN_ID}" -echo "== shielded-1 balance ==" -${NAMADAC} --base-dir ${NAMADA_BASE} balance \ - --token ${token} \ - --owner ${SHIELDED_ALIAS} \ - --node ${NAMADA_LEDGER_ADDR} - -echo "== shielded-2 balance ==" -${NAMADAC} --base-dir ${NAMADA_BASE} balance \ - --token ${token} \ - --owner ${SHIELDED_ALIAS_2} \ - --node ${NAMADA_LEDGER_ADDR} diff --git a/scripts/setup-namada b/scripts/setup-namada deleted file mode 100755 index 2652d23297..0000000000 --- a/scripts/setup-namada +++ /dev/null @@ -1,232 +0,0 @@ -#!/bin/bash - -# This script sets up 2 Namada chains locally -# `make build` and `make build-wasm-scripts` on Namada directory in advance -# Run with `setup-namada ${namada_dir}` - -set -e - - -# Get absolute path to Namada directory -SCRIPT_DIR=$(cd $(dirname $0) && pwd) -NAMADA_DIR=$(cd $1 && pwd) -cd $SCRIPT_DIR -if [ -z "${NAMADA_DIR}" ] -then - echo "ERROR: Namada directory should be given" - exit 1 -fi - -HERMES_DIR=${PWD%/scripts*} - -# edit for your environment -NAMADAC="${NAMADA_DIR}/target/debug/namadac" -NAMADAN="${NAMADA_DIR}/target/debug/namadan" -NAMADAW="${NAMADA_DIR}/target/debug/namadaw" -BASE_GENESIS_DIR="${NAMADA_DIR}/genesis/localnet" -CHECKSUM_PATH="${NAMADA_DIR}/wasm/checksums.json" -DATA_DIR="${HERMES_DIR}/data" - -LEDGER_ADDR_A="http://127.0.0.1:27657" -LEDGER_ADDR_B="http://127.0.0.1:28657" - -HERMES_CONFIG_TEMPLATE=" -[global] -log_level = 'debug' - -[mode] - -[mode.clients] -enabled = true -refresh = true -misbehaviour = true - -[mode.connections] -enabled = false - -[mode.channels] -enabled = false - -[mode.packets] -enabled = true -clear_interval = 10 -clear_on_start = false -tx_confirmation = true - -[telemetry] -enabled = false -host = '127.0.0.1' -port = 3001 - -[[chains]] -id = '_CHAIN_ID_A_' -type = 'Namada' -rpc_addr = 'http://127.0.0.1:27657' -grpc_addr = 'http://127.0.0.1:9090' -event_source = { mode = 'push', url = 'ws://127.0.0.1:27657/websocket', batch_delay = '500ms' } -account_prefix = '' -key_name = 'relayer' -store_prefix = 'ibc' -gas_price = { price = 0.000001, denom = '_FEE_TOKEN_A_' } - -[[chains]] -id = '_CHAIN_ID_B_' -type = 'Namada' -rpc_addr = 'http://127.0.0.1:28657' -grpc_addr = 'http://127.0.0.1:9090' -event_source = { mode = 'push', url = 'ws://127.0.0.1:28657/websocket', batch_delay = '500ms' } -account_prefix = '' -key_name = 'relayer' -store_prefix = 'ibc' -gas_price = { price = 0.000001, denom = '_FEE_TOKEN_B_' } -" - -function make_genesis() { - local suffix=$1 - local base_dir=${DATA_DIR}/namada-${suffix} - - mkdir -p ${base_dir}/templates - cp ${BASE_GENESIS_DIR}/*.toml ${base_dir}/templates - sed -i .bak "s/epochs_per_year = .*/epochs_per_year = 31536/g" ${base_dir}/templates/parameters.toml - sed -i .bak "s/default_mint_limit = .*/default_mint_limit = \"1000000000\"/g" ${base_dir}/templates/parameters.toml - sed -i .bak "s/default_per_epoch_throughput_limit = .*/default_per_epoch_throughput_limit = \"1000000000\"/g" ${base_dir}/templates/parameters.toml - - mkdir ${base_dir}/pre-genesis - cp -r ${BASE_GENESIS_DIR}/src/pre-genesis/* ${base_dir}/pre-genesis -} - -function init_network() { - local suffix=$1 - local base_dir=${DATA_DIR}/namada-${suffix} - local validator_base_dir=${base_dir}/setup/validator-0 - - mkdir -p ${base_dir}/genesis - local chain_id=$(NAMADA_BASE_DIR=${base_dir} \ - ${NAMADAC} utils init-network \ - --chain-prefix namada-${suffix} \ - --genesis-time "2023-01-01T00:00:00.000000000+00:00" \ - --templates-path ${base_dir}/templates \ - --wasm-checksums-path ${CHECKSUM_PATH} \ - --archive-dir ${base_dir}/genesis \ - --wasm-dir ${NAMADA_DIR}/wasm \ - | awk '$1 == "Derived" {print $4}') - - mkdir -p ${validator_base_dir}/pre-genesis/validator-0 - cp ${BASE_GENESIS_DIR}/src/pre-genesis/validator-0/*.toml ${validator_base_dir}/pre-genesis/validator-0 - - NAMADA_NETWORK_CONFIGS_DIR=${base_dir}/genesis \ - ${NAMADAC} --base-dir ${validator_base_dir} \ - utils join-network \ - --chain-id ${chain_id} \ - --genesis-validator validator-0 \ - --pre-genesis-path \ - ${base_dir}/pre-genesis/validator-0 - - rm -rf ${base_dir}/${chain_id} - # for non-validator - NAMADA_NETWORK_CONFIGS_DIR=${base_dir}/genesis \ - ${NAMADAC} --base-dir ${base_dir} \ - utils join-network \ - --add-persistent-peers \ - --chain-id ${chain_id} -} - -function init_relayer_acc() { - local suffix=$1 - local chain_id=$2 - - local base_dir=${DATA_DIR}/namada-${suffix} - - ${NAMADAW} --base-dir ${base_dir} \ - gen --alias relayer --unsafe-dont-encrypt -} - -function add_relayer_key() { - local suffix=$1 - local chain_id=$2 - - local base_dir=${DATA_DIR}/namada-${suffix} - - cargo run --bin hermes -- --config ${HERMES_DIR}/config_for_namada.toml \ - keys add \ - --chain ${chain_id} \ - --key-file ${base_dir}/${chain_id}/wallet.toml \ - --overwrite -} - -# ==== main ==== - -mkdir -p ${DATA_DIR} - -# for chain A -make_genesis "a" -result=$(init_network "a") -chain_id_a=$(echo "${result}" | awk '$5 == "ID" {id = $6} END {print id}') - -${NAMADAN} --base-dir ${DATA_DIR}/namada-a/setup/validator-0 \ - ledger > ${DATA_DIR}/namada-a/namada.log 2>&1 & -sleep 5 - -# shutdown temporarily to bootstrap chain-b -killall namadan - -# for chain B -make_genesis "b" -result=$(init_network "b") -chain_id_b=$(echo "${result}" | awk '$5 == "ID" {id = $6} END {print id}') - -${NAMADAN} --base-dir ${DATA_DIR}/namada-b/setup/validator-0 \ - ledger > ${DATA_DIR}/namada-b/namada.log 2>&1 & -sleep 5 - -# shutdown temporarily to bootstrap chain-b -killall namadan - -# Edit chain-b addresses -sed -i .bak \ - -e "s/:27656/:28656/" \ - -e "s/:27657/:28657/" \ - -e "s/:27658/:28658/" \ - ${DATA_DIR}/namada-b/setup/validator-0/${chain_id_b}/config.toml -sed -i .bak \ - -e "s/:27656/:28656/" \ - -e "s/:27657/:28657/" \ - -e "s/:27658/:28658/" \ - ${DATA_DIR}/namada-b/setup/validator-0/${chain_id_b}/cometbft/config/config.toml - -# Restart each chain -${NAMADAN} --base-dir ${DATA_DIR}/namada-a/setup/validator-0 \ - ledger > ${DATA_DIR}/namada-a/namada.log 2>&1 & -echo "Namada chain A's PID = $!" -sleep 5 - -${NAMADAN} --base-dir ${DATA_DIR}/namada-b/setup/validator-0 \ - ledger > ${DATA_DIR}/namada-b/namada.log 2>&1 & -echo "Namada chain B's PID = $!" -sleep 5 - -# Create "relayer" account on each chain -init_relayer_acc "a" ${chain_id_a} -init_relayer_acc "b" ${chain_id_b} - -# Get token addresses -nam_addr_a=$(${NAMADAW} --base-dir ${DATA_DIR}/namada-a find --alias nam | awk '/"nam":/{print $3}') -nam_addr_b=$(${NAMADAW} --base-dir ${DATA_DIR}/namada-b find --alias nam | awk '/"nam":/{print $3}') - -# Make Hermes config -cd ${HERMES_DIR} -echo "${HERMES_CONFIG_TEMPLATE}" \ - | sed -e "s/_CHAIN_ID_A_/${chain_id_a}/g" -e "s/_CHAIN_ID_B_/${chain_id_b}/g" \ - | sed -e "s/_FEE_TOKEN_A_/${nam_addr_a}/g" -e "s/_FEE_TOKEN_B_/${nam_addr_b}/g" \ - > ${HERMES_DIR}/config_for_namada.toml - -# Add namada keys to Hermes -add_relayer_key "a" ${chain_id_a} -add_relayer_key "b" ${chain_id_b} - -echo "2 Namada chains are running" -echo "You can use Hermes with ${HERMES_DIR}/config_for_namada.toml" - -echo "You also want to run the following lines:" -echo "export CHAIN_A_ID=${chain_id_a}" -echo "export CHAIN_B_ID=${chain_id_b}" diff --git a/scripts/setup-namada-single-node b/scripts/setup-namada-single-node deleted file mode 100755 index dd32c3a1fb..0000000000 --- a/scripts/setup-namada-single-node +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash - -# This script sets up 1 Namada chain locally -# `make build` and `make build-wasm-scripts` on Namada directory in advance -# Run with `setup-namada-single-node ${namada_dir}` - -set -e - -NAMADA_DIR=$1 -if [ -z "${NAMADA_DIR}" ] -then - echo "ERROR: Namada directory should be given" - exit 1 -fi -cd $(dirname $0) -HERMES_DIR=${PWD%/scripts*} - -# edit for your environment -NAMADAC="${NAMADA_DIR}/target/debug/namadac" -NAMADAN="${NAMADA_DIR}/target/debug/namadan" -NAMADAW="${NAMADA_DIR}/target/debug/namadaw" -BASE_GENESIS_DIR="${NAMADA_DIR}/genesis/localnet" -CHECKSUM_PATH="${NAMADA_DIR}/wasm/checksums.json" -DATA_DIR="${HERMES_DIR}/data" - -LEDGER_ADDR="http://127.0.0.1:27657" - -HERMES_CONFIG_TEMPLATE=" -[global] -log_level = 'debug' - -[mode] - -[mode.clients] -enabled = true -refresh = true -misbehaviour = true - -[mode.connections] -enabled = false - -[mode.channels] -enabled = false - -[mode.packets] -enabled = true -clear_interval = 10 -clear_on_start = false -tx_confirmation = true - -[telemetry] -enabled = false -host = '127.0.0.1' -port = 3001 - -[[chains]] -id = '_CHAIN_ID_' -type = 'Namada' -rpc_addr = 'http://127.0.0.1:27657' -grpc_addr = 'http://127.0.0.1:9090' -event_source = { mode = 'push', url = 'ws://127.0.0.1:27657/websocket', batch_delay = '500ms' } -account_prefix = '' -key_name = 'relayer' -store_prefix = 'ibc' -gas_price = { price = 0.000001, denom = '_FEE_TOKEN_' } -" - -function make_genesis() { - local base_dir=${DATA_DIR}/namada - - mkdir -p ${base_dir}/templates - cp ${BASE_GENESIS_DIR}/*.toml ${base_dir}/templates - sed -i .bak "s/epochs_per_year = .*/epochs_per_year = 31536/g" ${base_dir}/templates/parameters.toml - sed -i .bak "s/default_mint_limit = .*/default_mint_limit = \"1000000000\"/g" ${base_dir}/templates/parameters.toml - sed -i .bak "s/default_per_epoch_throughput_limit = .*/default_per_epoch_throughput_limit = \"1000000000\"/g" ${base_dir}/templates/parameters.toml - - mkdir ${base_dir}/pre-genesis - cp -r ${BASE_GENESIS_DIR}/src/pre-genesis/* ${base_dir}/pre-genesis -} - -function init_network() { - local base_dir=${DATA_DIR}/namada - local validator_base_dir=${base_dir}/setup/validator-0 - - mkdir -p ${base_dir}/genesis - local chain_id=$(NAMADA_BASE_DIR=${base_dir} \ - ${NAMADAC} utils init-network \ - --chain-prefix namada-test \ - --genesis-time "2023-01-01T00:00:00.000000000+00:00" \ - --templates-path ${base_dir}/templates \ - --wasm-checksums-path ${CHECKSUM_PATH} \ - --archive-dir ${base_dir}/genesis \ - --wasm-dir ${NAMADA_DIR}/wasm \ - | awk '$1 == "Derived" {print $4}') - - mkdir -p ${validator_base_dir}/pre-genesis/validator-0 - cp ${BASE_GENESIS_DIR}/src/pre-genesis/validator-0/*.toml ${validator_base_dir}/pre-genesis/validator-0 - - NAMADA_NETWORK_CONFIGS_DIR=${base_dir}/genesis \ - ${NAMADAC} --base-dir ${validator_base_dir} \ - utils join-network \ - --add-persistent-peers \ - --chain-id ${chain_id} \ - --genesis-validator validator-0 - - # for non-validator - rm -rf ${base_dir}/${chain_id} - NAMADA_NETWORK_CONFIGS_DIR=${base_dir}/genesis \ - ${NAMADAC} --base-dir ${base_dir} \ - utils join-network \ - --add-persistent-peers \ - --chain-id ${chain_id} -} - -function init_relayer_acc() { - local chain_id=$1 - - local base_dir=${DATA_DIR}/namada - - ${NAMADAW} --base-dir ${base_dir} \ - gen --alias relayer --unsafe-dont-encrypt -} - -function fund_relayer_acc() { - local account=$1 - local base_dir=${DATA_DIR}/namada - - ${NAMADAC} --base-dir ${base_dir} \ - transparent-transfer --node ${LEDGER_ADDR} \ - --source ${account} --target relayer --amount 10000 --token NAM -} - -function add_relayer_key() { - local chain_id=$1 - - local base_dir=${DATA_DIR}/namada - - cargo run --bin hermes -- --config ${HERMES_DIR}/config_for_namada.toml \ - keys add \ - --chain ${chain_id} \ - --key-file ${base_dir}/${chain_id}/wallet.toml \ - --overwrite -} - -# ==== main ==== - -mkdir -p ${DATA_DIR} - -make_genesis -result=$(init_network) -chain_id=$(echo "${result}" | awk '$5 == "ID" {id = $6} END {print id}') - -${NAMADAN} --base-dir ${DATA_DIR}/namada/setup/validator-0 \ - ledger > ${DATA_DIR}/namada/namada.log 2>&1 & -echo "Namada chain's PID = $!" -sleep 5 - -init_relayer_acc ${chain_id} -sleep 10 - -fund_relayer_acc "albert" ${LEDGER_ADDR} - -nam_addr=$(${NAMADAW} --base-dir ${DATA_DIR}/namada find --alias nam | awk '/"nam":/{print $3}') - -# for the relayer -cd ${HERMES_DIR} -echo "${HERMES_CONFIG_TEMPLATE}" \ - | sed -e "s/_CHAIN_ID_/${chain_id}/g" -e "s/_FEE_TOKEN_/${nam_addr}/g" \ - > ${HERMES_DIR}/config_for_namada.toml - -add_relayer_key ${chain_id} - -echo "A Namada chain is running" -echo "You can use Hermes with ${HERMES_DIR}/config_for_namada.toml" - -echo "You also want to run the following lines:" -echo "export CHAIN_ID=${chain_id}"