Three phases and the AA acknowledgement¶
With BRIDGE_PROTOCOL_PHASES=3 the relayer reports back to the source
chain after the destination call succeeds. This page shows what the extra phase costs, how the
acknowledgement is signed, and how to route it through a second BridgeAA.
You will learn / You need
You will learn: the difference between two and three phases, the two ways to sign the
acknowledgement (eoa and aa), the setup of the second account, and the startup checks of the
ack leg.
You need: a working bridge setup, gas on the source chain, and the sequence
diagrams in Relayers and cross-chain calls.
Two phases or three¶
Phase 1 is the request on the source chain, phase 2 the execution on the destination chain, phase 3
the acknowledgement back on the source chain. Three phases require EVENT_HANDLER_MODE=bridge:
BRIDGE_PROTOCOL_PHASES=3 with static mode is a startup error, and any value other than 2 or 3 is
too.
sequenceDiagram
participant S as Source chain
participant H as Handler
participant D as Destination chain
Note over S,D: Two phases
S-->>H: CrossChainRequest
H->>D: execute the call
D-->>H: effects
Note over S,D: Three phases add
H->>S: acknowledge(request_id, digest)
S-->>S: RequestAcknowledged event
The acknowledgement is a claim by the relayer, not a proof: nothing on the source chain verifies the destination state. It gives the source chain a record that the round trip completed. With the committee on, it is the executor, not the committee, that sends it.
One acknowledgement transaction covers a whole batch. Every event in a destination batch shares one
destination digest, so the acks carry one shared digest input and only the request_id differs. The
ack runs on the network that EVENT_HANDLER_NETWORK is not: the handler flips between devnet and
testnet.
EOA or AA acknowledgement¶
By default the acknowledgement is an ordinary transaction from the relayer's key.
BRIDGE_ACK_SIGNER=aa routes it through a second BridgeAA on the source chain instead, so both legs
share one authorisation model. It calls bridge_source::acknowledge_pure, because the authenticator
only matches calls whose arguments are all pure.
eoa (default) |
aa |
|
|---|---|---|
| Sender of the ack transaction | The relayer address | The second BridgeAA on the source chain |
| Move function | bridge_source::acknowledge (takes &SourceConfig) |
bridge_source::acknowledge_pure (all pure) |
| What the relayer key signs | The transaction | A CrossChainIntent only |
| Required variables | EVENT_LISTENER_PACKAGE_ID, BRIDGE_SOURCE_CONFIG_ID |
EVENT_LISTENER_PACKAGE_ID, BRIDGE_ACK_AA_PACKAGE_ID, BRIDGE_ACK_AA_ACCOUNT_ID |
| Who owns the gas coins | The relayer, on the source network | The second account, on the source network |
| Consensus | The ack touches a frozen object and pure arguments, so it stays on the consensus-free fast path | Authenticated by a shared account object, so it goes through consensus like the destination leg |
sequenceDiagram
participant H as Handler
participant S as Source chain
Note over H,S: eoa
H->>S: transaction signed by the relayer key<br/>acknowledge(config, request_id, digest)
Note over H,S: aa
H->>S: transaction sent by the second BridgeAA<br/>authenticator checks the signed intent<br/>acknowledge_pure(chain id, request_id, digest)
In aa mode the intent's chain ids are the mirror image of the destination leg's. Its
source_chain_id is the destination chain, its source_sender is the destination BridgeAA (the
identity that executed the call), and its target_chain_id is the source chain. The digest is passed
as its ASCII bytes, so rows from both modes stay comparable.
Setting up the second account¶
- Publish
bridge_abstract_accounton the source chain (BRIDGE_ACK_AA_PACKAGE_ID). - Run
bridge_aa_initwith the chain ids swapped (BRIDGE_SOURCE_CHAIN_ID=2,BRIDGE_TARGET_CHAIN_ID=1),BRIDGE_ACL_SOURCE_SENDERS=<BRIDGE_AA_ACCOUNT_ID>andEVENT_HANDLER_NETWORK=testnet. The single extra ACL entry names the destination account as the originator. - Fund the new account on the source network.
- Set
BRIDGE_ACK_AA_ACCOUNT_IDandBRIDGE_ACK_SIGNER=aa, then redeploy. Theack_signercolumn inbridge_results.csvrecords which path each row used.
What the handler checks¶
build_ack_config() in stealth_name_service/backend/testing_backend/src/bin/event_handler.rs runs
only when BRIDGE_PROTOCOL_PHASES=3.
- The source package. It reads
EVENT_LISTENER_PACKAGE_IDas thebridge_sourcepackage, because the listener already watches that package forCrossChainRequest. It reads it only here, so in three-phase bridge mode it must be set; in other modes the handler does not read it. eoa:BRIDGE_SOURCE_CONFIG_IDmust be a valid object id, and theSourceConfigis looked up at startup.aa: the same three prechecks as the destination leg. Each failure is a startup error:
| Message starts with | Meaning and fix |
|---|---|
Source-chain BridgeAA … is bound to chain_id …, but acks target chain … |
The second account's chain_id is not BRIDGE_SOURCE_CHAIN_ID. Recreate it with BRIDGE_TARGET_CHAIN_ID set to the source chain id, on the source network. |
Source-chain BridgeAA … has no ACL entry for (source_chain_id=…, source_sender=…) |
The destination account is not in the second account's ACL. Seed it with BRIDGE_ACL_SOURCE_SENDERS=<destination BridgeAA> when running bridge_aa_init against the source network. |
… holds no gas coins on … for acknowledgements |
The sender of the ack has no coins on the source network: the relayer in eoa mode, the second account in aa mode. |
Unsupported BRIDGE_ACK_SIGNER '…'; expected 'eoa' or 'aa' |
Typo in the variable. |
The acknowledgement gas pool¶
The ack leg is one transaction per batch, like the destination leg, so it needs its own pool on the
source chain, sized by the same rules as in Gas pool sizing. Its budget is
BRIDGE_ACK_GAS_BUDGET times the requests in the batch (at most BATCH_SIZE), and BRIDGE_ACK_GAS_BUDGET defaults to 2000000. Do not go below
that: one ack costs more than 1000000, and a smaller budget aborts during execution with
InsufficientGas and still burns the budget. The handler logs this as ACK GAS and keeps the coin.
After retiring underfunded coins, the handler checks the ack pool once:
| Log line contains | Meaning |
|---|---|
ACK GAS: BRIDGE_PROTOCOL_PHASES=3 but no acknowledgement gas coin can fund a batch |
Every acknowledgement will fail and the ack columns of the CSV stay empty. Fund or merge coins so each holds at least BRIDGE_ACK_GAS_BUDGET x BATCH_SIZE. |
ACK GAS: fewer usable acknowledgement coins than EVENT_HANDLER_CONCURRENCY |
Acks queue for a coin and phase-3 latency includes that wait. |
Check it worked¶
- The handler log shows
ack signer: relayer key (eoa)orack signer: source-chain BridgeAA (aa), thenthird phase (acknowledge) ready. - Rows of
bridge_results.csvhaveack_tx_digest,total_3phase_time_secondsandack_signerset (columns). - A
RequestAcknowledgedevent for therequest_idappears on the source chain.
Next¶
- Gas pool sizing: the coin rules both legs share.
- Adding the consensus committee: put an agreement step in front of the executor.