<!-- XE-16823 · [High] SwapBlock unwinding lease_renew / lease_accept with standing cross-chain dependents produces unreplayable state · testnet -->
*Markdown view of <https://bounty.xe.network/XE-16823>. The page is the record; this is the same page for reading.*

XE-16823 · Bounty

# \[High\] SwapBlock unwinding lease\_renew / lease\_accept with standing cross-chain dependents produces unreplayable state

Closed · duplicate
—claimed High
[xe#661](https://github.com/xeprotocol/xe/issues/661)
filed 2026-11-17 06:23 UTC
by kecedanzz77-bit

Verdict
:   Duplicate

Tier
:   —

Claimed
:   High

Area
:   Consensus

Duplicate of
:   [XE-0022](https://bounty.xe.network/XE-0022) patched

Tracked
:   internally

Updated
:   2026-11-22 23:26 UTC

Told
:   2026-11-22 23:26 UTC

### Patches

None linked.

### History

- [770274](https://bounty.xe.network/log/770274) 2026-11-22 23:26 UTC reply.mirror\_failed
- [770044](https://bounty.xe.network/log/770044) 2026-11-22 23:26 UTC proposal.adopted
- [770043](https://bounty.xe.network/log/770043) 2026-11-22 23:26 UTC reply.sent
- [770042](https://bounty.xe.network/log/770042) 2026-11-22 23:26 UTC ticket.status new → closed
- [769218](https://bounty.xe.network/log/769218) 2026-11-22 23:25 UTC proposal.adopted
- [769217](https://bounty.xe.network/log/769217) 2026-11-22 23:25 UTC ticket.facts area
- [769216](https://bounty.xe.network/log/769216) 2026-11-22 23:25 UTC proposal.adopted
- [769215](https://bounty.xe.network/log/769215) 2026-11-22 23:25 UTC ticket.facts
- [769214](https://bounty.xe.network/log/769214) 2026-11-22 23:25 UTC proposal.adopted
- [769213](https://bounty.xe.network/log/769213) 2026-11-22 23:25 UTC ticket.facts
- [769212](https://bounty.xe.network/log/769212) 2026-11-22 23:25 UTC proposal.adopted
- [769211](https://bounty.xe.network/log/769211) 2026-11-22 23:25 UTC ticket.facts

[Full history](https://bounty.xe.network/log?ref=XE-16823) · [JSON](https://bounty.xe.network/v1/tickets/XE-16823) · [markdown](https://bounty.xe.network/XE-16823.md)

### 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_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.
- **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`.

## 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 `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.
- 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.

## 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 `planSwap` refuses, so not producible via `SwapBlock`.

## Suggested fix

Refuse to swap a lease block that has live cross-chain dependents, or cascade the unwind to those dependents.

### Thread

**Joseph Denne**team2026-11-22 23:26 UTCdesk

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.
