Skip to content

fix(p2p): stream tx pool hydration to bound startup memory (A-968)#23086

Open
PhilWindle wants to merge 4 commits intomerge-train/spartanfrom
phil/a-968-tx_pool_v2-ooms-hydrating-txs-at-startup
Open

fix(p2p): stream tx pool hydration to bound startup memory (A-968)#23086
PhilWindle wants to merge 4 commits intomerge-train/spartanfrom
phil/a-968-tx_pool_v2-ooms-hydrating-txs-at-startup

Conversation

@PhilWindle
Copy link
Copy Markdown
Collaborator

@PhilWindle PhilWindle commented May 8, 2026

Summary

hydrateFromDatabase was deserializing every persisted tx into a single { tx, meta }[] array before doing anything else.

Stream the txs DB instead: deserialize, build metadata, and resolve mined status one tx at a time, dropping the Tx reference before moving on. Only the much smaller TxMetaData objects accumulate. The previously separate #loadAllTxsFromDb and #markMinedStatusBatch helpers fold into the streaming loop (they were only used here).

Fixes A-968.

Test plan

  • All 238 existing tx_pool_v2.test.ts cases pass (including the hydration / restart suite).
  • All 25 tx_pool_v2.compat.test.ts cases pass.

PhilWindle added 3 commits May 8, 2026 11:24
hydrateFromDatabase previously deserialized every persisted tx into a
single { tx, meta }[] array before processing it. Tx objects (with proof
data) can be megabytes each, so a busy mempool (20k+ entries at 10 TPS)
OOMed the node on startup.

Stream the txs DB instead: build metadata and resolve mined status one
tx at a time, dropping the Tx reference before moving to the next entry.
Only the (much smaller) TxMetaData objects accumulate. The previously
separate #loadAllTxsFromDb and #markMinedStatusBatch helpers fold into
the streaming loop.
Both calls are independent I/O — running them in parallel roughly halves
per-tx hydration latency for large mempools. getTxEffect rejections are
still treated as non-fatal (tx is just considered not-yet-mined), matching
the previous behavior.
@PhilWindle PhilWindle marked this pull request as ready for review May 8, 2026 11:45
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.

1 participant