Skip to content

Commit

Permalink
test ibc fee middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
dasanchez committed Apr 22, 2024
1 parent 604a0fe commit 1637834
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 15 deletions.
161 changes: 146 additions & 15 deletions .github/workflows/upgrade-gaia-v16-fresh-state.yml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
# exit 0
# fi

# v16-2-ibc-rate-limit:
# v16-2-IBC-rate-limit:
# runs-on: ubuntu-22.04
# needs: set-version-matrix
# strategy:
Expand Down Expand Up @@ -795,7 +795,136 @@
# sleep 3
# tests/gaia-v16/test_rate_limits.sh $TRANSFER_CHANNEL $RATE $RPC_PORT

v16-3-ica-controller:
# v16-3-ICA-controller:
# runs-on: ubuntu-22.04
# needs: set-version-matrix
# strategy:
# matrix:
# ${{ fromJSON(needs.set-version-matrix.outputs.upgrade_versions) }}
# fail-fast: false
# env:
# COSMOVISOR_VERSION: ${{ matrix.cv_version }}
# UPGRADE_MECHANISM: ${{ matrix.upgrade_mechanism }}
# CHAIN_BINARY_SECONDARY: gaiad-ibc
# COMMIT_TIMEOUT: 1
# RELAYER: hermes
# steps:
# - name: start-version
# run: echo ${{matrix.gaia_version}}
# - name: target-version
# run: echo ${{matrix.upgrade_version}}
# - name: target-commit
# if: ${{ matrix.upgrade_version == 'main' }}
# run: |
# BUILD_TAG=gaiad-linux-${{matrix.upgrade_version}}
# TARGET_COMMIT=$(curl -s -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/hyphacoop/cosmos-builds/releases/tags/$BUILD_TAG | jq -r '.name')
# echo TARGET_COMMIT: $TARGET_COMMIT
# - name: Update PATH
# run: |
# mkdir -p $HOME/go/bin
# echo "$HOME/go/bin" >> $GITHUB_PATH
# echo "$HOME/.hermes" >> $GITHUB_PATH
# echo "$HOME/.relayer" >> $GITHUB_PATH
# - name: Bypass the grub-efi-amd64-signed package
# run: sudo apt-mark hold grub-efi-amd64-signed
# - name: Check out repository code
# uses: actions/checkout@v3
# - name: Set up Python
# uses: actions/setup-python@v3
# with:
# python-version: '3.10'
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# python -m pip install toml-cli
# - name: Install Cosmovisor > v1.3.0
# if: ${{ (matrix.upgrade_mechanism == 'cv_manual' || matrix.upgrade_mechanism == 'cv_auto') && matrix.cv_version != 'v1.3.0' }}
# run: |
# go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@$COSMOVISOR_VERSION
# echo "COSMOVISOR=true" >> $GITHUB_ENV
# echo "$HOME_1/cosmovisor/current/bin" >> $GITHUB_PATH
# - name: Install Cosmovisor v1.3.0
# if: ${{ (matrix.upgrade_mechanism == 'cv_manual' || matrix.upgrade_mechanism == 'cv_auto') && matrix.cv_version == 'v1.3.0' }}
# run: |
# go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@$COSMOVISOR_VERSION
# echo "COSMOVISOR=true" >> $GITHUB_ENV
# echo "$HOME_1/cosmovisor/current/bin" >> $GITHUB_PATH
# - name: Set up relayer
# run: scripts/gaia-v16/setup_relayer_ica_controller.sh

# - name: Start chain
# env:
# START_VERSION: ${{matrix.gaia_version}}
# run: |
# export CHAIN_BINARY_URL=https://github.com/cosmos/gaia/releases/download/$START_VERSION/gaiad-$START_VERSION-linux-amd64
# scripts/start_chain_single_val.sh
# - name: Check Gaia log
# run: sudo journalctl -u $PROVIDER_SERVICE_1
# - name: Print Gaia version
# run: $CHAIN_BINARY version --long
# - name: Block production check
# run: tests/test_block_production.sh 127.0.0.1 $VAL1_RPC_PORT 5 # 5 blocks

