Introducing a new way to review your PRs.

Read the announcement

lfdt-ibc / ibc

The Inter-Blockchain Communication Protocol (IBC) is a neutral, open standard for secure cross-ledger interoperability

View on GitHub

18 documents · Updated Nov 23, 2026

docs / link-deployment-and-persistence

Deployment, storage, and operational state

Link manages a relayer installation through two durable state boundaries. Deployment records describe the chain-side IBC services that the installation can use. The store preserves relay requests, packet progress, and packet-clearing state so live relay work can continue after a restart. Together they connect installation setup with packet clearing and operator recovery. See IBC CLI relayer system for the wider system view.

Deployment lifecycle

The deployment lifecycle turns a chain description into a usable set of on-chain IBC services. A target-neutral deployment engine coordinates target-specific actions and records each result locally so later commands can find deployed addresses, compare them with live chain state, and create runtime relay configuration.

Deployment stages

Deployment uses ordered, repeat-safe stages with checks before each change. A rerun skips completed work only when the local record and the chain agree. If an on-chain result is missing from the record or the requested identity conflicts with the deployed service, the workflow stops instead of guessing which address or relationship to use.

The stages build the services that a relayer needs:

  1. Core routing stack: Creates the chain's IBC routing endpoint and its access control boundary.
  2. Batching endpoint: Adds a multicall endpoint governed by the core access manager so relayers can group supported calls.
  3. Light client: Creates and registers a client that tracks the counterparty chain. EVM targets support attestation and Besu client types. A Besu client starts from trusted state read from a sealed chain head.
  4. GMP application: Adds the cross-chain account application when the installation needs it.
  5. IFT token: Creates a token under the GMP application when IFT transfers are in use. An optional rate limit can be set or changed without redeploying the token.
  6. IFT bridge: Connects tokens on two chains through their shared client pair. The EVM send-call constructor is deployed once per chain unless an operator supplies an override.

The CLI can show the planned steps without sending transactions. A live run records each successful chain action only after it completes. The EVM target connects to the configured RPC endpoint and checks the RPC-reported chain ID before provisioning. A deployer key is required for changes, while read-only checks can use a driver without a signer. See Chain connectivity and network configuration for the network inputs used by deployment.

References: cli/…/deploy.go• L18-21 cli/…/deploy.go• L155-201 cli/…/steps.go• L18-69 cli/…/steps.go• L71-127 cli/…/steps.go• L130-199 cli/…/steps.go• L201-267 cli/…/steps.go• L269-353 cli/…/steps.go• L355-461 cli/…/driver.go• L50-95

Deployment manifests

A deployment manifest is the machine-written record for one chain. It identifies the chain and target and records the router, batching endpoint, clients, GMP application, tokens, bridges, and target-specific addresses that deployment produced. It also preserves the client parameters needed to tell a safe rerun from a request for a different deployment. It does not replace operator configuration or live chain state.

Link stores one JSON manifest per chain in the deployment manifest directory. A stage updates the manifest only after its chain action succeeds. A missing prerequisite blocks a dependent stage. An interrupted action that left an on-chain client or application without a manifest record requires reconciliation or a new identity instead of accepting the next command's parameters as proof of what was deployed.

The manifest keeps reusable deployment data separate from user configuration. It records a chain-level EVM send-call constructor and the constructor used by each bridge. Token identity uses symbol, name, and owner, while a bridge is tied to a token address and client ID. This lets a bridge step reuse known deployment data while still allowing an explicit override when an operator intends to change it. Manifest writes are atomic, so a failed write does not replace the last complete record.

References: cli/…/manifest.go• L17-31 cli/…/manifest.go• L34-49 cli/…/manifest.go• L90-145 cli/…/manifest.go• L167-191 cli/…/manifest.go• L217-257 cli/…/steps.go• L71-127 cli/…/steps.go• L130-199 cli/…/steps.go• L355-473

Deployment verification

Verification compares the recorded deployment with live chain state without changing the chain. It checks the connected chain identity and the presence and relationships of the router, clients, application, token code, bridge targets, and multicall authority.

The EVM checks distinguish an absent client, application, or bridge from a failed RPC call or a contract that is not the expected IBC contract. A client lookup that cannot prove a healthy router does not report an absent client. A provider that strips revert data therefore triggers a router health check before Link accepts the client as missing. Verification also checks that light clients point to the expected router and that Besu client prefixes match the counterparty router. This prevents verification from masking a bad address and prevents a later deployment step from spending gas against the wrong contract.

