Testing Packet Forwarding

Prerequisites

  • Gaiad at least (v8.0.0). The version can be checked with:
gaiad version --log_level error --long | head -n4

Testing procedure

Setup using Gaia manager

Note: The gm.toml file that we're using here looks like this:

[global]
  add_to_hermes = true
  auto_maintain_config = true
  extra_wallets = 2
  gaiad_binary = "/Users/luca/go/bin/gaiad"
  hdpath = ""
  home_dir = "/Users/luca/.gm"
  ports_start_at = 27000
  validator_mnemonic = ""
  wallet_mnemonic = ""

  [global.hermes]
    binary = "$HOME/.hermes/bin/hermes"
    config = "$HOME/.hermes/config.toml"
    log_level = "trace"
    telemetry_enabled = true
    telemetry_host = "127.0.0.1"
    telemetry_port = 3001

[ibc-0]
  ports_start_at = 27000

[ibc-1]
  ports_start_at = 27010

[ibc-2]
  ports_start_at = 27020
  • Run the command gm start
  • Run the commands: gm hermes config and gm hermes keys

Test packet forwarding

  1. Create a channel between ibc-0 and ibc-1, and another between ibc-1 and ibc-2:

    hermes create channel --a-chain ibc-0 --b-chain ibc-1 --a-port transfer --b-port transfer --new-client-connection
    
    
    SUCCESS Channel {
        ordering: Unordered,
        a_side: ChannelSide {
            chain: BaseChainHandle {
                chain_id: ChainId {
                    id: "ibc-0",
                    version: 0,
                },
                runtime_sender: Sender { .. },
            },
            client_id: ClientId(
                "07-tendermint-0",
            ),
            connection_id: ConnectionId(
                "connection-0",
            ),
            port_id: PortId(
                "transfer",
            ),
            channel_id: Some(
                ChannelId(
                    "channel-0",
                ),
            ),
            version: None,
        },
        b_side: ChannelSide {
            chain: BaseChainHandle {
                chain_id: ChainId {
                    id: "ibc-1",
                    version: 1,
                },
                runtime_sender: Sender { .. },
            },
            client_id: ClientId(
                "07-tendermint-0",
            ),
            connection_id: ConnectionId(
                "connection-0",
            ),
            port_id: PortId(
                "transfer",
            ),
            channel_id: Some(
                ChannelId(
                    "channel-0",
                ),
            ),
            version: None,
        },
        connection_delay: 0ns,
    }
    
    hermes create channel --a-chain ibc-1 --b-chain ibc-2 --a-port transfer --b-port transfer --new-client-connection
    
    
    SUCCESS Channel {
        ordering: Unordered,
        a_side: ChannelSide {
            chain: BaseChainHandle {
                chain_id: ChainId {
                    id: "ibc-1",
                    version: 1,
                },
                runtime_sender: Sender { .. },
            },
            client_id: ClientId(
                "07-tendermint-1",
            ),
            connection_id: ConnectionId(
                "connection-1",
            ),
            port_id: PortId(
                "transfer",
            ),
            channel_id: Some(
                ChannelId(
                    "channel-1",
                ),
            ),
            version: None,
        },
        b_side: ChannelSide {
            chain: BaseChainHandle {
                chain_id: ChainId {
                    id: "ibc-2",
                    version: 2,
                },
                runtime_sender: Sender { .. },
            },
            client_id: ClientId(
                "07-tendermint-0",
            ),
            connection_id: ConnectionId(
                "connection-0",
            ),
            port_id: PortId(
                "transfer",
            ),
            channel_id: Some(
                ChannelId(
                    "channel-0",
                ),
            ),
            version: None,
        },
        connection_delay: 0ns,
    }
    
  2. Obtain the addresses of the wallets on each chain:

    hermes keys list --chain ibc-0
    
    
    SUCCESS 
    - wallet2 (cosmos179ld56nmany7nqmsdjz684rx5t4r5gxspn6hgr)
    - wallet (cosmos1gz507egejvz3ukg3xwr3v04n3xcny7vcnkjw32)
    - wallet1 (cosmos14cgtalvczzm6xuaa086g5tx6sss6e85j55vqrd)
    
    hermes keys list --chain ibc-1
    
    
    SUCCESS 
    - wallet2 (cosmos1pmzq62tewxla9z7gpntcnvszyrkygnk4mesauy)
    - wallet (cosmos1jwr34yvnkqkc0ddndnh9y8t94hlhn7rapfyags)
    - wallet1 (cosmos1at4nj238c3ltlj0wymwgfjmdjctlvstwj8xl2s)
    
    hermes keys list --chain ibc-2
    
    
    SUCCESS 
    - wallet2 (cosmos1xpezl2vvwg9fhdmksvne6lygd7dwz4vf65v6ye)
    - wallet (cosmos1nsztzzhl553avufxhqa204908l4dndafqph4tw)
    - wallet1 (cosmos1csdnmydggcyvjd7z8l64z9lpdgmgyr4v7hw5r8)
    
  3. (Optional) Check the balance of the wallets before transferring tokens:

    hermes keys balance --all --chain ibc-0
    
    
    SUCCESS Balances for key `wallet`:
            100000000 samoleans
            99992294 stake
    
    hermes keys balance --all --chain ibc-1
    
    
    SUCCESS Balances for key `wallet`:
            100000000 samoleans
            99983377 stake
    
    hermes keys balance --all --chain ibc-2
    
    
    SUCCESS Balances for key `wallet`:
            100000000 samoleans
            99990916 stake
    
  4. (Optional) Confirm the name of the channels used for the transfer:

    hermes query channels --counterparty-chain ibc-1 --chain ibc-0
    
    
    SUCCESS [
        PortChannelId {
            channel_id: ChannelId(
                "channel-0",
            ),
            port_id: PortId(
                "transfer",
            ),
        },
    ]
    
    hermes query channels --counterparty-chain ibc-2 --chain ibc-1
    
    
    SUCCESS [
        PortChannelId {
            channel_id: ChannelId(
                "channel-1",
            ),
            port_id: PortId(
                "transfer",
            ),
        },
    ]
    
  5. In a separate terminal, start an instance of Hermes:

    hermes start
    
    
  6. Transfer token using the special receiver:

    hermes tx ft-transfer --denom samoleans --receiver cosmos1jwr34yvnkqkc0ddndnh9y8t94hlhn7rapfyags --memo '{"forward": {"receiver": "cosmos1al3csagycya3l7ze3dk4345czw9vwgtjtsezut", "port": "transfer", "channel": "channel-1"}}' --timeout-seconds 120  --dst-chain ibc-1 --src-chain ibc-0 --src-port transfer --src-channel channel-0 --amount 2500
    
    SUCCESS [
        IbcEventWithHeight {
            event: SendPacket(
                SendPacket {
                    packet: Packet {
                        sequence: Sequence(
                            2,
                        ),
                        source_port: PortId(
                            "transfer",
                        ),
                        source_channel: ChannelId(
                            "channel-0",
                        ),
                        destination_port: PortId(
                            "transfer",
                        ),
                        destination_channel: ChannelId(
                            "channel-0",
                        ),
                        data: [123, 34, 97, 109, 111, 117, 110, 116, 34, 58, 34, 50, 53, 48, 48, 34, 44, 34, 100, 101, 110, 111, 109, 34, 58, 34, 115, 97, 109, 111, 108, 101, 97, 110, 115, 34, 44, 34, 114, 101, 99, 101, 105, 118, 101, 114, 34, 58, 34, 99, 111, 115, 109, 111, 115, 49, 106, 119, 114, 51, 52, 121, 118, 110, 107, 113, 107, 99, 48, 100, 100, 110, 100, 110, 104, 57, 121, 56, 116, 57, 52, 104, 108, 104, 110, 55, 114, 97, 112, 102, 121, 97, 103, 115, 124, 116, 114, 97, 110, 115, 102, 101, 114, 47, 99, 104, 97, 110, 110, 101, 108, 45, 49, 58, 99, 111, 115, 109, 111, 115, 49, 110, 115, 122, 116, 122, 122, 104, 108, 53, 53, 51, 97, 118, 117, 102, 120, 104, 113, 97, 50, 48, 52, 57, 48, 56, 108, 52, 100, 110, 100, 97, 102, 113, 112, 104, 52, 116, 120, 34, 44, 34, 115, 101, 110, 100, 101, 114, 34, 58, 34, 99, 111, 115, 109, 111, 115, 49, 103, 122, 53, 48, 55, 101, 103, 101, 106, 118, 122, 51, 117, 107, 103, 51, 120, 119, 114, 51, 118, 48, 52, 110, 51, 120, 99, 110, 121, 55, 118, 99, 110, 107, 106, 119, 51, 50, 34, 125],
                        timeout_height: Never,
                        timeout_timestamp: Timestamp {
                            time: Some(
                                Time(
                                    2022-11-10 16:05:13.409228,
                                ),
                            ),
                        },
                    },
                },
            ),
            height: Height {
                revision: 0,
                height: 59,
            },
        },
    ]
    
  7. (Optional) Check the balances:

    hermes keys balance --all --chain ibc-0
    
    
    SUCCESS Balances for key `wallet`:
            99997500 samoleans
            99985136 stake
    
    hermes keys balance --all --chain ibc-1
    
    
    SUCCESS Balances for key `wallet`:
            100000000 samoleans
            99972551 stake
    
    hermes keys balance --all --chain ibc-2
    
    
    SUCCESS Balances for key `wallet`:
            2500 ibc/F47F0D7C9B4F7D971DF647A75A80CB8D905D3230262FEF2996340664D3A12D48
            100000000 samoleans
            99987055 stake