consensus: enable BIP94 on regtest

pull/30681/head
Sjors Provoost 3 months ago
parent dd154b0568
commit e85f386c4b
No known key found for this signature in database
GPG Key ID: 57FF9BDBCC301009

@ -0,0 +1,4 @@
Tests
-----
- The BIP94 timewarp attack mitigation is now active on the `regtest` network

@ -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;

@ -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)

@ -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

Loading…
Cancel
Save