diff --git a/doc/release-notes-31156.md b/doc/release-notes-31156.md new file mode 100644 index 00000000000..c61cfc08b93 --- /dev/null +++ b/doc/release-notes-31156.md @@ -0,0 +1,4 @@ +Test +------ + +The BIP94 timewarp attack mitigation (designed for testnet4) is no longer active on the regtest network. (#31156) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 68319e8e8b2..7966b80a273 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -44,6 +44,7 @@ void ReadSigNetArgs(const ArgsManager& args, CChainParams::SigNetOptions& option void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& options) { if (auto value = args.GetBoolArg("-fastprune")) options.fastprune = *value; + if (HasTestOption(args, "bip94")) options.enforce_bip94 = true; for (const std::string& arg : args.GetArgs("-testactivationheight")) { const auto found{arg.find('@')}; diff --git a/src/common/args.cpp b/src/common/args.cpp index 3029625ff72..833a0b28bd2 100644 --- a/src/common/args.cpp +++ b/src/common/args.cpp @@ -709,6 +709,7 @@ std::string HelpMessageOpt(const std::string &option, const std::string &message const std::vector TEST_OPTIONS_DOC{ "addrman (use deterministic addrman)", + "bip94 (enforce BIP94 consensus rules)", }; bool HasTestOption(const ArgsManager& args, const std::string& test_option) diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp index 0f128d4c562..349e14a5d6e 100644 --- a/src/kernel/chainparams.cpp +++ b/src/kernel/chainparams.cpp @@ -542,7 +542,7 @@ class CRegTestParams : public CChainParams consensus.nPowTargetTimespan = 24 * 60 * 60; // one day consensus.nPowTargetSpacing = 10 * 60; consensus.fPowAllowMinDifficultyBlocks = true; - consensus.enforce_BIP94 = true; + consensus.enforce_BIP94 = opts.enforce_bip94; 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/kernel/chainparams.h b/src/kernel/chainparams.h index c4584600fdf..f7ea141c37c 100644 --- a/src/kernel/chainparams.h +++ b/src/kernel/chainparams.h @@ -155,6 +155,7 @@ class CChainParams std::unordered_map version_bits_parameters{}; std::unordered_map activation_heights{}; bool fastprune{false}; + bool enforce_bip94{false}; }; static std::unique_ptr RegTest(const RegTestOptions& options); diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py index aca71933ec5..ee617069ab6 100755 --- a/test/functional/mining_basic.py +++ b/test/functional/mining_basic.py @@ -122,6 +122,7 @@ def test_blockmintxfee_parameter(self): def test_timewarp(self): self.log.info("Test timewarp attack mitigation (BIP94)") node = self.nodes[0] + self.restart_node(0, extra_args=['-test=bip94']) self.log.info("Mine until the last block of the retarget period") blockchain_info = self.nodes[0].getblockchaininfo()