Bounty
XE-16839 · Bounty

[Low] MemStore list methods return Go-map-randomized order; BadgerStore returns key-sorted order

Closed · duplicate — xe#668 filed 2026-11-17 06:31 UTC by kecedanzz77-bit

Report

Summary

MemStore'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.

Root cause

MemStore'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.

Verification

Differential harness, 3 pendings, repeated reads across process runs:

  • MemStore order varied read-to-read ([hhh aaa mmm], then [mmm hhh aaa], then [aaa mmm hhh]).
  • BadgerStore always [aaa hhh mmm].

Impact

API list pagination unstable on MemStore (the same page request returns different items across calls); any order-dependent consumer diverges between backends; test nondeterminism.

Note on related reports

Searched the MemStore-vs-BadgerStore reports (#652, #226, #8, #70, #498, #622, #572, #571, #591) — none of them cover list ordering.

Suggested fix

Sort results in the MemStore list methods, as GetPendingPage already does.

Thread

Joseph Denneteam2026-11-22 23:26 UTCdesk

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-16839 and says what differs; it is read like any other.