KeystoneRouter coordinates cross-chain settlements. One router is deployed per chain next to that chain’s KeystoneSettlement. The router holds no funds, no recipients, and no copy of the settlement state machine: on the coordinator chain it holds only the coordination record and a single irrevocable release-or-abort decision; on a participant chain it only reads its local settlement’s status and drives the two router-only settlement entrypoints (executeFromRouter / abortFromRouter).
The coordinator role is per settlement, not per chain: any chain’s router can act as the coordinator for a given settlement, with the other involved chains as participants. The coordinator’s own leg is read live from its local settlement and is never messaged.
Message types
The router is a LayerZero V2 OApp carrying three single-id messages:
Receive gas is pinned contract-side via governance-set enforced options per
(chain, message type) pair, so a permissionless relayer never supplies raw options bytes.
The relay pattern: no LayerZero send ever runs inside a message receive or a settlement-state transaction. Receiving a message makes at most one settlement call and zero sends. Sends happen only through the permissionless, payable relay calls (
sendConfirm / relayDecision) with the LayerZero fee supplied as msg.value.Cross-chain settlement flow
- Register. An operator calls
registerCoordinationon the coordinator chain’s router with the remote participant EIDs and the settlement’s deadlines. A coordination can never be re-registered; the participant set and deadlines are immutable. The structural floorabortDeadline >= timeoutAt + minDecisionWindowis enforced, and an empty participant set is rejected. - Prepare. Each chain’s settlement is funded and flips to
Prepared(see remote mode). - Confirm. On each participant chain, anyone calls
sendConfirm(settlementId, coordinatorEid)- it reverts unless the local settlement is actuallyPrepared, and the message carries the localtimeoutAt/abortDeadlineso the coordinator can cross-check them. A confirmation whose deadlines disagree with the coordination record records an Abort instead of counting. - Decide. When every remote participant has confirmed, the coordinator’s own leg is
Prepared, the time is strictly beforereleaseCutoff, and no decision exists yet, the router records the irrevocable Release decision. Evaluation runs inline on each confirmation and can be re-triggered permissionlessly withpokeDecision. - Relay. Anyone calls
relayDecision(settlementId, dstEid)per participant chain to transmit the recorded decision (the relayer pays the LayerZero fee and cannot influence the decision), andapplyLocalDecision(settlementId)for the coordinator chain’s own leg. ReceivingRELEASEcallsexecuteFromRouter;ABORTcallsabortFromRouter. Re-delivery is harmless - the settlement guards its own state.
Abort paths
A recorded decision is single-write: onceRelease exists it can never flip to Abort, and vice versa.
- Operator abort - an operator can record
Abortat any time before a Release exists (e.g. a participant chain will never fund, or compliance regressed afterPrepared). - Permissionless abort - once the release window has closed (
block.timestamp >= releaseCutoff) and the confirmation set is still incomplete, anyone can recordAbort. This keeps refunds live even if the KeyStone backend is down. - Deadline-mismatch abort - a
CONFIRMEDmessage whose deadlines disagree with the coordination record recordsAbortautomatically.
Timing windows
The release window (before
abortDeadline, on the settlement) and the timeout window (at/after abortDeadline) are disjoint, so no instant has both release and refund live on any chain. Current testnet deployments use minDecisionWindow = 3600 seconds and releaseMargin = 900 seconds - see testnet addresses.
Functions
getCoordination(settlementId) (record incl. confirmedCount, participantCount, decision), getParticipantEids(settlementId), isConfirmed(settlementId, eid), releaseCutoff(settlementId).