Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/test/util/setup_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,22 @@ void ChainTestingSetup::LoadVerifyActivateChainstate()
{
auto& chainman{*Assert(m_node.chainman)};

// peerman and cj_walletman reference llmq_ctx, the mempool and the Dash
// managers recreated by the reload below. No test uses them across a
// reload: destroy them (clearing connman's raw m_msgproc pointer first)
// so future use after a reload fails on a null pointer instead of
// silently reading freed memory; such a test must rebuild them itself,
// as AppInitMain constructs them only after the chainstate is loaded.
if (m_node.peerman) {
CConnman::Options connman_options;
connman_options.socketEventsMode = ::g_socket_events_mode;
m_node.connman->Init(connman_options);
m_node.peerman.reset();
}
#ifdef ENABLE_WALLET
m_node.cj_walletman.reset();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve wallet registrations when rebuilding CoinJoin manager

When a wallet-enabled fixture has already added a wallet through CoinJoinLoaderImpl::AddWallet() and then calls LoadVerifyActivateChainstate(), this reset destroys the only m_wallet_manager_map entries, while the newly constructed manager below is never repopulated from the still-loaded wallets. Subsequent loader operations such as WithClient() therefore return false and CoinJoin processing silently stops for those wallets; preserve or re-register the loaded wallets as part of the rebuild.

AGENTS.md reference: AGENTS.md:L15-L17

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in c43e3e4 by documenting the invariant at the rebuild site rather than re-registering: no current fixture has wallets loaded when the chainstate is reloaded (verified all three caller families), and setup_common cannot reach the shared_ptr that addWallet() requires without new plumbing. Details in the thepastaclaw thread on this line.


🤖 Posted autonomously by Claude on behalf of pasta.

#endif // ENABLE_WALLET

node::ChainstateLoadOptions options{ChainstateLoadOptionsForTest()};

if (options.reindex || options.reindex_chainstate) {
Expand Down
Loading