Introduce KOMODO_MININGTHREADS for mining configuration#401
Closed
monkins1010 wants to merge 2 commits intomiketout:devfrom
Closed
Introduce KOMODO_MININGTHREADS for mining configuration#401monkins1010 wants to merge 2 commits intomiketout:devfrom
monkins1010 wants to merge 2 commits intomiketout:devfrom
Conversation
Added KOMODO_MININGTHREADS variable to manage mining thread count and updated related mining logic.
komodo_args() is ran before teh conffiguration file VRSC.conf is loaded.
in bitcoind.cpp:
Line 142: komodo_args(argv[0]); is called
Line 161: ReadConfigFile(mapArgs, mapMultiArgs); is called 19 lines later
So the startup order is:
Line 142 - komodo_args(argv[0]) - This reads -gen and -genproclimit and sets KOMODO_MININGTHREADS
Lines 144-152 - Wait for ASSETCHAIN_INIT
Line 161 - ReadConfigFile(mapArgs, mapMultiArgs) - Config file is read here
When komodo_args() runs, it does this in komodo_utils.h:1746-1750:
At this point, mapArgs only contains command-line arguments (parsed earlier by ParseParameters() at line 113). The config file settings like gen=1, genproclimit=1, mint=1 in VRSC.conf haven't been loaded yet.
So if you only set these in the config file (not on the command line), GetBoolArg("-gen", false) returns false, and KOMODO_MININGTHREADS gets set to 0.
That's why getmininginfo shows "numthreads": 0 when using config file settings - the variable was set before the config was ever read.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Mining Configuration Not Applied from Config File
Problem
When setting mining parameters in
VRSC.conf:The daemon would:
"numthreads": 0ingetmininginfoHowever, manually running
./verus setgenerate true 1after startup worked correctly.Root Cause
The
komodo_args()function runs before the configuration file is loaded.In bitcoind.cpp:
ParseParameters(argc, argv)komodo_args(argv[0])KOMODO_MININGTHREADSReadConfigFile(mapArgs, mapMultiArgs)When
komodo_args()executes (line 142), it checks for-geninkomodo_utils.h:1746-1750:At this point,
mapArgsonly contains command-line arguments. Config file settings (gen=1,genproclimit=1,mint=1) haven't been loaded yet.Since
-genisn't found,KOMODO_MININGTHREADSis set to0and never updated.Solution
externdeclaration forKOMODO_MININGTHREADSin init.cppKOMODO_MININGTHREADSin init.cpp after the config file has been readGenerateBitcoins()call to afterSetRPCWarmupFinished()to ensure the node is fully initialized before starting mining threadsChanges
init.cpp:
extern int32_t KOMODO_MININGTHREADS;declarationKOMODO_MININGTHREADSfrom config after it's loadedGenerateBitcoins()until after RPC warmup completes