Introducing a new way to review your PRs.

Read the announcement

lfdt-ibc / ibc-go

Inter-Blockchain Communication Protocol (IBC) implementation in Golang.

View on GitHub

20 documents · Updated Nov 13, 2026

docs / end-to-end-suite-and-simulation-app

End-to-end suite and simulation app

The end-to-end suite runs IBC scenarios across temporary Cosmos chains and relayers. The simulation app provides the simd chain that those scenarios start, query, upgrade, and use to process IBC packets. Together they check the full path from a signed transaction to cross-chain state.

System purpose

The suite tests IBC behavior at the level of running chains. It creates real chain boundaries and lets a relayer carry proofs and packets between them. The simulation app makes those chains consistent test targets by wiring IBC modules into one executable Cosmos SDK state machine.

The two Go modules link to the local IBC code. Their SDK, CometBFT, and IBC versions must remain compatible with the chain images and the scenarios they run (e2e/go.mod#L1-L34, simapp/go.mod#L1-L26). See Integration and test infrastructure for the wider test system and Go testing harness for unit and integration test patterns.

End-to-end test environment

Test configuration

The test configuration turns chain and relayer choices into a runnable network. Local runs read a YAML file, while CI can use the checked-in configuration and environment overrides. The configuration can select up to four chains, images and versions, validator and full-node counts, the active relayer, upgrade plans, and diagnostic behavior (e2e/…/testconfig.go• L99-115, e2e/…/testconfig.go• L393-420).

Validation runs before setup. It checks that every chain has an image, binary, version, and node; that Chain A and Chain B use compatible chain-ID revisions; that the active relayer exists; and that an upgrade name maps to a version when upgrades are enabled (e2e/…/testconfig.go• L118-189, e2e/…/testconfig.go• L227-254).

Environment values override file values. If no file exists locally, e2e/…/init.sh• L13-28 creates one from the sample configuration. CI uses e2e/ci-e2e-config.yaml and can replace image tags or relayer choice without changing the test scenario (e2e/ci-e2e-config.yaml• L7-20, e2e/sample.config.extended.yaml• L7-20).

References: e2e/…/testconfig.go• L99-189 e2e/…/testconfig.go• L393-420 e2e/…/testconfig.go• L490-648 e2e/…/init.sh• L13-28 e2e/ci-e2e-config.yaml• L7-20

Chain and relayer topology

The suite models a small network of independent Cosmos chains. It normally links neighboring chains: Chain A to B, B to C, and C to D. A scenario can use one chain for localhost or attestation tests, two chains for a standard transfer, or more chains for forwarding and multi-hop behavior (e2e/…/testsuite.go• L206-218, e2e/…/testsuite.go• L443-480).

Each chain runs in a Docker container on a shared test network. Relayers run in their own containers and submit the messages needed to advance IBC state. The suite supports Hermes and the Cosmos Go relayer through one common relayer contract (e2e/…/relayer.go• L20-54, e2e/…/relayer.go• L137-161).

The selected chain image and version make compatibility tests possible. A scenario can pair different chain releases and use version gates to choose the message, genesis, query, or error format that each release supports (e2e/…/values.go• L51-129).

References: e2e/…/testconfig.go• L702-783 e2e/…/testsuite.go• L443-480 e2e/…/relayer.go• L20-54 e2e/…/relayer.go• L137-161 e2e/…/values.go• L51-129

Suite lifecycle

The suite creates shared chains once for each test suite. Each test then creates its own IBC clients, connections, channels, and relayer assignment. This gives tests a common chain environment while preserving control over channel versions, ordering, and setup (e2e/…/testsuite.go• L150-204, e2e/README.md• L128-142).

The lifecycle follows this order:

  1. Load, default, and validate the configuration.
  2. Create a Docker network and the requested chain containers.
  3. Create a relayer pool before tests run. Single-test mode normally uses one relayer. Suite mode reserves a pool for concurrent tests.
  4. Assign one relayer to each test and create its paths.
  5. Create clients, connections, and channels for the selected chains.
  6. Start or flush the relayer when the scenario needs packet movement.
  7. Broadcast transactions and query source and destination state.
  8. Collect logs or genesis data when needed, then remove containers unless debug settings keep them.

The full suite may run tests in parallel on one host. Tests that change chain-wide parameters, run governance, or restart a chain must stay isolated (e2e/README.md• L100-110, e2e/README.md• L136-142).

This diagram shows how configuration becomes shared infrastructure and then becomes scenario evidence.

flowchart LR
    C[Configuration] --> N[Docker network]
    N --> CH[Chain containers]
    N --> RP[Relayer pool]
    CH --> P[Test path]
    RP --> P
    P --> TX[Scenario transaction]
    TX --> PKT[Packet or proof]
    PKT --> Q[Queries and assertions]
    Q --> D[Diagnostics and cleanup]

References: e2e/…/testsuite.go• L85-109 e2e/…/testsuite.go• L150-204 e2e/…/testsuite.go• L710-738 e2e/…/diagnostics.go• L26-101 e2e/README.md• L121-179

Path and channel ownership

An IBC path is the test relationship between two chains. The relayer names the path and creates client and connection state. The test then creates the channel with its chosen options and records the channel under the test name (e2e/…/testsuite.go• L206-261).

Concurrent tests need separate channel ownership. The suite locks channel creation and discovery, selects the newest channel in each direction, records it for the owning test, and applies the complete Hermes packet filter. This prevents a relayer from processing a channel created by another test (e2e/…/testsuite.go• L264-288, e2e/…/relayer.go• L56-109).

References: e2e/…/testsuite.go• L206-288 e2e/…/testsuite.go• L330-381 e2e/…/relayer.go• L56-109

Relayer assignment

The suite treats Hermes and the Cosmos Go relayer as interchangeable packet workers. A test receives one relayer from a pre-created pool and reuses that assignment for its paths and packet flow. Pre-creation avoids unsafe relayer creation during concurrent test execution (e2e/…/testsuite.go• L150-159, e2e/…/testsuite.go• L359-381).

Hermes can watch only the channels assigned to the test. ICA endpoints remain enabled as a special case because ICA scenarios need their own channel family. The filter therefore protects most parallel traffic but still leaves a shared ICA allowance (e2e/…/relayer.go• L56-108).

References: e2e/…/testsuite.go• L150-159 e2e/…/testsuite.go• L359-381 e2e/…/relayer.go• L56-108

Scenario execution

Transaction and packet flow

Scenarios fund wallets on temporary chains, submit Cosmos SDK or IBC messages, and inspect both transaction results and committed state. BroadcastMessages adapts messages for the target chain version, uses the suite codec, waits for block progress, and retries relayer-wallet sequence races (e2e/…/tx.go• L37-77).

An IBC transfer demonstrates the main contract. The source chain escrows or burns the token and stores a packet commitment. A relayer submits the packet and its proof to the destination. The destination writes an acknowledgement. The relayer returns that acknowledgement so the source can clear the commitment or refund the sender on an error or timeout (e2e/…/base_test.go• L53-167, e2e/…/testsuite.go• L408-436).

sequenceDiagram
    participant U as Test wallet
    participant A as Source chain
    participant R as Relayer
    participant B as Destination chain
    U->>A: Submit transaction
    A->>A: Commit packet and escrow state
    R->>A: Observe commitment
    R->>B: Submit packet proof
    B->>B: Apply application logic
    B-->>R: Write acknowledgement
    R->>A: Submit acknowledgement
    A->>A: Clear commitment or refund
    U->>A: Query source state
    U->>B: Query destination state

References: e2e/…/tx.go• L37-77 e2e/…/base_test.go• L53-167 e2e/…/base_test.go• L169-273 e2e/…/testsuite.go• L408-436

Scenario coverage

The scenario set uses one environment model to check core IBC, applications, middleware, alternate clients, and upgrades. The tests assert state transitions rather than only transaction success.

Scenario familyProduct behavior checked
Client and connection scenariosClient trust, updates, misbehaviour, recovery, and connection parameters
Transfer scenariosNative and IBC token movement, acknowledgements, timeouts, invalid receivers, and send or receive controls
Interchain account scenariosRemote account creation, transaction execution, queries, governance, channel ordering, and reopen behavior
Packet-forward scenariosMulti-hop transfers, unwind paths, invalid forwards, and timeout refunds
Rate-limit scenariosQuota state, inflow and outflow accounting, denial acknowledgements, and refund behavior
GMP and attestation scenariosCross-chain calls and packet proofs from an attestation client
Upgrade scenariosState migration, chain restarts, old IBC application state, and packet flow before and after upgrade

IBC v2 scenarios create clients, register counterparties, query proofs, and submit receive, acknowledgement, or timeout messages directly. This gives the suite coverage for v2 transfer and rate-limit behavior even when a normal relayer path is not used (e2e/…/ibc_v2_test.go• L53-188, e2e/…/ibc_v2_test.go• L57-219).

Compatibility scenarios use release markers to choose supported features. The suite can use old and new governance formats, sanitize messages for older chains, and adapt query paths when reflection is unavailable (e2e/…/messages.go• L14-65, e2e/…/grpc_query.go• L22-69).

References: e2e/…/base_test.go• L53-273 e2e/…/base_test.go• L61-168 e2e/…/packet_forward_test.go• L33-180 e2e/…/rate_limiting_test.go• L42-213 e2e/…/base_test.go• L58-195 e2e/…/attestations_test.go• L47-222 e2e/…/upgrade_test.go• L132-238

Upgrade and compatibility flow

Upgrade scenarios treat a chain version as part of the test input. They submit a governance upgrade plan, halt the chain at the planned height, replace the chain image, restart the nodes, and repopulate query paths before checking IBC state again (e2e/…/upgrade_test.go• L65-130).

Legacy upgrade scenarios preserve or remove in-flight application state as the target version takes ownership. The suite checks packet-forward state and rate-limit pending packets before and after migration. This protects behavior that is not visible through a normal transfer result (e2e/…/v10_legacy_pfm_upgrade_test.go• L266-484, e2e/…/v10_legacy_ratelimit_upgrade_test.go• L120-197).

Genesis checks use the same chain lifecycle as upgrades. They export state, replace node genesis data, reset the node state, restart the chain, and confirm that IBC transfers and interchain accounts still work (e2e/…/genesis_test.go• L63-212).

References: e2e/…/upgrade_test.go• L65-130 e2e/…/v10_legacy_pfm_upgrade_test.go• L40-64 e2e/…/v10_legacy_pfm_upgrade_test.go• L266-484 e2e/…/v10_legacy_ratelimit_upgrade_test.go• L120-197 e2e/…/genesis_test.go• L150-251

Query and diagnostic boundary

Queries provide the observation boundary for scenarios. On chains that support reflection, the suite discovers gRPC paths from file descriptors. Older chains use a derived path format. Shared query helpers then expose balances, clients, channels, module accounts, validator sets, and IBC state in scenario terms (e2e/…/grpc_query.go• L22-69, e2e/…/queries.go• L29-168).

Diagnostics preserve the evidence needed to explain a failure. Cleanup can copy chain and relayer logs, configuration files, genesis files, and Docker inspection data when a test fails or debug mode requests collection (e2e/…/diagnostics.go• L26-101, e2e/…/testsuite.go• L710-738).

References: e2e/…/grpc_query.go• L22-115 e2e/…/queries.go• L29-168 e2e/…/diagnostics.go• L26-101 e2e/…/diagnostics.go• L148-165

Simulation application

Executable chain

The simulation app is a Cosmos SDK application for tests, learning, and small local networks. Its simd command exposes standard chain commands for initialization, keys, genesis, transactions, queries, block processing, state export, snapshots, and upgrades (simapp/…/root.go• L195-218, simapp/README.md• L5-36).

simd creates a SimApp with the same module and codec contract used by the end-to-end containers. A local initialization flow can create a working chain with funded accounts and a validator, while the normal Cosmos SDK commands support multi-validator testnets (simapp/…/root.go• L42-107, simapp/…/main.go• L16-21).

The app uses module genesis state as the boundary between chain setup and runtime. Initialization routes each module's raw JSON state into the registered modules. Export gathers module state, validators, and consensus parameters into a new genesis result (simapp/genesis.go• L9-16, simapp/app.go• L717-727, simapp/export.go• L18-49).

References: simapp/README.md• L1-6 simapp/README.md• L17-36 simapp/…/root.go• L42-107 simapp/…/main.go• L16-21 simapp/genesis.go• L9-16 simapp/export.go• L18-49

IBC module set

The app runs IBC as part of one Cosmos SDK state machine. IBC core manages clients, connections, channels, and packet commitments. Application modules provide token transfer, interchain accounts, cross-chain calls, packet forwarding, and rate limits. Light-client modules provide Tendermint, solo machine, and attestation verification (simapp/app.go• L330-397, simapp/app.go• L452-462, simapp/app.go• L475-506).

The module set also supplies the codec, stores, genesis handling, message services, query services, block hooks, and command metadata that make those features available through simd. This is why the end-to-end suite can drive the app through normal transactions and queries instead of a special IBC test stub (simapp/app.go• L508-519, simapp/app.go• L575-615, simapp/…/root.go• L98-107).

References: simapp/app.go• L261-267 simapp/app.go• L330-397 simapp/app.go• L452-506 simapp/app.go• L508-519 simapp/app.go• L575-615

IBC router stacks

The IBC router maps packet ports and submodules to the application that handles them. Middleware is a policy layer around a base application. For the classic transfer route, outgoing packets pass from transfer through packet forwarding and rate limiting to IBC core. Incoming packets pass back through rate limiting and packet forwarding before transfer handles them (simapp/app.go• L399-422).

The app also exposes separate routes for ICA controller and host behavior. The IBC v2 router connects v2 transfer with rate limiting and connects GMP to its cross-chain call handler. Light-client routes connect client identifiers to their verification modules (simapp/app.go• L424-462).

flowchart LR
    S[Transfer send] --> T[Transfer]
    T --> P[Packet forwarding]
    P --> L[Rate limiting]
    L --> C[IBC channel]
    C --> L2[Rate limiting receive]
    L2 --> P2[Packet forwarding receive]
    P2 --> T2[Transfer receive]
    C --> ICA[ICA controller and host]
    C --> V2[IBC v2 transfer]
    C --> GMP[GMP]

References: simapp/app.go• L399-450 simapp/app.go• L452-462 e2e/…/packet_forward_test.go• L75-180 e2e/…/ibc_v2_test.go• L98-219

Chain lifecycle and simulation

The app assigns module order for pre-block, begin-block, end-block, genesis initialization, and genesis export. These orders keep dependent state ready at the point where each block or genesis stage runs (simapp/app.go• L521-570).

Transactions pass through the SDK ante handler before message execution. The handler validates the transaction, fees, signatures, sequences, and redundant IBC relay conditions. The module manager then runs block hooks and commits the combined state (simapp/ante.go• L15-53, simapp/app.go• L607-680).

The simulation manager uses the registered modules to support deterministic SDK state and transaction simulation. Query and API services expose the same module set to CLI and gRPC clients, including reflection used by the end-to-end query layer (simapp/app.go• L585-605, simapp/app.go• L805-847).

References: simapp/app.go• L521-615 simapp/app.go• L697-727 simapp/app.go• L800-847 simapp/ante.go• L15-53

Upgrade handlers

The simulation app registers named upgrade handlers for supported chain releases and legacy IBC application layouts. A handler can run migrations and add stores before the module manager continues. This lets the end-to-end suite start an older image and move it to the current app while checking preserved packet and rate-limit state (simapp/upgrades.go• L22-95).

Store additions are selected from the upgrade plan on disk. The supported legacy plans add the stores needed by GMP or rate limiting. The handler and store loader therefore form one upgrade contract (simapp/upgrades.go• L97-132).

References: simapp/upgrades.go• L22-95 simapp/upgrades.go• L97-132 e2e/…/v10_legacy_pfm_upgrade_test.go• L40-64 e2e/…/v10_legacy_ratelimit_upgrade_test.go• L120-197

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep YAML fields, environment overrides, defaults, and image tags aligned. A valid configuration can still select a chain release that lacks the genesis or message features a scenario expects.
  • Keep the active relayer ID, relayer pool size, test assignment, and packet filter channel set aligned when changing concurrency or topology.
  • When changing chain count or link shape, update both shared setup and every scenario that assumes neighboring paths or channel ownership.
  • When changing a query service or chain release, keep reflection discovery and the older derived gRPC path in agreement.
  • When adding a message or proto type to an end-to-end transaction, update the shared codec and the version sanitizer when older chains can receive it.
  • When changing an IBC application, update its store, router route, module manager entry, service registration, genesis order, and light-client or middleware links as one contract.
  • When changing middleware order, check outgoing and incoming paths. The incoming path must unwind the outgoing stack in the reverse order.
  • When changing an upgrade plan, keep the plan name, target image, handler, store additions, migration order, and legacy E2E fixture aligned.
  • Keep the e2e and simapp local replacements and SDK, CometBFT, and IBC versions compatible with the chain images under test.

Important failure modes

TriggerConsequenceGuard
Active relayer ID is absent from the configured relayer listSetup cannot build the relayer used by a scenarioValidate the configuration before creating containers
Chain A and Chain B have different parsed chain-ID revisionsClient height and timeout checks fail as misleading timeoutsUse matching {chainID}-{revision} values
A concurrent test receives no relayer or a channel from another testPath creation panics or packets are sent on the wrong channelSize the pool and serialize channel discovery and filter updates
A new message type is not in the E2E codec or contains fields unknown to an old imageTransaction responses cannot decode or compatibility transactions failRegister the type and sanitize fields by release
Reflection is expected but the chain has no usable reflection pathgRPC query helpers cannot find a methodUse the release gate and retain the legacy path derivation
A routed IBC module is absent from module or genesis registrationTransactions, queries, or chain start fail even though the route existsTreat keeper, route, module, service, and genesis registration as one change
Middleware order differs between send and receive pathsPolicy state or token state is applied in the wrong orderPreserve reverse unwinding on receive
An upgrade handler does not match its store additions or legacy stateThe chain cannot start or in-flight packets are lostPair each plan with its handler, store loader, and migration checks
Diagnostics run after containers are removedThe failure has no chain or relayer evidenceRegister cleanup collection before container cleanup and keep containers when required

Key files

FileWhy to read it
e2e/README.mdExplains local, suite, CI, and compatibility test use at a system level
e2e/…/testconfig.goDefines how files and environment values become chains, images, relayers, and upgrades
e2e/…/testsuite.goShows shared chain setup, per-test paths, relayer assignment, packet flow, and cleanup boundaries
e2e/…/relayer.goShows the supported relayer choices and Hermes channel filtering
e2e/…/codec.goShows the cross-module message types available to transactions and queries
e2e/…/tx.goShows transaction broadcasting, compatibility sanitizing, governance, and transfer boundaries
e2e/…/grpc_query.goShows reflection-aware and legacy query access
e2e/…/diagnostics.goShows how failed chain and relayer state becomes useful evidence
e2e/…/base_test.goGives the standard transfer, acknowledgement, timeout, and refund flow
e2e/…/packet_forward_test.goShows multi-hop packet forwarding and unwind behavior
e2e/…/base_test.goShows remote account creation and execution through IBC
e2e/…/ibc_v2_test.goShows direct IBC v2 proof, receive, acknowledgement, and timeout flow
e2e/…/upgrade_test.goShows image replacement and packet checks across a normal upgrade
e2e/…/v10_legacy_pfm_upgrade_test.goShows preservation of legacy packet-forward state during upgrade
simapp/app.goDefines the executable chain, IBC module set, routers, services, order, and simulation manager
simapp/ante.goDefines transaction checks that run before message execution
simapp/…/root.goDefines the simd command surface and application lifecycle hooks
simapp/genesis.go and simapp/export.goDefine the application state boundary for initialization and export
simapp/upgrades.goDefines named upgrade handlers and store additions
simapp/go.mod and e2e/go.modDefine the local IBC links and dependency contract for the chain and suite