{"id":"XE-16835","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"664","source_url":"https://github.com/xeprotocol/xe/issues/664","reporter_id":2920,"title":"[Medium] CommitBlock on a missing lease/pending: MemStore silently commits, BadgerStore fails the entire block","area":"leasing-ledger","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T06:33:15.009009+00:00","updated_at":"2026-11-22T23:26:13.231783+00:00","source_created_at":"2026-11-17T06:31:17+00:00","told_at":"2026-11-22T23:26:13.254228+00:00","status_changed_at":"2026-11-22T23:26:13.236368+00:00","url":"https://bounty.xe.network/XE-16835","body":"## Summary\n\nThe 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.\n\nProduction 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.\n\n## Root cause\n\n- 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.\n- 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.\n\n## Verification\n\nDifferential 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):\n- MemStore: `err=<nil>`, block stored.\n- BadgerStore: `err=CommitBlock: settle lease missing-leas: Key not found` (same shape for cancel / force-settle / topup), block **not** stored.\n\n## Impact\n\nLedger-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.\n\n## Note on related reports\n\nDistinct 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).\n\n## Suggested fix\n\nMake both backends agree — either both fail or both skip. Failing loudly is the safer direction.","patch_refs":[],"thread":[{"id":18818,"source":"desk","source_ref":"reply:16495","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, 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-16835 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:13.231783+00:00"}]}