References: cli/…/deploy.go• L126-153 cli/…/deploy.go• L155-201 cli/…/driver.go• L63-95 cli/…/wiring.go• L70-99 cli/…/wiring.go• L157-296 cli/…/steps.go• L130-179 cli/…/steps.go• L201-243 cli/…/steps.go• L391-434

Relay configuration projection

The render-config operation turns two compatible deployment manifests into the chain and connection settings used by the relayer. Mutual client records define the cross-chain relationship. The resulting configuration carries the router addresses and attestor entries needed by runtime services.

The operation rejects manifests without a matching client pair. This prevents a relayer from starting with a one-sided relationship. Operators can review the rendered YAML or ask the command to merge it into the main configuration. A merge reports replacement conflicts and preserves settings outside the intended chain, connection, and attestor sections. The resulting connection is the hand-off to IBC CLI runtime and service interfaces.

References: cli/…/manifest.go• L40-49 cli/…/steps.go• L130-199 cli/…/steps.go• L507-547

Persistent relay state

The store is the database-facing record of relay work that must survive process restarts. A database-neutral store contract lets relay services use the meaning of requests, packets, clearing progress, and transactions without depending on one database product. Startup opens the store and gives it to the dispatcher, relay pipelines, and relayer service.

Relay request records

A relay request identifies a source-chain transaction that needs packet processing. The source chain and transaction hash form its identity, so repeated submissions for the same transaction do not create duplicate work. This makes API callers and event sources safe to retry.

The request is the entry point for relay work. Packet records then describe the individual packets from that request. These layers separate the question of whether a source transaction was requested from the question of how each packet progressed.

References: cli/…/store.go• L29-41 cli/…/store.go• L128-134 link/…/002-relay-requests.sql• L3-13 link/…/002-relay-requests.sql• L3-13 link/…/service.go• L200-218

Packet relay state

A packet record is the durable state machine for one packet. It ties the packet to its source and destination chains, sequence, client pair, source transaction, timeout, current relay status, and chain transactions for receive, acknowledgement, or timeout work.

Packet discovery can create a packet or refresh one that has not yet been selected. Dispatch then reads selected packets that are not terminal. The relay pipeline can therefore resume from the last durable point instead of starting again from the source event. A repeated discovery does not overwrite progress after a packet leaves the unselected state. See Relay execution pipeline for the work that consumes this state.

The broad status groups are:

State groupOperational meaning
SelectionThe packet is new or waiting to be chosen for relay.
Send and finalityA receive, acknowledgement, or timeout action is being sent or is waiting for chain finality.
Delivery checksLink checks whether the relevant packet result already exists on a chain.
CompletionThe packet completed with an acknowledgement, write-ack error, or timeout.
FailureThe relay attempt cannot continue without operator or system action.

The status catalog must cover every declared state. Otherwise filters or dispatch selection can make a packet invisible.

References: cli/…/store.go• L36-60 cli/…/store.go• L139-160 cli/…/store.go• L172-219 cli/…/relayer.sql• L5-36 cli/…/relayer.sql• L125-147 cli/…/relay_status_test.go• L13-34

Packet-clearing state

Packet clearing uses a separate durable record for each source chain and client. It stores the last sequence that a clearing pass probed and the set of sequences that remain unresolved. This lets the next pass continue from known progress while still revisiting packets that need attention.

The store reads a client with no clearing record as an initial state that starts at sequence one. Each clearing pass sends a delta rather than replacing the unresolved set. It can add sequences found on chain and resolve sequences that the pass checked. A sequence that the pass did not name remains stored, so an incomplete probe cannot erase work by omission.

When a clearing pass finishes, the watermark advances only forward. New unresolved sequences keep their first-seen time and the first height at which they were seen live. A resolve is accepted only when the probe reaches that saved height. This prevents a lagging node from making live commitments appear settled. The watermark and the unresolved changes form one store operation, so a failed update does not leave only part of the pass recorded.

The clearing state moves from the prior probe point to the next probe point while preserving unresolved work.

flowchart LR
    A[Read clearing state] --> B[Probe packet range]
    B --> C[Build clearing delta]
    C --> D[Add unresolved sequences]
    C --> E[Resolve safe sequences]
    D --> F[Advance watermark]
    E --> F
    F --> G[Next clearing pass]

References: cli/…/store.go• L56-70 cli/…/store.go• L100-117 cli/…/relayer.sql• L149-213 link/…/store_postgres.go• L307-381 link/…/store_sqlite.go• L352-426 link/…/store_test.go• L529-623