# - name: Installing secondary chain binaries
# env:
# START_VERSION: ${{matrix.gaia_version}}
# run: |
# export CHAIN_BINARY_URL=https://github.com/cosmos/gaia/releases/download/$START_VERSION/gaiad-$START_VERSION-linux-amd64
# echo "Chain binary URL: $CHAIN_BINARY_URL"
# echo "Installing secondary chain binary..."
# wget $CHAIN_BINARY_URL -O $HOME/go/bin/$CHAIN_BINARY_SECONDARY -q
# chmod +x $HOME/go/bin/$CHAIN_BINARY_SECONDARY
# - name: Start host chain
# env:
# CHAIN_SERVICE: host.service
# CHAIN_HOME: /home/runner/.host
# CHAIN_ID: host
# API_PORT: 25011
# GRPC_PORT: 26011
# RPC_PORT: 27011
# P2P_PORT: 28011
# PPROF_PORT: 29011
# run: |
# scripts/start_chain_secondary.sh
# - name: Generate host connection
# env:
# TARGET_CHAIN_ID: host
# CLIENT_COUNT: 0
# RPC_PORT: 27011
# run: |
# scripts/gaia-v16/setup_connection_ica_controller.sh $CHAIN_ID $TARGET_CHAIN_ID $CLIENT_COUNT

# - name: Test software upgrade for published releases
# if: ${{ matrix.upgrade_version != 'main' }}
# env:
# DOWNLOAD_URL: https://github.com/cosmos/gaia/releases/download/${{ matrix.upgrade_version }}/gaiad-${{ matrix.upgrade_version }}-linux-amd64
# run: |
# echo $DOWNLOAD_URL
# scripts/software_upgrade.sh 127.0.0.1 $VAL1_RPC_PORT $TARGET_VERSION
# - name: Test software upgrade for main branch
# if: ${{ matrix.upgrade_version == 'main' }}
# env:
# DOWNLOAD_URL: https://github.com/hyphacoop/cosmos-builds/releases/download/gaiad-linux-main/gaiad-linux
# run: |
# scripts/software_upgrade.sh 127.0.0.1 $VAL1_RPC_PORT $TARGET_VERSION

# - name: _Blocks produced after upgrade
# run: |
# tests/test_block_production.sh 127.0.0.1 $VAL1_RPC_PORT 10

# - name: Restart relayer
# run: |
# sudo systemctl restart $RELAYER
# sleep 1m

# - name: _Test ICA controller
# env:
# CONTROLLER_HOME: /home/runner/.val1
# HOST_HOME: /home/runner/.host
# run: |
# tests/gaia-v16/test_ica_controller.sh

v16-4-IBC-fee-middleware:
runs-on: ubuntu-22.04
needs: set-version-matrix
strategy:
Expand Down Expand Up @@ -850,11 +979,12 @@
echo "COSMOVISOR=true" >> $GITHUB_ENV
echo "$HOME_1/cosmovisor/current/bin" >> $GITHUB_PATH
- name: Set up relayer
run: scripts/gaia-v16/setup_relayer_ica_controller.sh
run: scripts/gaia-v16/setup_relayer_ibc_fee.sh

