Repository navigation
refactor: delete extra ctors from managers, restore memory-only db for EvoDb and LLMQContext
#6923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
88a2375
301bc70
adb5117
52f7160
5163e85
5dd2e99
556d0b8
a7bec54
5b2e54a
8763104
3c85563
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset, | |
| int64_t nCoinCacheUsage, | ||
| bool block_tree_db_in_memory, | ||
| bool coins_db_in_memory, | ||
| bool dash_dbs_in_memory, | ||
| std::function<bool()> shutdown_requested, | ||
| std::function<void()> coins_error_cb) | ||
| { | ||
|
|
@@ -73,7 +74,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset, | |
| LOCK(cs_main); | ||
|
|
||
| evodb.reset(); | ||
| evodb = std::make_unique<CEvoDB>(util::DbWrapperParams{.path = data_dir, .memory = false, .wipe = fReset || fReindexChainState}); | ||
| evodb = std::make_unique<CEvoDB>(util::DbWrapperParams{.path = data_dir, .memory = dash_dbs_in_memory, .wipe = fReset || fReindexChainState}); | ||
|
UdjinM6 marked this conversation as resolved.
|
||
|
|
||
| mnhf_manager.reset(); | ||
| mnhf_manager = std::make_unique<CMNHFManager>(*evodb); | ||
|
|
@@ -89,8 +90,8 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset, | |
| pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, block_tree_db_in_memory, fReset)); | ||
|
|
||
| DashChainstateSetup(chainman, govman, mn_metaman, mn_sync, sporkman, mn_activeman, chain_helper, cpoolman, | ||
| dmnman, evodb, mnhf_manager, llmq_ctx, mempool, data_dir, fReset, fReindexChainState, | ||
| consensus_params); | ||
| dmnman, evodb, mnhf_manager, llmq_ctx, mempool, data_dir, dash_dbs_in_memory, | ||
| /*llmq_dbs_wipe=*/fReset || fReindexChainState, consensus_params); | ||
|
|
||
|
Comment on lines
92
to
95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard mempool pointer before use in DashChainstateSetup. mempool is a raw pointer; Setup dereferences it (ConnectManagers, passed into LLMQContext). Add a non‑fatal assert/early check to avoid accidental null deref in tests or future code paths. Apply this diff near the start of DashChainstateSetup: void DashChainstateSetup(ChainstateManager& chainman,
@@
const Consensus::Params& consensus_params)
{
+ CHECK_NONFATAL(mempool != nullptr);Based on learnings. Also applies to: 251-253 🤖 Prompt for AI Agents |
||
| if (fReset) { | ||
| pblocktree->WriteReindexing(true); | ||
|
|
@@ -230,8 +231,8 @@ void DashChainstateSetup(ChainstateManager& chainman, | |
| std::unique_ptr<LLMQContext>& llmq_ctx, | ||
| CTxMemPool* mempool, | ||
| const fs::path& data_dir, | ||
| bool fReset, | ||
| bool fReindexChainState, | ||
| bool llmq_dbs_in_memory, | ||
| bool llmq_dbs_wipe, | ||
| const Consensus::Params& consensus_params) | ||
| { | ||
| // Same logic as pblocktree | ||
|
|
@@ -248,7 +249,7 @@ void DashChainstateSetup(ChainstateManager& chainman, | |
| llmq_ctx.reset(); | ||
| llmq_ctx = std::make_unique<LLMQContext>(chainman, *dmnman, *evodb, mn_metaman, *mnhf_manager, sporkman, | ||
| *mempool, mn_activeman.get(), mn_sync, | ||
| util::DbWrapperParams{.path = data_dir, .memory = false, .wipe = fReset || fReindexChainState}); | ||
| util::DbWrapperParams{.path = data_dir, .memory = llmq_dbs_in_memory, .wipe = llmq_dbs_wipe}); | ||
| mempool->ConnectManagers(dmnman.get(), llmq_ctx->isman.get()); | ||
| // Enable CMNHFManager::{Process, Undo}Block | ||
| mnhf_manager->ConnectManagers(&chainman, llmq_ctx->qman.get()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,8 +87,8 @@ static constexpr CAmount CENT{1000000}; | |
| /** Initialize Dash-specific components during chainstate initialization (NodeContext-friendly aliases) */ | ||
| void DashChainstateSetup(ChainstateManager& chainman, | ||
| node::NodeContext& node, | ||
| bool fReset, | ||
| bool fReindexChainState, | ||
| bool llmq_dbs_in_memory, | ||
| bool llmq_dbs_wipe, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit; it's a bit risky to change one bool flag to other with completely different meaning; but so far as it is DashChainstateSetup I think it's not a big deal. |
||
| const Consensus::Params& consensus_params); | ||
|
Comment on lines
88
to
92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainAPI change: new LLMQ DB flags—verify all call sites and consider a small options struct. Adding llmq_dbs_in_memory and llmq_dbs_wipe is fine, but increases boolean-parameter soup. Consider grouping LLMQ DB options into a small struct to reduce call-site errors. Please also verify all test helpers/callers are updated. Run: 🏁 Script executed: #!/bin/bash
rg -nP '\bDashChainstateSetup\s*\(' -C2 -- srcLength of output: 3890 Length of output: 2179 🏁 Script executed: #!/bin/bash
# Look for indirect callers (functions that might call DashChainstateSetup)
rg -nP 'LoadChainstate|InitCoinsCache' -C1 -- src/test | head -30Length of output: 2063 Length of output: 839 🏁 Script executed: #!/bin/bash
# Verify no additional DashChainstateSetup calls exist in production code
rg -nP 'DashChainstateSetup\s*\(' -- src/node src/init --type cpp | grep -v 'void DashChainstateSetup' | grep -v '//'Length of output: 228 Add inline comment to production call site; bool-parameter design acceptable with comments. The production call at src/node/chainstate.cpp:92 passes 🤖 Prompt for AI Agents
Comment on lines
+90
to
92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainAudit all DashChainstateSetup call sites for new bool ordering. API now takes (llmq_dbs_in_memory, llmq_dbs_wipe). Verify all prod/tests map args correctly and annotate at call sites to avoid boolean swaps. Run to review usage across the tree: 🏁 Script executed: #!/bin/bash
# Show all call sites with context
rg -nP --type=cpp -C2 '\bDashChainstateSetup\s*\(' src
# Quick sanity: ensure named inline comments present at prod call(s)
rg -nP --type=cpp -C1 'DashChainstateSetup\s*\([^)]*llmq_dbs_in_memory' src/node src
# List any legacy signature usage that might remain (2 bools often ambiguous)
rg -nP --type=cpp -C2 'DashChainstateSetup\s*\(\s*[^,]+,\s*[^,]+,\s*(true|false)\s*,\s*(true|false)\s*,' srcLength of output: 4431 Add inline comment for llmq_dbs_in_memory at production call site. Verification confirms the new bool parameters are mapped correctly across all call sites, but the production call at 🤖 Prompt for AI Agents |
||
| void DashChainstateSetupClose(node::NodeContext& node); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: so far as
coins_db_in_memoryanddash_dbs_in_memoryare always equal, consider merging them to a new flagdbs_in_memory.LoadChainstatehas a bit too many arguments already.Though, keep
block_tree_db_in_memoryas it is because it will be refactored later in bitcoin#30965