{"id":"XE-16823","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"661","source_url":"https://github.com/xeprotocol/xe/issues/661","reporter_id":2920,"title":"[High] SwapBlock unwinding lease_renew / lease_accept with standing cross-chain dependents produces unreplayable state","area":"consensus","claimed_tier":"high","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0022","tracked":true,"internal_ref":"#1090","internal_url":"https://github.com/xeprotocol/core/issues/1090","status":"closed","closed_reason":"duplicate","github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T06:24:29.366571+00:00","updated_at":"2026-11-22T23:26:16.104779+00:00","source_created_at":"2026-11-17T06:23:47+00:00","told_at":"2026-11-22T23:26:16.148876+00:00","status_changed_at":"2026-11-22T23:26:16.119679+00:00","url":"https://bounty.xe.network/XE-16823","body":"## Summary\n\n`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.\n\nTwo variants, both found by stateful fuzzing of `Ledger.AddBlock` (~29,700 ledger sequences, ~1.1M blocks applied, 0 panics):\n\n- **Variant A — unwinding a `lease_renew` while a settle stands (37 instances).** lease → accept → renew → settle, then `SwapBlock` replaces 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.\n- **Variant B — unwinding a `lease_accept` while renewals stand (142 instances).** lease → accept → renew, then `SwapBlock` replaces the accept. The lease is restored to `Created` but the renewal remains on the consumer chain; replay fails: `lease not yet accepted for renewal (state created): retry after accept`.\n\n## Root cause\n\n`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`).\n\n## Verification\n\nMinimized reproducers (deterministic replay sequences):\n- Variant A, 21 blocks: lease `204b9543` cost 4275 → accept `cce66d6c` → renew `a8a66fc2` amt 4275 (swapped out) → settle `5b5b2ef4` 19132 XE; fork send `4b326d66` amt 417048. Replay 21/21 into a fresh ledger, `SwapBlock` succeeds, replay-from-chains fails with the segment error at `core/ledger.go:2313`. Supply post-swap conserved.\n- Variant B, 51 blocks: lease `97382e00` → accept `37da19dd` (swapped out) → renew `cf7992b0` amt 7750; fork `551df0d2`. Replay 51/51, `SwapBlock` succeeds, replay-from-chains fails at `core/lease_renew.go:29`. Supply post-swap conserved.\n\n## Note on related reports\n\nDistinct from:\n- #8 Finding 2 — unwinding the *lease* leaves the *accept* dangling (the reverse direction: swapped block is the lease, orphaned dependent is the accept).\n- #652 — settled-lease escrow refund on unwind; a funds bug, not a replay failure.\n- #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.\n- #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.\n- #533 — rolling back a *cancel* that won over an accept zeroes accept metadata; different trigger and failure mode (renewals are kept there, stranded here).\n- #226 v1 — multi-step cascade stale reads; needs multi-lease unwinds, which `planSwap` refuses, so not producible via `SwapBlock`.\n\n## Suggested fix\n\nRefuse to swap a lease block that has live cross-chain dependents, or cascade the unwind to those dependents.","patch_refs":[],"thread":[{"id":18861,"source":"desk","source_ref":"reply:16538","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0022, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-16823 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:16.104779+00:00"}]}