<!-- XE-16835 · [Medium] CommitBlock on a missing lease/pending: MemStore silently commits, BadgerStore fails the entire block · testnet -->
*Markdown view of <https://bounty.xe.network/XE-16835>. The page is the record; this is the same page for reading.*

XE-16835 · Bounty

# \[Medium\] CommitBlock on a missing lease/pending: MemStore silently commits, BadgerStore fails the entire block

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

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Medium

Area
:   Leasing / ledger

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-22 23:26 UTC

Told
:   2026-11-22 23:26 UTC

### Patches

None linked.

### History

- [770265](https://bounty.xe.network/log/770265) 2026-11-22 23:26 UTC reply.mirror\_failed
- [769899](https://bounty.xe.network/log/769899) 2026-11-22 23:26 UTC proposal.adopted
- [769898](https://bounty.xe.network/log/769898) 2026-11-22 23:26 UTC reply.sent
- [769897](https://bounty.xe.network/log/769897) 2026-11-22 23:26 UTC proposal.adopted
- [769896](https://bounty.xe.network/log/769896) 2026-11-22 23:26 UTC ticket.status new → closed
- [768885](https://bounty.xe.network/log/768885) 2026-11-22 23:25 UTC proposal.adopted
- [768884](https://bounty.xe.network/log/768884) 2026-11-22 23:25 UTC ticket.facts area
- [768883](https://bounty.xe.network/log/768883) 2026-11-22 23:25 UTC proposal.adopted
- [768882](https://bounty.xe.network/log/768882) 2026-11-22 23:25 UTC ticket.facts
- [768881](https://bounty.xe.network/log/768881) 2026-11-22 23:25 UTC proposal.adopted
- [768880](https://bounty.xe.network/log/768880) 2026-11-22 23:25 UTC ticket.facts
- [766558](https://bounty.xe.network/log/766558) 2026-11-22 23:17 UTC note.added

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

### Report

## Summary

The two store backends disagree on `CommitBlock` when the referenced lease or pending does not exist: MemStore silently skips the missing entry and commits the block, BadgerStore fails the whole commit. The same block commits on one backend and is rejected on the other.

Production nodes use BadgerStore (`node/node.go:233`); MemStore is what the entire test suite runs against. So the divergence means tests cannot detect this production failure mode.

## Root cause

- MemStore `applyCommitLocked` (`store/mem_store.go:~386-427`): `SettleLeaseHash`/`CancelLeaseHash`/`UnfulfillLeaseHash` are guarded by `if l, ok := m.leases[...]; ok` — a missing lease is silently skipped and the block commits. Same for `TopUpPendingID` (`~:386-395`): a missing pending is silently skipped.
- BadgerStore `applyCommitTxn` (`store/badger_store.go:~960-1031`): the lease `txn.Get` returns `ErrKeyNotFound`, failing the whole commit. `addToPendingAmountTxn` (`~:835-861`) errors on a missing pending.

## Verification

Differential harness running identical operations against both backends (`BlockCommit` with `SettleLeaseHash`/`CancelLeaseHash`/`UnfulfillLeaseHash` pointing at a nonexistent lease, and one with `TopUpPendingID` pointing at a nonexistent pending):

- MemStore: `err=<nil>`, block stored.
- BadgerStore: `err=CommitBlock: settle lease missing-leas: Key not found` (same shape for cancel / force-settle / topup), block **not** stored.

## Impact

Ledger-level trigger: `addBlock` holds no ledger-wide lock across validate→commit, so a concurrent cascade can remove the lease/pending between validation and commit; also any pre-existing store inconsistency (e.g. the #498 missing-lease-record class). On Badger the node then cannot apply an already-gossiped block at all.

## Note on related reports

Distinct from #226 V4 (CommitCascade pre-undo CAS omission — different function and fields; the `ExpectLeaseHash` CAS itself agrees between backends in `CommitBlock`, verified by a sanity check in the same harness).

## Suggested fix

Make both backends agree — either both fail or both skip. Failing loudly is the safer direction.

### Thread

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

Thanks. This is the same finding as an earlier report that is not public, 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-16835 and says what differs; it is read like any other.
