Merge bitcoin/bitcoin#33728: test: Add bitcoin-chainstate test for assumeutxo functionality

7b5d256af4 test: Add bitcoin-chainstate test for assumeutxo functionality (stringintech)
2bc3265649 Fix `ChainstateManager::AddChainstate()` assertion crash (stringintech)
5f3d6bdb66 Add regtest support to bitcoin-chainstate tool (stringintech)

Pull request description:

  This PR adds functional test coverage for the bitcoin-chainstate tool loading a datadir initialized with an assumeutxo snapshot.

  The PR also includes:
  - Fix for assertion crash in `ChainstateManager::AddChainstate()` when `prev_chainstate` has no initialized mempool (required for the test to pass)
  - `-regtest` flag support for bitcoin-chainstate to enable the testing

  This work started while experimenting with the bitcoin-chainstate tool and how the kernel API (#30595) behaved when loading a datadir containing assumeutxo data, during the time that PR was still under review. sedited suggested opening a PR to add this test coverage.

ACKs for top commit:
  achow101:
    ACK 7b5d256af4
  theStack:
    Concept and code-review ACK 7b5d256af4
  sedited:
    Re-ACK 7b5d256af4

Tree-SHA512: 5d3b0050cf2d53144b5f65451c991d5e212117b4541ae1368ecf58fde5f3cca4f018aad6ae32257b9ebb1c28b926424fbcff496ba5487cdc4eb456cea6db8b24
This commit is contained in:
Ava Chow
2026-01-14 14:30:47 -08:00
4 changed files with 84 additions and 25 deletions

View File

@@ -6226,7 +6226,7 @@ Chainstate& ChainstateManager::AddChainstate(std::unique_ptr<Chainstate> chainst
// Transfer possession of the mempool to the chainstate.
// Mempool is empty at this point because we're still in IBD.
assert(prev_chainstate.m_mempool->size() == 0);
assert(!prev_chainstate.m_mempool || prev_chainstate.m_mempool->size() == 0);
assert(!curr_chainstate.m_mempool);
std::swap(curr_chainstate.m_mempool, prev_chainstate.m_mempool);
return curr_chainstate;