[Low] MemStore dest index returns a stale copy after re-putting a pending under a different destination
Report
Summary
Re-putting a pending under a different destination: MemStore's dest index returns a stale copy, BadgerStore returns the live record. MemStore's pendingByDest stores copies; re-putting the same SendHash with a new destination creates a new copy under the new dest and leaves the old dest entry pointing at the old copy.
Root Cause
- MemStore's
pendingByDeststores copies (store/mem_store.go:147-157): re-putting the sameSendHashwith a new destination creates a new copy under the new dest and leaves the old dest entry pointing at the old copy. - BadgerStore's dest index stores only hashes, resolved live via
GetPendingSend(store/badger_store.go:430-460).
Verification
Executed differential harness (test A5): PutPendingSend(hash H, dest B, amount 50), then PutPendingSend(hash H, dest C, amount 70).
GetPendingByDest(B): Mem = 1 entry, amount 50, dest B (stale)
Badger = 1 entry, amount 70, dest C (current record)
GetPendingSend(H) agrees (70/C) on both.
Same test-only caveat as the sibling aliasing report: PutPendingSend has no production callers (a SendHash is a block hash, added once in production), plus a contrived trigger (re-put with changed destination). Low.
Note on related reports
Searched stale pending destination (#229, #395, #97, #155 — all different mechanisms; #229 is a conflict-swap plan→apply race) and pendingByDest (0 hits). Distinct from #226 V4: that is about Badger duplicate membership in the dest list; this is about the content MemStore returns from its copy-based dest index (membership count is 1 on both sides here).
Suggested fix
Resolve dest-index lookups against the primary map (store hashes, not copies), matching BadgerStore.
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-16991 and says what differs; it is read like any other.