- name: Start chain
env:
START_VERSION: ${{matrix.gaia_version}}
GAS_PRICE: 0
run: |
export CHAIN_BINARY_URL=https://github.com/cosmos/gaia/releases/download/$START_VERSION/gaiad-$START_VERSION-linux-amd64
scripts/start_chain_single_val.sh
Expand All @@ -870,25 +1000,27 @@
START_VERSION: ${{matrix.gaia_version}}
run: |
export CHAIN_BINARY_URL=https://github.com/cosmos/gaia/releases/download/$START_VERSION/gaiad-$START_VERSION-linux-amd64
export DOWNLOAD_URL: https://github.com/cosmos/gaia/releases/download/v16.0.0-rc0/gaiad-v16.0.0-rc0-linux-amd64
echo "Chain binary URL: $CHAIN_BINARY_URL"
echo "Installing secondary chain binary..."
wget $CHAIN_BINARY_URL -O $HOME/go/bin/$CHAIN_BINARY_SECONDARY -q
wget $DOWNLOAD_URL -O $HOME/go/bin/$CHAIN_BINARY_SECONDARY -q
chmod +x $HOME/go/bin/$CHAIN_BINARY_SECONDARY
- name: Start host chain
- name: Start secondary chain
env:
CHAIN_SERVICE: host.service
CHAIN_HOME: /home/runner/.host
CHAIN_ID: host
CHAIN_SERVICE: two.service
CHAIN_HOME: /home/runner/.two
CHAIN_ID: two
API_PORT: 25011
GRPC_PORT: 26011
RPC_PORT: 27011
P2P_PORT: 28011
PPROF_PORT: 29011
GAS_PRICE: 0
run: |
scripts/start_chain_secondary.sh
- name: Generate host connection
- name: Generate connection connection
env:
TARGET_CHAIN_ID: host
TARGET_CHAIN_ID: two
CLIENT_COUNT: 0
RPC_PORT: 27011
run: |
Expand Down Expand Up @@ -917,14 +1049,13 @@
sudo systemctl restart $RELAYER
sleep 1m
- name: _Test ICA controller
- name: _Test IBC fee middleware
env:
CONTROLLER_HOME: /home/runner/.val1
HOST_HOME: /home/runner/.host
HOME_IBC: /home/runner/.two
run: |
tests/gaia-v16/test_ica_controller.sh
tests/gaia-v16/test_ibc_fee.sh
# Baseline-1-upgrade:
# runs-on: ubuntu-22.04
# needs: set-version-matrix-cosmovisor
Expand Down
42 changes: 42 additions & 0 deletions scripts/gaia-v16/setup_relayer_ibc_fee.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# Set up a relayer

if [ $RELAYER == "hermes" ]; then
echo "Downloading Hermes..."
wget -q https://github.com/informalsystems/hermes/releases/download/$HERMES_VERSION/hermes-$HERMES_VERSION-x86_64-unknown-linux-gnu.tar.gz -O hermes-$HERMES_VERSION.tar.gz
tar -xzvf hermes-$HERMES_VERSION.tar.gz
mkdir -p ~/.hermes
cp hermes ~/.hermes/hermes
export PATH="$PATH:~/.hermes"

echo "Setting up Hermes config..."
cp templates/gaia-v16/hermes-config-ibc-fee.toml ~/.hermes/config.toml

echo "Adding relayer keys..."
echo $MNEMONIC_RELAYER > mnemonic.txt
hermes keys add --chain $CHAIN_ID --mnemonic-file mnemonic.txt
hermes keys add --chain host --mnemonic-file mnemonic.txt
fi

echo "Creating service..."
sudo touch /etc/systemd/system/$RELAYER.service
echo "[Unit]" | sudo tee /etc/systemd/system/$RELAYER.service
echo "Description=Relayer service" | sudo tee /etc/systemd/system/$RELAYER.service -a
echo "After=network-online.target" | sudo tee /etc/systemd/system/$RELAYER.service -a
echo "" | sudo tee /etc/systemd/system/$RELAYER.service -a
echo "[Service]" | sudo tee /etc/systemd/system/$RELAYER.service -a
echo "User=$USER" | sudo tee /etc/systemd/system/$RELAYER.service -a

if [ $RELAYER == "hermes" ]; then
echo "ExecStart=$HOME/.hermes/$RELAYER start" | sudo tee /etc/systemd/system/$RELAYER.service -a
elif [ $RELAYER == "rly" ]; then
echo "ExecStart=$HOME/.relayer/$RELAYER start" | sudo tee /etc/systemd/system/$RELAYER.service -a
fi
echo "Restart=no" | sudo tee /etc/systemd/system/$RELAYER.service -a
echo "LimitNOFILE=4096" | sudo tee /etc/systemd/system/$RELAYER.service -a
echo "" | sudo tee /etc/systemd/system/$RELAYER.service -a
echo "[Install]" | sudo tee /etc/systemd/system/$RELAYER.service -a
echo "WantedBy=multi-user.target" | sudo tee /etc/systemd/system/$RELAYER.service -a

