Since at least #17693, the extra nonce logic has been unused.
Prior to that PR, if the nNonce field rolled, then the while loop inside generateBlocks()
would iterate, a new block would be generated in CreateNewBlock()
, and the extra nonce could be incremented. See https://github.com/bitcoin/bitcoin/pull/17693/commits/dcc8332543f8fb6d1bb47cb270fcbb6a814a7d6e#diff-ccc24453c13307f815879738d3bf00eec351417537fbf10dde1468180cacd2f1L132-L133.
After that PR, the extra_nonce can only be set to 0 in the call to IncrementExtraNonce()
.
I think this is fine and we should just remove the unused code. The generate RPCs are only used for regtest and signet. For regtest, the difficulty is always minimum, so the nNonce field won’t roll. If the nNonce field rolls in signet and the rpc fails, then the rpc can just be called again and a new candidate block will be generated.