{"id":"XE-16839","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"668","source_url":"https://github.com/xeprotocol/xe/issues/668","reporter_id":2920,"title":"[Low] MemStore list methods return Go-map-randomized order; BadgerStore returns key-sorted order","area":"node-api","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-17T06:33:15.153002+00:00","updated_at":"2026-11-22T23:26:12.535100+00:00","source_created_at":"2026-11-17T06:31:54+00:00","told_at":"2026-11-22T23:26:12.577214+00:00","status_changed_at":"2026-11-22T23:26:12.545935+00:00","url":"https://bounty.xe.network/XE-16839","body":"## Summary\n\nMemStore's list methods iterate Go maps directly, so their result order is randomized per call; BadgerStore iterates keys lexicographically, so its order is deterministic. The same list query returns different orderings depending on the backend.\n\n## Root cause\n\nMemStore's `GetAllPending` (`store/mem_store.go:192-201`), `GetPendingByDest`, `GetAllLeases`, `GetLeasesByProvider`, `GetLeasesByState`, `GetAllConflicts`, `GetConflictsForAccount`, `GetVotesByConflict`, and `IterateDelegations` all iterate Go maps (`for _, x := range m.pending` / `m.leases` / `m.conflicts` ...). BadgerStore iterates keys in lexicographic order. Note the authors knew map order was a problem for pagination — `GetPendingPage` is explicitly sorted in MemStore — but the other list methods were not.\n\n## Verification\n\nDifferential harness, 3 pendings, repeated reads across process runs:\n- MemStore order varied read-to-read (`[hhh aaa mmm]`, then `[mmm hhh aaa]`, then `[aaa mmm hhh]`).\n- BadgerStore always `[aaa hhh mmm]`.\n\n## Impact\n\nAPI list pagination unstable on MemStore (the same page request returns different items across calls); any order-dependent consumer diverges between backends; test nondeterminism.\n\n## Note on related reports\n\nSearched the MemStore-vs-BadgerStore reports (#652, #226, #8, #70, #498, #622, #572, #571, #591) — none of them cover list ordering.\n\n## Suggested fix\n\nSort results in the MemStore list methods, as `GetPendingPage` already does.","patch_refs":[],"thread":[{"id":18810,"source":"desk","source_ref":"reply:16487","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-16839 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:12.535100+00:00"}]}