Cross-Shard Atomic Commit
Two-phase commit across chain-VM shards anchored by a parent-L1 QuasarCert. Per-shard waves prepare, a coordinator collects prepare-acks, the parent-L1 wave commits all shards atomically. All shards commit or none.
Abstract
State organised into chain-VM shards running on a parent L1 has no intrinsic atomicity across shards: the wave commits at each shard are independent under LP-0310 / LP-0150. This LP supplies that atomicity.
The mechanism is cross-shard 2PC via a parent-L1 QuasarCert. A coordinator (one of the parent L1's validators, selected deterministically per cross-shard tx group) dispatches per-shard portions to shard executors, collects prepare-acks (LP-0150 Phase 4 staged-prepare), and when all shards have prepared, submits a cross-shard commit transaction to the parent L1. The parent L1's next wave (LP-0310) includes that transaction; the wave's cert is the cross-shard cert. Once the parent L1's cert finalises, every shard's prepared overlay is committed atomically.
If any shard refuses to prepare (coordinator timeout, validity failure,
slashable equivocation), the coordinator submits a cross-shard abort transaction
instead; every prepared shard unwinds its staged overlay via LP-4805
txn.Discard(). ALL shards commit OR NONE — the LP-4805 atomic-unwind
contract makes this O(1) at each shard.
The latency dividend: per-shard waves continue at the LP-0310 cadence (~100 ms LAN); the cross-shard cert adds one parent-L1 wave (~100 ms LAN) plus the cert-mode timing (~5 ms at PQ-strict). Total cross-shard latency: ~200 ms at LAN scale at PQ-strict. The throughput dividend: each shard's waves run independently except for the cross-shard transactions, which by construction are a minority of the workload (in exchange-style traffic: ~5%). The 95% intra-shard waves commit at the LP-0150 single-shard rate; the 5% cross-shard waves pay the 2PC tax.
Why the parent cert, not a sidechain mechanism
A naive cross-shard atomicity mechanism uses a sidechain or a relay validator set. This LP instead uses the parent L1's existing QuasarCert as the atomic-commit anchor. The parent L1 already has a validator set; the chain-VMs inherit the parent's security automatically. The parent L1's cert at its chosen mode is the strongest cryptographic statement available on the network — using it for cross-shard commit means cross-shard finality is exactly as strong as the parent L1's finality at that mode.
No new validator set. No new bridge contract. No new dispute window. The cert that the parent L1 already publishes per wave serves as the cross-shard commit anchor. The shards prepare; the parent L1 commits; the cert covers the commit.
Algorithm
Step 0 — coordinator selection
A cross-shard tx group T = {T_1, ..., T_K} where each T_j is the
per-shard portion targeting shard s_j. The coordinator is a parent-L1
validator selected deterministically:
coordinator(T) = parent_L1.validators[ hash(T.id) mod N ]
where T.id = sha256(canonical_bytes(T)). The selection is a pure
function of the tx group; every shard executor agrees on the
coordinator without coordination.
Step 1 — dispatch
The coordinator gossips T via the parent L1's LP-0410 DHT, schema 0xE3
(CrossShardDispatch — see Wire schemas below). Each shard s_j whose
NodeID is subscribed to the parent L1 receives T and dispatches T_j
into its local mempool.
Step 2 — per-shard prepare
Each shard s_j executes T_j under LP-0310 / LP-0150 normally:
T_jenters the shard's LP-0300 DAG mempool.- The shard's LP-0310 wave commits a wave containing
T_j. - LP-0150 Phase 4 detects that
T_jis cross-shard (T_j.txEnvelope.kind == cross_shard) and stages the overlay instead of committing. - The shard publishes a prepare-ack: schema 0xE4 (
CrossShardPrepareAck) containing(T.id, s_j, T_j.state_diff_hash, shard_wave_cert).
The shard_wave_cert is the per-shard cert at the shard's
configured mode — proof that the shard committed to executing T_j at
the shard's per-wave consensus. The cert leg presence/absence governs the
strength.
Step 3 — coordinator collect
The coordinator subscribes to prepare-acks on the parent L1's gossip layer. It collects acks until either:
- All K acks arrive within
prepare_timeout_ms→ emit cross-shard commit transaction (Step 4). - Any shard times out or refuses (returns refuse-ack schema 0xE5) → emit cross-shard abort transaction (Step 4').
prepare_timeout_ms defaults to 5× the slowest shard's wave cadence
(typical: 500 ms LAN, 2000 ms WAN). The timeout is conservative — under
healthy operation, all acks arrive within 1× wave cadence.
Step 4 — cross-shard commit transaction at parent L1
The coordinator submits to the parent L1's LP-0300 mempool:
CrossShardCommit {
group_id: [32]byte T.id
shards: []ShardCommit // per-shard: (chain_id, state_diff_hash, wave_cert)
coordinator: NodeID
coord_sig: []byte // BLS or PQ per parent L1 cert mode
}
The parent L1's next LP-0310 wave includes this transaction. The wave's cert covers the cross-shard commit. Once the parent L1's cert finalises:
- Each shard observes the parent L1's cert (gossip schema 0xE6
CrossShardCommitNotifyfrom any parent-L1 validator). - Each shard verifies the cert covers
T.idand that the cert's leg composition satisfies the shard's cert-mode policy. - Each shard applies its staged overlay via LP-4805 atomic commit. Done.
Step 4' — cross-shard abort transaction at parent L1
If any shard refused or timed out, the coordinator submits:
CrossShardAbort {
group_id: [32]byte T.id
reason: enum {timeout, shard_refused, coordinator_replaced}
coordinator: NodeID
coord_sig: []byte
}
The parent L1's next wave includes this transaction; the cert covers the abort;
each shard observes via gossip and unwinds its staged overlay via LP-4805
txn.Discard(). The cross-shard tx group is dropped; per-shard waves
move forward independently from the next round.
Step 5 — atomicity invariant
The cross-shard commit/abort cert is the single point at which all shards observe the same outcome. Before the parent-L1 cert: each shard holds a staged overlay; no observable state change. After the parent-L1 cert: every shard has either committed (commit path) or unwound (abort path); no half-state.
Concretely: any external observer (light client, indexer, bridge)
queries the parent L1 first to learn T.id's outcome. If the parent L1
has finalised a CrossShardCommit(T.id) cert, every shard MUST present
the committed state for T_j to the observer (or the shard is byzantine
and slashed at the parent L1). If the parent L1 has finalised a
CrossShardAbort(T.id) cert, every shard MUST present pre-T_j state.
Wire schemas
This LP introduces six ZAP wire schemas at 0xE2..0xE7, registered in the
LP-0230 master registry (which is normative for the allocation; this table is
informative).
| Schema | Hex | Purpose | Fields |
|---|---|---|---|
| CrossShardTxGroup | 0xE2 | the tx group bytes (canonical) | group_id [32]byte, parts []CrossShardPart where each part = (chain_id uint32, tx_bytes []byte) |
| CrossShardDispatch | 0xE3 | coordinator → shards via DHT (Step 1) | group_id [32]byte, coordinator NodeID, tx_group_bytes []byte (Schema 0xE2 payload) |
| CrossShardPrepareAck | 0xE4 | shard → coordinator (Step 2) | group_id [32]byte, chain_id uint32, state_diff_hash [32]byte, wave_cert []byte (LP-0117 QuorumCert) |
| CrossShardRefuseAck | 0xE5 | shard → coordinator (Step 2 refusal) | group_id [32]byte, chain_id uint32, reason enum |
| CrossShardCommitNotify | 0xE6 | parent L1 → shards (Step 4 commit) | group_id [32]byte, parent_cert []byte (QuorumCert covering CrossShardCommit) |
| CrossShardAbortNotify | 0xE7 | parent L1 → shards (Step 4' abort) | group_id [32]byte, parent_cert []byte (QuorumCert covering CrossShardAbort) |
Schemas 0xE0..0xE1 are LP-0300 (DAG header/body).
Latency
LAN, PQ-strict mode at every layer, 40-validator parent L1 with 4-shard fan-out:
| Event | Time (cumulative) | Source |
|---|---|---|
| Cross-shard tx submitted to coordinator | 0 ms | client |
| Coordinator dispatches to shards via DHT | ~10 ms | LP-0410 DHT lookup + gossip |
| Per-shard mempool admit | ~25 ms | LP-0300 §Tx receive |
Per-shard wave commits T_j with prepare-staged | ~120 ms | LP-0310 §Latency to PQ-strict |
| Prepare-acks arrive at coordinator | ~130 ms | + 10 ms gossip |
| Coordinator submits CrossShardCommit to parent L1 | ~131 ms | one mempool insert |
| Parent L1 wave commits CrossShardCommit | ~251 ms | + LP-0310 wave latency at PQ-strict |
| Shards observe commit-notify and apply staged overlay | ~260 ms | + 10 ms gossip + LP-4805 O(1) commit |
End-to-end cross-shard finality at PQ-strict LAN: ~260 ms.
WAN, PQ-strict mode: ~600–800 ms (RTT-dominated; LP-0310 latency triples under WAN).
PQ-heavy mode: add ~150 ms to each cert step; total ~400 ms LAN, ~1000 ms WAN.
The dominant cost is the two sequential LP-0310 wave commits — per-shard prepare wave plus parent-L1 commit wave. Optimisations:
- Speculative commit at PQ-fast. If the shard cert is PQ-fast and the parent-L1 cert is also PQ-fast, both certs land within 5 ms LAN; total cross-shard latency drops to ~150 ms.
- Pipelined cross-shard groups. Multiple in-flight cross-shard groups overlap their wave commits via LP-0160 pipelining; aggregate cross-shard throughput remains at the parent-L1 wave rate (~10 waves/sec × ~100 cross-shard txs/wave = 1000 cross-shard txs/sec floor).
Atomicity proof sketch
The atomicity claim is: for any cross-shard tx group T, after the
parent-L1 cert decisively covers either CrossShardCommit(T.id) or
CrossShardAbort(T.id), every shard s_j ∈ T's shards has either
committed T_j or unwound T_j, and these outcomes match.
Argument:
- Each shard's LP-0150 Phase 4 staging is local — the staged overlay exists only in the shard's runtime, content-addressed by the per-shard wave cert.
- The shard's wave cert (Step 2 ack) commits the shard to executing
T_jat the shard's per-wave finality. If the shard later refuses to apply the staged overlay on Step 4 commit-notify, the shard is byzantine and slashable on the parent L1 (Step 4 commit-notify is the cryptographic instruction; refusal contradicts the shard's own wave cert). - The parent-L1 cert is either commit or abort, never both — wave
ordering at the parent L1 is total (LP-0310), so the
CrossShardCommit(T.id)orCrossShardAbort(T.id)transaction commits at exactly one parent-L1 wave height with a single cert. - Therefore: the parent-L1 cert is the unique decision oracle. Every
shard's local outcome is a deterministic function of the parent-L1
cert (
commit→ apply staged overlay;abort→ LP-4805 unwind). A shard that diverges is byzantine and slashable.
The atomicity is eventually-cryptographic: there is a transient
window between Step 2 prepare and Step 4 commit during which a shard's
staged overlay exists but is not yet committed. During that window, the
shard's external API MUST NOT expose the staged state — queries return
pre-T_j state. This is the standard 2PC invisibility property; LP-0150's
Phase 4 staging guarantees it by construction.
Composition with cert tier degradation
LP-4805 §"Cert leg degradation tiers" allows a QuasarCert to be observable at a lower mode than the chain's configured target, when slower legs fail to aggregate within the timeout. The cert is monotone: once a leg arrives, the cert is observable at the higher tier; legs never retract.
Cross-shard interaction: the parent-L1 cross-shard commit cert is observable at progressively higher modes as its legs arrive. A relying party (a shard executor watching for commit-notify) applies its own cert-mode policy against the parent-L1 cert. The shard does not need to wait for the parent L1 to reach the parent L1's configured target mode; it only needs to wait for its own configured mode.
Worked example: parent L1 configured PQ-heavy, shards A and B
configured PQ-strict.
| t (ms) | Event | Parent-L1 cert observable at | Shard A acts? | Shard B acts? |
|---|---|---|---|---|
| 0 | Cross-shard commit tx in parent-L1 wave | n/a | no | no |
| 100 | Parent-L1 BLS leg aggregates | PQ-off | no (A wants ≥ PQ-strict) | no |
| 105 | Parent-L1 Corona leg aggregates | PQ-fast | no | no |
| 110 | Parent-L1 Pulsar leg aggregates | PQ-strict | yes — A commits staged overlay | yes — B commits staged overlay |
| 155 | Parent-L1 Magnetar leg aggregates | PQ-heavy | (already committed at 110) | (already committed at 110) |
The shards commit at PQ-strict observability (their configured mode), not at the parent L1's target PQ-heavy. The parent L1 still waits for Magnetar before finalising at its target — but the shards do not.
Monotonic upgrade across shards. Different shards may be configured at different modes. The parent-L1 cert observability is monotonic per LP-4805; therefore the order of cross-shard commit observations across shards is a function only of each shard's individual mode threshold — not of any cross-shard coordination. A shard at PQ-fast acts at ~105 ms; a shard at PQ-strict acts at ~110 ms; a shard at PQ-heavy acts at ~155 ms. All three are committing the same cross-shard tx group; they just realise it at the time their own mode is satisfied.
Architectural decision: shards may commit early at their individual mode without waiting for the parent L1's target mode. This follows from LP-4805's monotonic-upgrade invariant — the parent-L1 cert is the same struct at every observation point; only the leg-set membership grows. A shard acting on an early observation cannot be wrong, because the cert at the lower mode is a strict subset of the cert at the higher mode. If shard A acts at PQ-strict observability and the parent L1 ultimately fails to reach its target PQ-heavy (some leg fails to aggregate within its timeout), the shard's commit is still valid — the cert at PQ-strict is a valid cert at PQ-strict. The parent L1 has not retracted anything.
This means: the cross-shard 2PC commit point is the minimum-mode-observability of the parent-L1 cert across all participating shards, not the parent L1's configured target. Latency is bounded by the slowest-configured shard, not by the parent L1's configured target.
Composition with LP-0150
LP-0150 Phase 4 has two modes (local-commit / staged-prepare). This LP formalises the staged-prepare mode:
| Phase 4 mode | Trigger | Action | Cert source |
|---|---|---|---|
| Local-commit | wave contains no cross-shard txs | apply overlay to ZapDB immediately | per-shard LP-0310 wave cert |
| Staged-prepare | wave contains 1+ cross-shard txs | stage overlay; emit CrossShardPrepareAck per cross-shard tx; intra-shard txs in the same wave still local-commit | per-shard wave cert covers the intra-shard txs; parent-L1 cert covers the cross-shard finality |
The same wave can contain a mix of intra-shard and cross-shard transactions. The
intra-shard ones commit immediately under local-commit; the cross-shard
portions stage and wait. This is the canonical STM × 2PC
composition — no special transaction type at the LP-0150 layer beyond the
cross_shard envelope kind.
Composition with LP-0160 pipelining
LP-0160 pipelines block (wave) production across rounds. Cross-shard cert pipelining is the same pattern at the parent-L1 wave layer:
| Parent-L1 wave | t=T (LAN) | t=T+100ms | t=T+200ms |
|---|---|---|---|
| W_k contains CrossShardCommit(T_A) | committed | (settled) | (settled) |
| W_{k+1} contains CrossShardCommit(T_B) | preparing | committed | (settled) |
| W_{k+2} contains CrossShardCommit(T_C) | (still collecting prepare-acks) | preparing | committed |
Three cross-shard tx groups, three overlapping parent-L1 wave commits.
Aggregate cross-shard throughput at LAN scale ≈ parent-L1 wave rate ×
(parent-L1 wave capacity / CrossShardCommit tx size) — ~1000 cross-shard
groups/sec at PQ-strict, ~500 at PQ-heavy.
Failure modes
| Failure | Trigger | Effect | Recovery |
|---|---|---|---|
| Coordinator offline | crash, partition | prepare-acks accumulate but no commit tx submitted | shards' staged overlays time out via local prepare_timeout_ms × 2 watchdog; LP-4805 txn.Discard() unwinds; tx group is dropped; client re-submits with a new group_id |
| One shard refuses prepare | validity failure, slashable equivocation, byzantine | coordinator receives CrossShardRefuseAck; aborts via Step 4' | every prepared shard unwinds; tx group dropped |
| Coordinator equivocates (submits both commit and abort) | byzantine | parent-L1 LP-0310 wave ordering admits only one (first-seen); LP-0300's equivocation gate suppresses the second at the parent-L1 mempool; coordinator slashed | atomicity preserved by parent-L1 wave ordering |
| Parent L1 itself partitions before committing | infrastructure | shards' staged overlays time out; LP-4805 unwind; client re-submits when partition heals | standard partition recovery |
| Shard commits before parent L1 cert finalises at shard's mode | bug | observable as a stale read; shard's external API serves un-committed state | bug — the shard's wave-cert prepare commits the shard to not exposing staged state; the bug is in the shard's executor, not in this protocol |
| Cross-shard tx is too large for one wave | >1 MiB cross-shard tx group | LP-0410 chunked DHT fetch handles arbitrary-size tx groups; coordinator dispatches (group_id, contentHash) instead of inline bytes | n/a; works by construction |
| Shard A configured PQ-fast, shard B configured PQ-heavy; B is much slower | configuration | B commits at ~155 ms after A's ~105 ms commit | acceptable — atomicity holds (per §"Composition with cert tier degradation"); A and B realise the same commit at different wall-clock times |
Cross-references
- LP-0117 — Consensus finality signed message and quorum certificate (the cert that anchors the cross-shard commit)
- LP-4805 — ZAP pipelining and atomic unwind (the atomic-commit and monotonic cert-tier-upgrade contracts cross-shard 2PC depends on)
- LP-0230 — Schema registry (normative owner of
0xE2..0xE7) - LP-0300 — DAG mempool (per-shard mempool that receives the cross-shard parts; equivocation gate)
- LP-0310 — DAG wave ordering (per-shard and parent-L1 wave commits)
- LP-0150 — Block-STM wave execution (per-shard staged-prepare in Phase 4)
- LP-0160 — Pipelined Quasar (parent-L1 wave pipelining for concurrent cross-shard groups)
- LP-0410 — ZAP P2P (DHT layer that dispatches large tx groups)
- LP-0530 — Rollup-to-rollup atomic composition (the same pattern applied one tier up)
Copyright
Copyright and related rights waived via CC0.