From fa11fecf0dac44846a08e1b325547641f2eca957 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 1 Jul 2021 19:58:16 +0200 Subject: [PATCH 1/2] doc: Move buried deployment doc to the enum that enumerates them This is more visible than a comment hidden in an RPC helper function. --- src/consensus/params.h | 10 ++++++---- src/rpc/blockchain.cpp | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/consensus/params.h b/src/consensus/params.h index 174f4677fa0..9205cfee874 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -11,8 +11,11 @@ namespace Consensus { -enum BuriedDeployment : int16_t -{ +/** + * A buried deployment is one where the height of the activation has been hardcoded into + * the client implementation long after the consensus change has activated. See BIP 90. + */ +enum BuriedDeployment : int16_t { // buried deployments get negative values to avoid overlap with DeploymentPos DEPLOYMENT_HEIGHTINCB = std::numeric_limits::min(), DEPLOYMENT_CLTV, @@ -22,8 +25,7 @@ enum BuriedDeployment : int16_t }; constexpr bool ValidDeployment(BuriedDeployment dep) { return DEPLOYMENT_HEIGHTINCB <= dep && dep <= DEPLOYMENT_SEGWIT; } -enum DeploymentPos : uint16_t -{ +enum DeploymentPos : uint16_t { DEPLOYMENT_TESTDUMMY, DEPLOYMENT_TAPROOT, // Deployment of Schnorr/Taproot (BIPs 340-342) // NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index b630458f234..e08dad2eb09 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1350,8 +1350,6 @@ static RPCHelpMan verifychain() static void SoftForkDescPushBack(const CBlockIndex* active_chain_tip, UniValue& softforks, const Consensus::Params& params, Consensus::BuriedDeployment dep) { // For buried deployments. - // A buried deployment is one where the height of the activation has been hardcoded into - // the client implementation long after the consensus change has activated. See BIP 90. // Buried deployments with activation height value of // std::numeric_limits::max() are disabled and thus hidden. if (!DeploymentEnabled(params, dep)) return; From fa5658ed077bfb02b6281d642dc649abdb99b6ee Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 1 Jul 2021 20:29:21 +0200 Subject: [PATCH 2/2] Use DeploymentEnabled to hide VB deployments The helper was previously unused. This commit changes it to be more meaningful and puts it to use. See previous discussion at https://github.com/bitcoin/bitcoin/pull/19438/files#r650687320 --- src/deploymentstatus.h | 2 +- src/rpc/blockchain.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/deploymentstatus.h b/src/deploymentstatus.h index 84c5e54698c..f95c5996f5e 100644 --- a/src/deploymentstatus.h +++ b/src/deploymentstatus.h @@ -49,7 +49,7 @@ inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::Buried inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::DeploymentPos dep) { assert(Consensus::ValidDeployment(dep)); - return params.vDeployments[dep].nTimeout != 0; + return params.vDeployments[dep].nStartTime != Consensus::BIP9Deployment::NEVER_ACTIVE; } #endif // BITCOIN_DEPLOYMENTSTATUS_H diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index e08dad2eb09..c4a89c9772a 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1350,8 +1350,7 @@ static RPCHelpMan verifychain() static void SoftForkDescPushBack(const CBlockIndex* active_chain_tip, UniValue& softforks, const Consensus::Params& params, Consensus::BuriedDeployment dep) { // For buried deployments. - // Buried deployments with activation height value of - // std::numeric_limits::max() are disabled and thus hidden. + if (!DeploymentEnabled(params, dep)) return; UniValue rv(UniValue::VOBJ); @@ -1366,8 +1365,8 @@ static void SoftForkDescPushBack(const CBlockIndex* active_chain_tip, UniValue& static void SoftForkDescPushBack(const CBlockIndex* active_chain_tip, UniValue& softforks, const Consensus::Params& consensusParams, Consensus::DeploymentPos id) { // For BIP9 deployments. - // Deployments that are never active are hidden. - if (consensusParams.vDeployments[id].nStartTime == Consensus::BIP9Deployment::NEVER_ACTIVE) return; + + if (!DeploymentEnabled(consensusParams, id)) return; UniValue bip9(UniValue::VOBJ); const ThresholdState thresholdState = g_versionbitscache.State(active_chain_tip, consensusParams, id);