Skip to content

Mempool: fix spuriouly failing test; shrink hash tables; some cleanup.#2080

Merged
ImplOfAnImpl merged 2 commits into
masterfrom
mempool_shrink_hash_tables
Jun 19, 2026
Merged

Mempool: fix spuriouly failing test; shrink hash tables; some cleanup.#2080
ImplOfAnImpl merged 2 commits into
masterfrom
mempool_shrink_hash_tables

Conversation

@ImplOfAnImpl

Copy link
Copy Markdown
Contributor
  • Since the switch to using hashbrown tables in mempool, the test mempool_full_real can fail spuriously, because now removing a tx from a full mempool and inserting one with the same size is not guaranteed to succeed (this is because hashbrown tables leave a tombstone instead of a removed element, which may not always be re-used during insertion). So the test had to be relaxed.

  • Mempool will now try to shrink its hashtables' capacities from time to time.
    Note that I initially implemented this to handle a degenerate case where an attacker would fill the mempool with 200'000 small transactions, which may permanently occupy up to 40Mb worth of capacity in the hashtables, thus reducing the effective mempool size by the same 40Mb. But then I noticed that we actually recreate the whole mempool store each time the mempool reorgs to a new tip, so the degenerate case may exist for several minutes at best. But IMO it's better to keep the shrinkage logic, at least as a fail-safe.

  • Small cleanup - MempoolStore's fields are now non-public.

Base automatically changed from consensus_tightening to master June 19, 2026 08:37
@ImplOfAnImpl ImplOfAnImpl merged commit 0bb3ea6 into master Jun 19, 2026
33 of 34 checks passed
@ImplOfAnImpl ImplOfAnImpl deleted the mempool_shrink_hash_tables branch June 19, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants