[High] SwapBlock unwinding lease_renew / lease_accept with standing cross-chain dependents produces unreplayable state
Report
Summary
SwapBlock can succeed while leaving lease-lifecycle dependents on other chains that reference the unwound block. The live ledger then holds a state its own validators reject on replay-from-chains: a single-node inconsistency that becomes a consensus split / permanent sync breakage for any node replaying from chains.
Two variants, both found by stateful fuzzing of Ledger.AddBlock (~29,700 ledger sequences, ~1.1M blocks applied, 0 panics):
- Variant A — unwinding a
lease_renewwhile a settle stands (37 instances). lease → accept → renew → settle, thenSwapBlockreplaces the renew with a fork send. Replay fails:lease_settle XE exceeds the 1 segment(s) applied here: expected 8572, got 19132. The settle's XE was computed for 2 segments; after the renew is unwound only 1 applies. - Variant B — unwinding a
lease_acceptwhile renewals stand (142 instances). lease → accept → renew, thenSwapBlockreplaces the accept. The lease is restored toCreatedbut the renewal remains on the consumer chain; replay fails:lease not yet accepted for renewal (state created): retry after accept.
Root cause
planSwap (core/ledger.go:3258-3320) only restricts the descendants on the same account to simple transfer types (filter at :3295-3300, error at :3299). It never checks for dependent lease-lifecycle blocks on other chains (accepts on the provider chain, renews/settles on the consumer chain). planCascade is only invoked when the swapped block itself is a BlockSend (:3313-3317). The undo logic (core/rollback.go:221-243) handles each lease block type in isolation: accept → priorLease(..., LeaseCreated) (:225-227), renew → priorLeasePopRenewal (:239-242).
Verification
Minimized reproducers (deterministic replay sequences):
- Variant A, 21 blocks: lease
204b9543cost 4275 → acceptcce66d6c→ renewa8a66fc2amt 4275 (swapped out) → settle5b5b2ef419132 XE; fork send4b326d66amt 417048. Replay 21/21 into a fresh ledger,SwapBlocksucceeds, replay-from-chains fails with the segment error atcore/ledger.go:2313. Supply post-swap conserved. - Variant B, 51 blocks: lease
97382e00→ accept37da19dd(swapped out) → renewcf7992b0amt 7750; fork551df0d2. Replay 51/51,SwapBlocksucceeds, replay-from-chains fails atcore/lease_renew.go:29. Supply post-swap conserved.
Note on related reports
Distinct from:
- #8 Finding 2 — unwinding the lease leaves the accept dangling (the reverse direction: swapped block is the lease, orphaned dependent is the accept).
- #652 — settled-lease escrow refund on unwind; a funds bug, not a replay failure.
- #183 — renew/settle and settle/force-settle concurrent arrival races with no merge rule; different trigger. Variants A/B are single-node swap unwinds after both blocks applied in order, no race needed.
- #525 / #43 / #608 — swaps refused/stalling on lease descendants; the opposite direction. Note #525's requested fix (loosening the descendant filter) would make A/B worse without a cross-chain dependency check.
- #533 — rolling back a cancel that won over an accept zeroes accept metadata; different trigger and failure mode (renewals are kept there, stranded here).
- #226 v1 — multi-step cascade stale reads; needs multi-lease unwinds, which
planSwaprefuses, so not producible viaSwapBlock.
Suggested fix
Refuse to swap a lease block that has live cross-chain dependents, or cascade the unwind to those dependents.
Thread
Thanks. This is the same finding as https://bounty.xe.network/XE-0022, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-16823 and says what differs; it is read like any other.