From 9be81463eac2f331a1b87d2d3a597aad963fdd8e Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Wed, 30 Aug 2023 20:15:10 +1000 Subject: [PATCH] Add ANYPREVOUT deployment --- src/consensus/params.h | 1 + src/deploymentinfo.cpp | 4 ++++ src/kernel/chainparams.cpp | 9 +++++++++ src/rpc/blockchain.cpp | 1 + src/validation.cpp | 5 +++++ test/functional/rpc_blockchain.py | 18 ++++++++++++++++-- 6 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/consensus/params.h b/src/consensus/params.h index f93258bfce2c33..501ab73205252e 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -33,6 +33,7 @@ constexpr bool ValidDeployment(BuriedDeployment dep) { return dep <= DEPLOYMENT_ enum DeploymentPos : uint16_t { DEPLOYMENT_TESTDUMMY, DEPLOYMENT_CHECKTEMPLATEVERIFY, // Deployment of CTV (BIP 119) + DEPLOYMENT_ANYPREVOUT, // NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp MAX_VERSION_BITS_DEPLOYMENTS }; diff --git a/src/deploymentinfo.cpp b/src/deploymentinfo.cpp index 94c848f578e06f..a6f954653963ae 100644 --- a/src/deploymentinfo.cpp +++ b/src/deploymentinfo.cpp @@ -19,6 +19,10 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B /*.name =*/ "checktemplateverify", /*.gbt_force =*/ true, }, + { + /*.name =*/ "anyprevout", + /*.gbt_force =*/ true, + }, }; std::string DeploymentName(Consensus::BuriedDeployment dep) diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp index 6f0be56d6a79c6..36825e9fc7de85 100644 --- a/src/kernel/chainparams.cpp +++ b/src/kernel/chainparams.cpp @@ -143,6 +143,7 @@ class CMainParams : public CChainParams { consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = SetupDeployment{.activate = 0x30000000, .abandon = 0, .never = true}; consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .never = true}; + consensus.vDeployments[Consensus::DEPLOYMENT_ANYPREVOUT] = SetupDeployment{.activate = 0x60007600, .abandon = 0x40007600, .never = true}; consensus.nMinimumChainWork = uint256{"000000000000000000000000000000000000000088e186b70e0862c193ec44d6"}; consensus.defaultAssumeValid = uint256{"000000000000000000011c5890365bdbe5d25b97ce0057589acaef4f1a57263f"}; // 856760 @@ -260,6 +261,7 @@ class CTestNetParams : public CChainParams { consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = SetupDeployment{.activate = 0x30000000, .abandon = 0, .never = true}; consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .never = true}; + consensus.vDeployments[Consensus::DEPLOYMENT_ANYPREVOUT] = SetupDeployment{.activate = 0x60007600, .abandon = 0x40007600, .never = true}; consensus.nMinimumChainWork = uint256{"000000000000000000000000000000000000000000000f209695166be8b61fa9"}; consensus.defaultAssumeValid = uint256{"000000000000000465b1a66c9f386308e8c75acef9201f3f577811da09fc90ad"}; // 2873500 @@ -489,6 +491,12 @@ class SigNetParams : public CChainParams { .activate = 0x60007700, .abandon = 0x40007700, }; + consensus.vDeployments[Consensus::DEPLOYMENT_ANYPREVOUT] = SetupDeployment{ + .start = 1625875200, // 2021-07-10 + .timeout = 1941408000, // 2031-07-10 + .activate = 0x60007600, + .abandon = 0x40007600, + }; RenounceDeployments(options.renounce, consensus.vDeployments); @@ -563,6 +571,7 @@ class CRegTestParams : public CChainParams // 0x3000_0000 = bit 28 plus versionbits signalling; 0x5000_0000 = bit 38 plus VERSIONBITS_TOP_ABANDON consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = SetupDeployment{.start = 0, .timeout = Consensus::HereticalDeployment::NO_TIMEOUT, .activate = 0x30000000, .abandon = 0x50000000}; consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .always = true}; + consensus.vDeployments[Consensus::DEPLOYMENT_ANYPREVOUT] = SetupDeployment{.activate = 0x60007600, .abandon = 0x40007600, .always = true}; consensus.nMinimumChainWork = uint256{}; consensus.defaultAssumeValid = uint256{}; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 1cc2ed8c93088e..717f990cf07471 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1394,6 +1394,7 @@ UniValue DeploymentInfo(const CBlockIndex* blockindex, const ChainstateManager& SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_TESTDUMMY); SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_TAPROOT); SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY); + SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_ANYPREVOUT); return softforks; } } // anon namespace diff --git a/src/validation.cpp b/src/validation.cpp index b0d71b357983a9..c3c28c13a65250 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2372,6 +2372,11 @@ unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const Chainstat flags |= SCRIPT_VERIFY_DEFAULT_CHECK_TEMPLATE_VERIFY_HASH; } + // Enforce ANYPREVOUT (BIP118) + if ((flags & SCRIPT_VERIFY_TAPROOT) && DeploymentActiveAt(block_index, chainman, Consensus::DEPLOYMENT_ANYPREVOUT)) { + flags |= SCRIPT_VERIFY_ANYPREVOUT; + } + return flags; } diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 9edca26e695da3..1b35db6ca93cb5 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -197,7 +197,7 @@ def check_signalling_deploymentinfo_result(self, gdi_result, height, blockhash): assert_equal(gdi_result, { "hash": blockhash, "height": height, - "script_flags": ["CHECKLOCKTIMEVERIFY","CHECKSEQUENCEVERIFY","DEFAULT_CHECK_TEMPLATE_VERIFY_HASH","DERSIG","NULLDUMMY","P2SH","TAPROOT","WITNESS"], + "script_flags": ["ANYPREVOUT","CHECKLOCKTIMEVERIFY","CHECKSEQUENCEVERIFY","DEFAULT_CHECK_TEMPLATE_VERIFY_HASH","DERSIG","NULLDUMMY","P2SH","TAPROOT","WITNESS"], "deployments": { 'bip34': {'type': 'buried', 'active': True, 'height': 2}, 'bip66': {'type': 'buried', 'active': True, 'height': 3}, @@ -233,7 +233,21 @@ def check_signalling_deploymentinfo_result(self, gdi_result, height, blockhash): }, 'height': 0, 'active': True - }, + }, + 'anyprevout': { + 'type': 'heretical', + 'heretical': { + 'binana-id': 'BIN-2016-0118-000', + 'start_time': -1, + 'timeout': 0x7fffffffffffffff, # testdummy does not have a timeout so is set to the max int64 value + 'period': 144, + 'status': 'active', + 'status_next': 'active', + 'since': 0, + }, + 'active': True, + 'height': 0, + }, } })