From e85f386c4b157b7d1ac16aface9bd2c614e62b46 Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Thu, 15 Aug 2024 17:13:33 +0200 Subject: consensus: enable BIP94 on regtest --- src/consensus/params.h | 4 ++++ src/kernel/chainparams.cpp | 2 +- src/validation.cpp | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/consensus/params.h b/src/consensus/params.h index d970e41637..eadfe2ba90 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -108,6 +108,10 @@ struct Params { /** Proof of work parameters */ uint256 powLimit; bool fPowAllowMinDifficultyBlocks; + /** + * Enfore BIP94 timewarp attack mitigation. On testnet4 this also enforces + * the block storm mitigation. + */ bool enforce_BIP94; bool fPowNoRetargeting; int64_t nPowTargetSpacing; diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp index bf0415667e..e7cf56ecbc 100644 --- a/src/kernel/chainparams.cpp +++ b/src/kernel/chainparams.cpp @@ -540,7 +540,7 @@ public: consensus.nPowTargetTimespan = 24 * 60 * 60; // one day consensus.nPowTargetSpacing = 10 * 60; consensus.fPowAllowMinDifficultyBlocks = true; - consensus.enforce_BIP94 = false; + consensus.enforce_BIP94 = true; consensus.fPowNoRetargeting = true; consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016) diff --git a/src/validation.cpp b/src/validation.cpp index bf2b4b315e..8c80e35c01 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4189,7 +4189,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio if (block.GetBlockTime() <= pindexPrev->GetMedianTimePast()) return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "time-too-old", "block's timestamp is too early"); - // Testnet4 only: Check timestamp against prev for difficulty-adjustment + // Testnet4 and regtest only: Check timestamp against prev for difficulty-adjustment // blocks to prevent timewarp attacks (see https://github.com/bitcoin/bitcoin/pull/15482). if (consensusParams.enforce_BIP94) { // Check timestamp for the first block of each difficulty adjustment -- cgit v1.2.3