Skip to content

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

Open
ImplOfAnImpl wants to merge 2 commits into
consensus_tighteningfrom
mempool_shrink_hash_tables
Open

Mempool: fix spuriouly failing test; shrink hash tables; some cleanup.#2080
ImplOfAnImpl wants to merge 2 commits into
consensus_tighteningfrom
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.

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