Transaction submission records

Transaction submission records link a relayer transaction to the packet work that caused it. They preserve the target chain, transaction kind, relayer address, submission and resolution times, cost, status, and execution error.

One submission can affect several packets, while one packet can pass through several submissions. A separate association keeps both views available: operators can follow packet progress and inspect the health of each chain-facing submission. See Attestation and transaction submission for the submission role at the chain boundary.

References: link/…/003-relayer-tx-submissions.sql• L3-19 link/…/004-packet-tx-submissions.sql• L3-10 link/…/003-relayer-tx-submissions.sql• L3-19 link/…/004-packet-tx-submissions.sql• L3-10

Database operations

Link supports SQLite and PostgreSQL through the same store contract. SQLite provides local or in-memory storage for an installation or a test process. PostgreSQL provides a separate network database with pooled connections for installations that need a database service. The PostgreSQL adapter checks reachability with a bounded ping and closes the pool if startup validation fails.

Store contract

The store contract covers repository actions, schema changes, transactions, reachability checks, and close behavior. A transaction groups related updates into one unit. If the work fails, the store rolls it back, so a status change and its chain transaction do not become partly recorded. Clearing uses the same boundary for its watermark and unresolved-sequence delta.

The store maps a missing row to one domain-level not-found error for both database types. A missing clearing row is an expected initial state, while other database errors remain visible to the caller. A broken database is therefore not treated as empty state.

References: cli/…/store.go• L19-29 cli/…/store.go• L31-84 cli/…/store.go• L100-117 cli/…/store.go• L308-317 link/…/store_postgres.go• L120-139 link/…/store_sqlite.go• L126-144

Schema migrations

Schema migrations create the durable model in a controlled order. The current model covers packets, relay requests, transaction submissions, links between packets and submissions, and packet-clearing progress. SQLite and PostgreSQL keep the same meaning while using database-specific syntax and types.

The CLI embeds the migration sources and selects the set for the configured database type. It records which migrations have been applied and when. Operators use ibc migrate up, ibc migrate down, and ibc migrate status to change or inspect the schema before the relayer starts.

References: cli/…/migrations.go• L29-47 cli/…/migrations.go• L101-169 cli/…/migrate.go• L14-37 cli/…/migrate.go• L39-91 link/…/store_sqlite.go• L110-124 link/…/store_postgres.go• L104-118 link/…/001-packets.sql• L3-36 link/…/002-relay-requests.sql• L3-16 link/…/003-relayer-tx-submissions.sql• L3-22

Installation state boundaries

Deployment manifests and database state support different recovery questions. A manifest says which chain-side addresses Link expects to use. The database says which relay work Link has seen, how far that work progressed, and which packet sequences clearing still needs to inspect. Neither record proves current chain state, so operators still need deployment verification and live chain queries.

At startup, the relayer opens the configured store before it builds the dispatcher and services. A working installation therefore needs valid chain configuration plus a reachable and migrated database. The attestor-only process has no store because it observes chain state without owning durable relay work. See Operational telemetry and observability for the signals that help operators watch these services.

References: link/…/bootstrap.go• L23-34 link/…/bootstrap.go• L36-45 link/…/bootstrap.go• L99-135 link/…/bootstrap.go• L138-182 link/…/config.go• L51-55 link/…/config.go• L138-155 cli/…/store.go• L56-70

Change checklist

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

  • Keep deployment manifest fields aligned with verification checks. A new address or relationship must be checked against live chain state.
  • Keep SQLite and PostgreSQL migrations equivalent in packet, request, submission, association, and clearing-state meaning.
  • Keep packet status transitions aligned with dispatch selection and the full status catalog. Non-terminal states must remain discoverable.
  • Keep packet upsert rules aligned with the boundary between undispatched packets and packets that already have relay progress.
  • Keep clearing updates aligned with the forward-only watermark, delta semantics, and unresolved sequence safety height. A pass must not erase work that it did not resolve.
  • Keep the store transaction boundary aligned with clearing updates. The watermark and unresolved changes must describe one probe result.
  • Keep manifest-to-config projection aligned with mutual client pairing. Changes to client identity or counterparty fields can create unusable connections.
  • Keep transaction submission links aligned with packet updates. A submission that affects several packets must remain visible from every affected packet.
  • Keep status discovery aligned with both configured chains and manifest files. An undeclared chain must remain visible as an explicit result.
  • Keep configuration merges limited to the intended chain, connection, and attestor sections. Existing settings outside those sections must survive --populate.
  • Keep the EVM driver's signer boundary aligned with every mutating deployment and wiring action. Read-only verification must remain usable without a deployer key.
  • Keep supported EVM client types aligned with the deployment inputs and verification paths. A client type accepted by configuration must remain deployable and checkable.
  • Keep rerun conflict checks aligned with the client fields that are fixed on-chain. A changed identity field must not silently rewrite the manifest or reuse the old client.
  • Keep bridge constructor override rules aligned with both the chain-level manifest record and the on-chain bridge. An explicit override must be able to trigger a deliberate bridge update.
  • Keep token identity rules aligned with manifest upserts. A symbol alone must not merge tokens that have different names or owners.
  • Keep manifest writes after successful chain actions. A failed action must not leave a record that makes an incomplete deployment look ready.

