From fc7dfb3df5b932cc015817c4461e7017601d607f Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Fri, 25 Oct 2024 13:49:47 -0400 Subject: [PATCH 1/2] test: Don't enforce BIP94 on regtest unless specified by arg The added regtest option -test=bip94 is only used in the functional test for BIP94. This is done because the default regtest consensus rules should aim to follow to mainnet, not testnet. --- src/chainparams.cpp | 1 + src/common/args.cpp | 1 + src/kernel/chainparams.cpp | 2 +- src/kernel/chainparams.h | 1 + test/functional/mining_basic.py | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) 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 @@ public: 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 @@ public: 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 @@ class MiningTest(BitcoinTestFramework): 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() From e60cecc8115d3b28be076792baa5e4ea26d353a6 Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Mon, 28 Oct 2024 11:24:28 -0400 Subject: [PATCH 2/2] doc: add release note for 31156 --- doc/release-notes-31156.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 doc/release-notes-31156.md 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)