Skip to content

Relayers and cross-chain calls

How a Move call requested on the source chain is carried out on the destination chain, in two phases or three, and how static mode differs from bridge mode.

You will learn / You need

You will learn: the path of one request, what the 2-phase and 3-phase protocols add, and what changes between static and bridge mode. You need: The ledger in five minutes.

The path of a request

Two chains cannot call each other. A relayer is an off-chain program that watches one chain and submits a transaction on the other. Here it is two binaries:

  1. A caller on the source chain calls bridge_source::request. The module emits a CrossChainRequest event.
  2. The listener (event_listener) polls the source node, finds new events and POSTs each one to the handler. With the committee on, it posts to the committee instead.
  3. The handler (event_handler) builds the destination transaction and submits it.
  4. On the destination chain the transaction runs the requested Move call.

The relayer is the only link between the chains. Nothing on the destination chain reads the source chain.

Two phases

sequenceDiagram
    participant U as Caller
    participant S as Source chain
    participant L as Listener
    participant H as Handler
    participant D as Destination chain
    U->>S: bridge_source::request
    S-->>L: CrossChainRequest event
    L->>H: POST /api/handle_event
    H->>D: transaction with the call
    D-->>H: effects

Three phases

BRIDGE_PROTOCOL_PHASES=3 adds an acknowledgement. After the destination transaction succeeds, the handler reports back to the source chain.

sequenceDiagram
    participant U as Caller
    participant S as Source chain
    participant L as Listener
    participant H as Handler
    participant D as Destination chain
    U->>S: bridge_source::request
    S-->>L: CrossChainRequest event
    L->>H: POST /api/handle_event
    H->>D: transaction with the call
    D-->>H: effects (digest)
    H->>S: acknowledge
    S-->>S: RequestAcknowledged event

The acknowledgement is a claim by the relayer, not a proof: nothing on the source chain verifies the destination state (see the doc comment on RequestAcknowledged in bridge_source.move). It gives the source chain a record of round-trip completion. It requires bridge mode. See Three phases and the AA acknowledgement.

Static mode and bridge mode

EVENT_HANDLER_MODE selects what the handler does with an event. It defaults to static; .env_sample ships bridge.

static (Track B) bridge (Track C)
Who signs the destination transaction The relayer key, as an ordinary keypair transaction The BridgeAA account is the sender; the relayer key only signs a CrossChainIntent (a signed description of the call to run)
What is executed The fixed call in EVENT_HANDLER_TARGET (with EVENT_HANDLER_ARGS_JSON) The call described by the event
What the event body is used for Nothing: it is ignored. The event is a trigger Everything: the event's fields become the intent and the call
Authorisation on chain Whatever the target call checks for its sender The account's ACL (access control list of allowed senders), the signature and the PTB match (details)
3-phase acknowledgement Not available Optional

Static mode exists to measure latency with a fixed call. Bridge mode is the real cross-chain path.

Replay protection is off-chain

The destination chain does not know a request was already executed. The listener is what stops a repeat: it records the ID of every event it has forwarded successfully in data/processed_events.json and skips those. An event is recorded only after the handler accepted it, so a failed forward is retried. The set is bounded: it keeps the newest 10,000 IDs by default (EVENT_LISTENER_DEDUPE_CAPACITY) and evicts the oldest first. It also advances its cursor (data/cursor.json) only past a page whose events all reached the handler.

On a normal start the listener deletes that state and begins at the chain tip (EVENT_LISTENER_RESET_CURSOR defaults to true). Events emitted while it was down are therefore not delivered. Set the variable to false to resume from the saved cursor.

Next

Account abstraction and BridgeAA explains what the destination account checks before it executes.