#36346 validation: don't accept txs to the mempool while loading a snapshot

ReviewabilityReviewsAgreementSize
#36346 0xShadowX validation: don't accept txs to the mempool while loading a snapshotReady0Crickets28 + 54 tests
  • Prevent node aborts and mandatory reindexing when transactions enter the mempool while loading a snapshot
  • Reject mempool submissions and concurrent snapshot loads while snapshot activation is in progress
  • Ready for review
  • No review verdicts recorded
  • Suggested blocking mempool entry during loading instead of failing activation later (fjahr)
  • Author updated the implementation to follow that approach and is waiting for review
  • 28 lines added or modified outside tests
  • 54 lines added or modified in tests
  • 0 lines removed in total
  • 3 files, 1 commits
Validation#6 of 53
P1 · bug fix
  • P1 because transactions entering the mempool during snapshot validation hit an assertion failure
  • Terminates the process after metadata is written to disk, requiring a full reindex to recover
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Sets a flag on ChainstateManager for the duration of ActivateSnapshot to reject new transactions and packages in AcceptToMemoryPool and ProcessNewPackage. Also rejects concurrent loadtxoutset calls if a snapshot is already being loaded.

Problem: ActivateSnapshot requires an empty mempool, but releases cs_main during PopulateAndValidateSnapshot, which can take several minutes. Any transaction entering the mempool during that window causes AddChainstate to hit an assertion failure, terminating the process after metadata is written to disk and forcing a full -reindex to recover.

Evidence of importance:

  • Commit and description cite the exact assertion failure in AddChainstate: `Assertion failed: (!prev_chainstate.m_mempool || prev_chainstate.m_mempool->size() == 0), function AddChainstate, file validation.cpp, line 6201`.
  • Functional test in feature_assumeutxo.py reproduces the race using a FIFO and confirms the node aborts on master when a transaction is submitted during the load.

Risk of a mistake: medium (validation, mempool_policy). Flaws in state tracking could leave the snapshot loading flag stuck on, permanently rejecting valid mempool submissions.

Changed since the previous assessment: Instead of letting transactions into the mempool and then aborting snapshot activation upon re-checking the mempool, the PR now prevents transactions from being accepted into the mempool while snapshot loading is in progress via an m_snapshot_loading flag.

Reviewability

Ready

Nothing known that would invalidate a review now.

Waiting on (from the thread read):

  • reviewer: fjahr to review the updated approach 2026-09-27

Agreement

Crickets

no substantive comment either way

Thread notes: The author implemented fjahr's suggestion to block transactions during snapshot validation and updated the description and tests.

Objections, suggestions, and questions:

ReviewerTypeHarm, request, or questionStatusMust beAuthor repliedQuote
fjahr (member)suggestion, approachPrevent transactions from entering the mempool during snapshot validation rather than failing snapshot activationfixed · fix pushed · author implemented the suggested approach in an updateansweredyes2026-09-26: 'it seems to me the correct fix would be to prevent the user from putting a tx into the mempool when we don't want one to get there instead of letting them do it and then fail'
Status from: 2026-09-27: 0xShadowX: 'Makes sense, changed it to that.'

Participants:

  • fjahr (member, neutral, 1 statements 2026-09-26 to 2026-09-26): suggested preventing transactions from entering the mempool rather than failing snapshot activation

Files

54 lines under test/bench/ci.

  • test/functional/feature_assumeutxo.py +54/-0
  • src/validation.cpp +23/-0
  • src/validation.h +5/-0

Card

The short text the ranking pass compares across PRs.

Validation rejects incoming mempool transactions and packages while an assumeutxo snapshot is being loaded. ActivateSnapshot verifies an empty mempool before releasing cs_main during snapshot population; transactions entering the mempool during that multi-minute window trigger an assertion failure in AddChainstate that crashes the node and requires a -reindex. This sets an m_snapshot_loading flag on ChainstateManager during ActivateSnapshot to reject transactions with a snapshot-loading policy error and blocks concurrent snapshot loads.

Data

dossier JSON · extract JSON · model ledger, generated 2026-09-28T01:15, confidence high, input hash 931e620a98d0c728
thread read through 2026-09-27 (2 statements), head ca21d8f5fb
labels: Validation

Categories

Validation

P1 · bug fix

Fixes a crash safety bug where transactions entering the mempool during ActivateSnapshot trigger an assertion failure in AddChainstate, terminating the node after metadata is written and forcing a full -reindex to recover.

Membership: Carries the Validation label, edits validation.cpp/h, and modifies ChainstateManager assumeutxo activation logic.

Factors: security/stability 2, bug 2, performance 0, user value 1, leverage 0