[Medium] CommitBlock on a missing lease/pending: MemStore silently commits, BadgerStore fails the entire block
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/UnfulfillLeaseHashare guarded byif l, ok := m.leases[...]; ok— a missing lease is silently skipped and the block commits. Same forTopUpPendingID(~:386-395): a missing pending is silently skipped. - BadgerStore
applyCommitTxn(store/badger_store.go:~960-1031): the leasetxn.GetreturnsErrKeyNotFound, 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
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.