When the internal miner is enabled at the start of a new node, there is an near instant assert in TestBlockValidity because its attempting to mine a block before the top checkpoint.
Also avoids a data race around vNodes.
When the internal miner is enabled at the start of a new node, there is an near instant assert in TestBlockValidity because its attempting to mine a block before the top checkpoint.
Also avoids a data race around vNodes.
When the internal miner is enabled at the start of a new node, there
is an near instant assert in TestBlockValidity because its attempting
to mine a block before the top checkpoint.
Also avoids a data race around vNodes.
This was reported on IRC by smccully; either of the two internal checks fix my reproduction of his problem.
An implication of this is that it makes it harder to intentionally fork testnet-- due to requiring getting it past IsInitialBlockDownload, which may be undesirable. (Though you should be able to syncup then invalidate block and mine ahead).
90 | @@ -91,6 +91,11 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, 91 | 92 | CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) 93 | { 94 | + LOCK(cs_main); 95 | + // Are we in sync enough to even try creating a block? Otherwise TestBlockValidity will fail. 96 | + if (chainActive.Height() < Checkpoints::GetTotalBlocksEstimate())
I've reproduced the issue to verify: the underlying problem appears to be that the std::runtime_exception raised by CreateNewBlock in case TestBlockValidity fails is not caught by the internal miner. The other uses of this function in RPC are protected.
terminate called after throwing an instance of 'std::runtime_error'
what(): CreateNewBlock() : TestBlockValidity failed
Adding an extra check here at the beginning is redundant - you'd add a check to avoid raising an exception later in the same funcion :) better to change the calling code in BitcoinMiner to catch and report this exception.
See here: https://github.com/laanwj/bitcoin/commit/89388eb36fe3e220605b9f4ffc46f4ad7e8fadb7
I've tested it with and without the change to BitcoinMiner, it catches the same problem.
That looks good to me.