Important failure modes

TriggerConsequenceGuard
The RPC chain ID differs from the configured chain ID.Deployment targets the wrong network and stops before provisioning.The EVM deployment target validates the connected chain identity.
A mutating EVM action runs without a deployer signer.Provisioning or wiring cannot submit its transaction.Build a signed driver with a deployer key for changes.
A dependent deployment stage has no recorded prerequisite.Link cannot safely determine the router, application, or client for the next action.The stage fails and requires the earlier deployment stage.
An on-chain client or application exists but the manifest does not record it.A rerun cannot prove that the recorded inputs and address match.The precheck reports an interrupted deployment and requires reconciliation or a new identity.
A rerun changes a client field that is fixed by its constructor.Link cannot satisfy the new request by skipping or by changing only the manifest.The precheck reports the conflict and requires a new client ID.
A client lookup reaches a contract that is not an IBC router.Link may spend gas on a client deployment whose registration then fails.Verification probes the router and treats an unhealthy contract as an error.
An IFT bridge points to a different counterparty.A rerun could attach the local token to the wrong remote token.The precheck stops and requires a new client pair or an explicit correction.
The database schema is not migrated.Store queries fail or relay state remains incomplete.Check migration status and apply migrations before startup.
The database is unreachable during runtime.Relay requests, packet progress, and clearing state cannot be read or saved.Configure a reachable SQLite path or PostgreSQL service and use the store reachability check.
A relay status is missing from the status catalog.Packets in that status disappear from filtered views or dispatch selection.Keep the catalog complete and use the status completeness check.
A clearing pass replaces the unresolved set instead of applying its named delta.A sequence that the pass did not probe is lost from future clearing work.Apply additions and resolutions only for the sequences named by the pass.
A clearing pass tries to move the watermark backward.A slow pass can cause repeated scans or hide progress made by another pass.The store accepts a new watermark only when it is greater than the saved value.
A node reports an unresolved commitment as absent below its last safe height.Link may clear work while the node has not caught up.Keep the unresolved row until a probe reaches its recorded safety height.
Two manifests have no mutual client pair.Rendered relay configuration has no safe connection between the chains.render-config rejects the pair until both sides are deployed consistently.
A replacement conflict in rendered configuration is not reviewed.--populate overwrites existing chain, connection, or attestor settings.Review reported conflicts or use the printed YAML without populating the file.

Key files

FileWhy to read it
cli/…/steps.goShows the ordered deployment stages, rerun checks, dependency checks, and manifest updates.
cli/…/deploy.goDefines the target-neutral deployment boundary, supported client types, and chain-side service contracts.
cli/…/driver.goShows EVM chain validation, signer boundaries, contract provisioning, and transaction finality handling.
cli/…/wiring.goShows how deployed clients, applications, bridges, and permissions are registered and checked.
cli/…/manifest.goDefines the durable record of chain-side deployment state and its identity rules.
cli/…/deploy.goShows the operator flows for deployment, verification, and configuration projection.
cli/…/store.goDefines the database-neutral store contract, packet relay state, and clearing delta model.
cli/…/relayer.sqlDefines packet discovery, dispatch selection, packet transaction updates, and packet-clearing safety rules.
link/…/store_postgres.goShows PostgreSQL connection health, transaction handling, packet persistence, and clearing-state persistence.
link/…/store_sqlite.goShows SQLite file and in-memory storage, transaction handling, packet persistence, and clearing-state persistence.
cli/…/migrations.goConnects the store to embedded schema migrations and reports migration state.
link/…/bootstrap.goShows how persistent state enters the running relayer.
cli/…/migrate.goShows the operator flow for applying and inspecting schema changes.