{"id":"XE-16991","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"702","source_url":"https://github.com/xeprotocol/xe/issues/702","reporter_id":2920,"title":"[Low] MemStore dest index returns a stale copy after re-putting a pending under a different destination","area":"leasing-ledger","claimed_tier":null,"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-17T08:13:52.184185+00:00","updated_at":"2026-11-22T23:26:14.505091+00:00","source_created_at":"2026-11-17T08:12:51+00:00","told_at":"2026-11-22T23:26:14.531783+00:00","status_changed_at":"2026-11-22T23:26:14.514834+00:00","url":"https://bounty.xe.network/XE-16991","body":"## Summary\n\nRe-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.\n\n## Root Cause\n\n- MemStore's `pendingByDest` stores copies (`store/mem_store.go:147-157`): 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.\n- BadgerStore's dest index stores only hashes, resolved live via `GetPendingSend` (`store/badger_store.go:430-460`).\n\n## Verification\n\nExecuted differential harness (test A5): `PutPendingSend(hash H, dest B, amount 50)`, then `PutPendingSend(hash H, dest C, amount 70)`.\n\n```\nGetPendingByDest(B): Mem = 1 entry, amount 50, dest B (stale)\n                     Badger = 1 entry, amount 70, dest C (current record)\nGetPendingSend(H) agrees (70/C) on both.\n```\n\nSame 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.\n\n## Note on related reports\n\nSearched `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).\n\n## Suggested fix\n\nResolve dest-index lookups against the primary map (store hashes, not copies), matching BadgerStore.\n","patch_refs":[],"thread":[{"id":18836,"source":"desk","source_ref":"reply:16513","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-16991 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:14.505091+00:00"}]}