-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: extract CActiveMasternodeManager from LLMQContext (4/n, followups)
#7066
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
base: develop
Are you sure you want to change the base?
Changes from all commits
1f912bd
5a0f361
3dba7e7
ae3ffb9
8262237
9a13ac0
c76d3f2
176f929
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 |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ class CBLSWorker | |
| CBLSWorker(); | ||
| ~CBLSWorker(); | ||
|
|
||
| void Start(); | ||
| void Start(int8_t worker_count); | ||
| void Stop(); | ||
|
Comment on lines
+57
to
58
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 chain🏁 Script executed: #!/bin/bash
# 1) Find all CBLSWorker::Start call sites
echo "=== Searching for CBLSWorker::Start() call sites ==="
rg -n --type=cpp --type=cc --type=h --type=hpp 'Start\s*\(' src/bls src/llmq 2>/dev/null | grep -i worker | head -30
echo -e "\n=== Searching for CBLSWorker in header files ==="
rg -n --type=h --type=hpp 'class CBLSWorker' src
echo -e "\n=== Searching for DEFAULT_WORKER_COUNT ==="
rg -n --type=cpp --type=cc --type=h --type=hpp 'DEFAULT_WORKER_COUNT' srcRepository: dashpay/dash Length of output: 274 🏁 Script executed: #!/bin/bash
# 2) Look at the actual implementation of Start() in bls_worker.cpp
echo "=== Finding bls_worker.cpp ==="
find src -name "bls_worker.cpp" -type f
echo -e "\n=== Checking if file exists and reading it ==="
if [ -f "src/bls/bls_worker.cpp" ]; then
echo "File found. Reading Start() implementation:"
rg -n -A 10 'void CBLSWorker::Start' src/bls/bls_worker.cpp
fiRepository: dashpay/dash Length of output: 451 🏁 Script executed: #!/bin/bash
# 3) Check for any validation or constraints on worker_count parameter
echo "=== Searching for worker_count usage and constraints ==="
rg -n --type=cpp --type=h 'worker_count' src/bls src/llmq | head -40Repository: dashpay/dash Length of output: 1111 🏁 Script executed: #!/bin/bash
# Fix the file type issue and search more broadly
echo "=== Searching for worker_count initialization ==="
rg -n 'worker_count\s*=' src --type c | head -30
echo -e "\n=== Searching for params initialization in context.cpp ==="
rg -n -B 5 'bls_worker->Start' src/bls/context.cpp
echo -e "\n=== Looking for LLMQParams or similar definition ==="
rg -n 'struct.*Params.*{' src/llmq | head -10Repository: dashpay/dash Length of output: 394 🏁 Script executed: #!/bin/bash
# Check what params is and where worker_count comes from
echo "=== Examining src/bls/context.cpp around Start() call ==="
cat -n src/bls/context.cpp | head -50
echo -e "\n=== Checking llmq/options.h for LLMQParams ==="
cat -n src/llmq/options.h | grep -A 10 -B 10 'worker_count'Repository: dashpay/dash Length of output: 1009 🏁 Script executed: #!/bin/bash
# Search for validation of worker_count anywhere
echo "=== Searching for any validation of worker_count ==="
rg -n 'worker_count.*>' src --type c
rg -n 'assert.*worker_count' src --type c
rg -n 'if.*worker_count' src --type c | head -20Repository: dashpay/dash Length of output: 108 🏁 Script executed: #!/bin/bash
echo "=== Searching for DashParams initialization ==="
rg -n 'DashParams' src --type c | head -30
echo -e "\n=== Examining src/llmq/context.cpp ==="
cat -n src/llmq/context.cpp | head -60Repository: dashpay/dash Length of output: 2950 🏁 Script executed: #!/bin/bash
echo "=== Searching for where worker_count/bls_threads are set ==="
rg -n 'bls_threads|worker_count' src --type c | grep -E '(=|DEFAULT|gArgs)' | head -30
echo -e "\n=== Searching for gArgs or parameter parsing related to bls/worker ==="
rg -n -i 'bls.thread|worker.count|llmq.*thread' src --type c | head -30Repository: dashpay/dash Length of output: 921 🏁 Script executed: #!/bin/bash
echo "=== Looking for where DashParams gets populated ==="
rg -n 'bls_threads\s*=' src --type c -A 2 -B 2
rg -n 'worker_count\s*=' src --type c -A 2 -B 2Repository: dashpay/dash Length of output: 107 🏁 Script executed: #!/bin/bash
echo "=== Searching for where DashParams is constructed ==="
rg -n 'DashParams\s*{' src --type c -A 3 | head -50
echo -e "\n=== Searching for any place where DashParams gets created ==="
rg -n 'llmq::DashParams' src --type c | head -30Repository: dashpay/dash Length of output: 632 🏁 Script executed: #!/bin/bash
echo "=== Looking for parameter parsing or initialization related to worker_count ==="
rg -n -i 'worker|llmq' src --type c | grep -i -E 'parse|arg|init|create|param' | head -30
echo -e "\n=== Checking if there are command-line argument parsers ==="
find src -name "*args*" -o -name "*params*" | head -10Repository: dashpay/dash Length of output: 3380 🏁 Script executed: #!/bin/bash
echo "=== Searching in chainstate or main initialization files ==="
find src -name "*.h" -o -name "*.cpp" | xargs grep -l 'DashParams' | head -10Repository: dashpay/dash Length of output: 265 🏁 Script executed: #!/bin/bash
echo "=== Checking src/init.cpp for DashParams construction ==="
rg -n 'DashParams' src/init.cpp -A 5 -B 5
echo -e "\n=== Checking src/node/chainstate.cpp for DashParams ==="
rg -n 'DashParams' src/node/chainstate.cpp -A 5 -B 5
echo -e "\n=== Searching for llmq:: DashParams initialization ==="
rg -n -A 10 'llmq::DashParams' src --type c | head -60Repository: dashpay/dash Length of output: 5393 🏁 Script executed: #!/bin/bash
echo "=== Looking for worker_count assignments or initialization ==="
rg -n 'worker_count' src/init.cpp src/node/chainstate.cpp -B 3 -A 3
echo -e "\n=== Checking test setup files ==="
cat src/test/util/setup_common.cpp | grep -n -A 10 -B 5 'DashParams\|worker_count' | head -50Repository: dashpay/dash Length of output: 3392 Add assertion to guard the int8_t to size_t conversion in While Proposed fix (in
|
||
|
|
||
| bool GenerateContributions(int threshold, Span<CBLSId> ids, BLSVerificationVectorPtr& vvecRet, std::vector<CBLSSecretKey>& skSharesRet); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2005,7 +2005,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node.mnhf_manager, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node.llmq_ctx, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Assert(node.mempool.get()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.GetDataDirNet(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fPruneMode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.GetBoolArg("-spentindex", DEFAULT_SPENTINDEX), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -2017,18 +2016,25 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cache_sizes.coins, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /*block_tree_db_in_memory=*/false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /*coins_db_in_memory=*/false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /*dash_dbs_in_memory=*/false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /*bls_threads=*/[&args]() -> int8_t { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int8_t threads = args.GetIntArg("-parbls", llmq::DEFAULT_BLSCHECK_THREADS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (threads <= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // -parbls=0 means autodetect (number of cores - 1 validator threads) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // -parbls=-n means "leave n cores free" (number of cores - n - 1 validator threads) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| threads += GetNumCores(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Subtract 1 because the main thread counts towards the par threads | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return std::clamp<int8_t>(threads - 1, 0, llmq::MAX_BLSCHECK_THREADS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.GetIntArg("-maxrecsigsage", llmq::DEFAULT_MAX_RECOVERED_SIGS_AGE), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| llmq::DashParams{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .bls_threads = [&args]() -> int8_t { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int8_t threads = args.GetIntArg("-parbls", llmq::DEFAULT_BLSCHECK_THREADS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (threads <= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // -parbls=0 means autodetect (number of cores - 1 validator threads) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // -parbls=-n means "leave n cores free" (number of cores - n - 1 validator threads) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| threads += GetNumCores(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Subtract 1 because the main thread counts towards the par threads | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return std::clamp<int8_t>(threads - 1, 0, llmq::MAX_BLSCHECK_THREADS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .worker_count = llmq::DEFAULT_WORKER_COUNT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .max_recsigs_age = args.GetIntArg("-maxrecsigsage", llmq::DEFAULT_MAX_RECOVERED_SIGS_AGE), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .db_params = util::DbWrapperParams{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .path = args.GetDataDirNet(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .memory = false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .wipe = fReset || fReindexChainState, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+2019
to
+2037
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. Avoid int8_t narrowing before clamping when computing
Proposed diff llmq::DashParams{
- .bls_threads = [&args]() -> int8_t {
- int8_t threads = args.GetIntArg("-parbls", llmq::DEFAULT_BLSCHECK_THREADS);
+ .bls_threads = [&args]() -> int8_t {
+ int threads = args.GetIntArg("-parbls", llmq::DEFAULT_BLSCHECK_THREADS);
if (threads <= 0) {
// -parbls=0 means autodetect (number of cores - 1 validator threads)
// -parbls=-n means "leave n cores free" (number of cores - n - 1 validator threads)
threads += GetNumCores();
}
// Subtract 1 because the main thread counts towards the par threads
- return std::clamp<int8_t>(threads - 1, 0, llmq::MAX_BLSCHECK_THREADS);
+ threads = std::clamp<int>(threads - 1, 0, llmq::MAX_BLSCHECK_THREADS);
+ return static_cast<int8_t>(threads);
}(),
.worker_count = llmq::DEFAULT_WORKER_COUNT,📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /*shutdown_requested=*/ShutdownRequested, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /*coins_error_cb=*/[]() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uiInterface.ThreadSafeMessageBox( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -2328,15 +2334,15 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node.llmq_ctx->Start(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node.peerman->StartHandlers(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (node.observer_ctx) node.observer_ctx->Start(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (node.observer_ctx) node.observer_ctx->Start(llmq::DEFAULT_WORKER_COUNT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node.scheduler->scheduleEvery(std::bind(&CNetFulfilledRequestManager::DoMaintenance, std::ref(*node.netfulfilledman)), std::chrono::minutes{1}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node.scheduler->scheduleEvery(std::bind(&CMasternodeUtils::DoMaintenance, std::ref(*node.connman), std::ref(*node.dmnman), std::ref(*node.mn_sync), node.cj_walletman.get()), std::chrono::minutes{1}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node.scheduler->scheduleEvery(std::bind(&CDeterministicMNManager::DoMaintenance, std::ref(*node.dmnman)), std::chrono::seconds{10}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node.peerman->ScheduleHandlers(*node.scheduler); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (node.active_ctx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node.active_ctx->Start(*node.connman, *node.peerman); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node.active_ctx->Start(*node.connman, *node.peerman, llmq::DEFAULT_WORKER_COUNT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node.scheduler->scheduleEvery(std::bind(&llmq::CDKGSessionManager::CleanupOldContributions, std::ref(*node.active_ctx->qdkgsman)), std::chrono::hours{1}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
why moved random.h? there's nothing SPECIAL in this header to be in its own group; use alphabetic order as all other. This file is not backported also, so, no need to care about possible conflicts