sudo systemctl daemon-reload
sudo systemctl enable $RELAYER
60 changes: 60 additions & 0 deletions templates/gaia-v16/hermes-config-ibc-fee.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[global]
log_level = 'info'

[mode]

[mode.clients]
enabled = true
refresh = true
misbehaviour = true

[mode.connections]
enabled = true

[mode.channels]
enabled = true

[mode.packets]
enabled = true
clear_interval = 10
clear_on_start = true
tx_confirmation = true

[telemetry]
enabled = true
host = '127.0.0.1'
port = 3001

[[chains]]
id = 'testnet'
rpc_addr = 'http://localhost:27001'
grpc_addr = 'http://localhost:26001'
event_source = { mode = 'push', url = 'ws://localhost:27001/websocket', batch_delay = '500ms' }
rpc_timeout = '15s'
account_prefix = 'cosmos'
key_name = 'wallet'
store_prefix = 'ibc'
gas_price = { price = 0, denom = 'uatom' }
gas_multiplier = 1.5
max_gas = 10000000
clock_drift = '10s'
trusting_period = '5days'
trust_threshold = { numerator = '1', denominator = '3' }
type = "CosmosSdk"

[[chains]]
id = 'two'
rpc_addr = 'http://localhost:27011'
grpc_addr = 'http://localhost:26011'
event_source = { mode = 'push', url = 'ws://localhost:27011/websocket', batch_delay = '500ms' }
rpc_timeout = '15s'
account_prefix = 'cosmos'
key_name = 'wallet'
store_prefix = 'ibc'
gas_price = { price = 0, denom = 'uatom' }
gas_multiplier = 1.5
max_gas = 10000000
clock_drift = '10s'
trusting_period = '5days'
trust_threshold = { numerator = '1', denominator = '3' }
type = "CosmosSdk"
16 changes: 16 additions & 0 deletions tests/gaia-v16/test_ibc-fee.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

balance_before=$($CHAIN_BINARY q bank balances $RELAYER_WALLET --home $HOME_1 -o json | jq -r --arg DENOM "$DENOM" '.balances[] | select(.denom == $DENOM).amount')

$RELAYER --json create channel --order unordered --a-chain $CHAIN_ID --a-port transfer --b-port transfer --a-connection connection-0 --channel-version "{\"fee_version\":\"ics29-1\",\"app_version\":\"ics20-1\"}"

txhash=$($CHAIN_BINARY tx ibc-transfer transfer transfer channel-0 $WALLET_1 1$DENOM --gas $GAS --gas-prices $GAS_PRICE$DENOM --gas-adjustment $GAS_ADJUSTMENT --from $WALLET_1 --output json -y --home $HOME_1 | jq -r '.txhash')
sleep $TIMEOUT_COMMIT
sequence=$($CHAIN_BINARY q tx $txhash --home $HOME_1 -o json | jq -r '.events[] | select(.type == "send_packet").attributes[] | select(.key == "packet_sequence").value')
$CHAIN_BINARY tx ibc-fee pay-packet-fee transfer channel-0 $sequence --recv-fee 123uatom --ack-fee 456uatom --timeout-fee 789uatom --from $WALLET_1 --gas $GAS --gas-prices $GAS_PRICE$DENOM --gas-adjustment $GAS_ADJUSTMENT --home $HOME_1 -y

sleep 30
balance_after=$($CHAIN_BINARY q bank balances $RELAYER_WALLET --home $HOME_1 -o json | jq -r --arg DENOM "$DENOM" '.balances[] | select(.denom == $DENOM).amount')

difference=$(echo "$balance_after - $balance_before" | bc)
echo "Difference: ${difference}$DENOM"

0 comments on commit 1637834

Please sign in to comment.