Skip to content

Introduce KOMODO_MININGTHREADS for mining configuration#401

Closed
monkins1010 wants to merge 2 commits intomiketout:devfrom
monkins1010:patch-22
Closed

Introduce KOMODO_MININGTHREADS for mining configuration#401
monkins1010 wants to merge 2 commits intomiketout:devfrom
monkins1010:patch-22

Conversation

@monkins1010
Copy link
Copy Markdown

@monkins1010 monkins1010 commented Jan 9, 2026

Fix: Mining Configuration Not Applied from Config File

Problem

When setting mining parameters in VRSC.conf:

gen=1
genproclimit=1
mint=1

The daemon would:

  1. Show "numthreads": 0 in getmininginfo
  2. Potentially hang on startup

However, manually running ./verus setgenerate true 1 after startup worked correctly.

Root Cause

The komodo_args() function runs before the configuration file is loaded.

In bitcoind.cpp:

Line Code Description
113 ParseParameters(argc, argv) Command-line args parsed
142 komodo_args(argv[0]) Sets KOMODO_MININGTHREADS
161 ReadConfigFile(mapArgs, mapMultiArgs) Config file loaded here

When komodo_args() executes (line 142), it checks for -gen in komodo_utils.h:1746-1750:

if ( GetBoolArg("-gen", false) != 0 )
{
    KOMODO_MININGTHREADS = GetArg("-genproclimit",-1);
}
else KOMODO_MININGTHREADS = 0;

At this point, mapArgs only contains command-line arguments. Config file settings (gen=1, genproclimit=1, mint=1) haven't been loaded yet.

Since -gen isn't found, KOMODO_MININGTHREADS is set to 0 and never updated.

Solution

  1. Added extern declaration for KOMODO_MININGTHREADS in init.cpp
  2. Set KOMODO_MININGTHREADS in init.cpp after the config file has been read
  3. Moved GenerateBitcoins() call to after SetRPCWarmupFinished() to ensure the node is fully initialized before starting mining threads

Changes

init.cpp:

  • Added extern int32_t KOMODO_MININGTHREADS; declaration
  • Set KOMODO_MININGTHREADS from config after it's loaded
  • Deferred GenerateBitcoins() until after RPC warmup completes

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.
@miketout miketout closed this Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants