mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
Bug fix: when CheckChallenge(...) is called on a trimmed header, temporarily
untrim it in order to extract the proof. Without this fix, there would be an exception in this scenario, because a trimmed header no longer has any proof information attached to it. This scenario was occuring when a pre-dynafed node with trimmed blocks would receive a new block header from its peer. The pre-dynafed node would try to validate the header by comparing its proof to the previous block's proof, and this would cause an exception if the previous block had pruned. New headers are not pruned as soon as they're received. Rather, they are pruned whenever the block index is flushed to disk. So, this behavior was only being observed in functional tests, when a pre-dynafed trimmed node was restarted.
This commit is contained in:
parent
413a175b53
commit
1ab6187071
3 changed files with 12 additions and 4 deletions
|
|
@ -3860,7 +3860,7 @@ static bool ContextualCheckDynaFedHeader(const CBlockHeader& block, BlockValidat
|
|||
* in ConnectBlock().
|
||||
* Note that -reindex-chainstate skips the validation that happens here!
|
||||
*/
|
||||
static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidationState& state, BlockManager& blockman, const ChainstateManager& chainman, const CBlockIndex* pindexPrev, int64_t nAdjustedTime) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
|
||||
static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidationState& state, BlockManager& blockman, const ChainstateManager& chainman, CBlockIndex* pindexPrev, int64_t nAdjustedTime) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
assert(pindexPrev != nullptr);
|
||||
|
|
@ -3868,6 +3868,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio
|
|||
|
||||
// Check proof of work target or non-dynamic signblockscript if necessary
|
||||
const Consensus::Params& consensusParams = chainman.GetConsensus();
|
||||
|
||||
if (!DeploymentActiveAfter(pindexPrev, chainman, Consensus::DEPLOYMENT_DYNA_FED) && !CheckChallenge(block, *pindexPrev, consensusParams))
|
||||
return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "bad-diffbits", "incorrect proof of work");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue