diff --git a/src/chainparams.cpp b/src/chainparams.cpp index e5c1735fb6..10f122424b 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -214,6 +214,12 @@ public: consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1628640000; // August 11th, 2021 consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 709632; // Approximately November 12th, 2021 + // Simplicity + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 24; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].min_activation_height = 0; // No activation delay + consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000002927cdceccbd5209e81e80db"); consensus.defaultAssumeValid = uint256S("0x000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091"); // 724466 @@ -354,6 +360,12 @@ public: consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1628640000; // August 11th, 2021 consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay + // Simplicity + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 24; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].min_activation_height = 0; // No activation delay + consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000064728c7be6fe4b2f961"); consensus.defaultAssumeValid = uint256S("0x00000000000163cfb1f97c4e4098a3692c8053ad9cab5ad9c86b338b5c00b8b7"); // 2143398 @@ -514,6 +526,12 @@ public: consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay + // Simplicity + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 24; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].min_activation_height = 0; // No activation delay + // ELEMENTS: copied from Main consensus.genesis_subsidy = 50*COIN; consensus.connect_genesis_outputs = false; @@ -607,6 +625,12 @@ public: consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nPeriod = 128; // test ability to change from default consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nThreshold = 128; + // Simplicity + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 24; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].min_activation_height = 0; // No activation delay + consensus.nMinimumChainWork = uint256{}; consensus.defaultAssumeValid = uint256{}; @@ -1257,6 +1281,12 @@ public: consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nPeriod = 10080; // one week... consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nThreshold = 10080; // ...of 100% signalling + // Simplicity + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].bit = 24; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; + consensus.vDeployments[Consensus::DEPLOYMENT_SIMPLICITY].min_activation_height = 0; // No activation delay + // Activated from block 1,000,000. consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].bit = 25; // Allow blocksigners to delay activation. diff --git a/src/consensus/params.h b/src/consensus/params.h index fd852b4c02..0162247285 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -34,10 +34,11 @@ enum DeploymentPos : uint16_t { DEPLOYMENT_TESTDUMMY, DEPLOYMENT_TAPROOT, // Deployment of Schnorr/Taproot (BIPs 340-342) DEPLOYMENT_DYNA_FED, // Deployment of dynamic federation + DEPLOYMENT_SIMPLICITY, // Deployment of Simplicity // NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp MAX_VERSION_BITS_DEPLOYMENTS }; -constexpr bool ValidDeployment(DeploymentPos dep) { return DEPLOYMENT_TESTDUMMY <= dep && dep <= DEPLOYMENT_DYNA_FED; } +constexpr bool ValidDeployment(DeploymentPos dep) { return DEPLOYMENT_TESTDUMMY <= dep && dep < MAX_VERSION_BITS_DEPLOYMENTS; } /** * Struct for each individual consensus rule change using BIP9. diff --git a/src/deploymentinfo.cpp b/src/deploymentinfo.cpp index ddb4d82acb..874606acf3 100644 --- a/src/deploymentinfo.cpp +++ b/src/deploymentinfo.cpp @@ -19,6 +19,10 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B /*.name =*/ "dynafed", /*.gbt_force =*/ true, }, + { + /*.name =*/ "simplicity", + /*.gbt_force =*/ true, + }, }; std::string DeploymentName(Consensus::BuriedDeployment dep) diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index ee8d972b0e..8bc7c1d69c 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -1653,7 +1653,7 @@ static std::vector AllConsensusFlags() { std::vector ret; - for (unsigned int i = 0; i < 128; ++i) { + for (unsigned int i = 0; i < 256; ++i) { unsigned int flag = 0; if (i & 1) flag |= SCRIPT_VERIFY_P2SH; if (i & 2) flag |= SCRIPT_VERIFY_DERSIG; @@ -1662,11 +1662,14 @@ static std::vector AllConsensusFlags() if (i & 16) flag |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY; if (i & 32) flag |= SCRIPT_VERIFY_WITNESS; if (i & 64) flag |= SCRIPT_VERIFY_TAPROOT; + if (i & 128) flag |= SCRIPT_VERIFY_SIMPLICITY; // SCRIPT_VERIFY_WITNESS requires SCRIPT_VERIFY_P2SH if (flag & SCRIPT_VERIFY_WITNESS && !(flag & SCRIPT_VERIFY_P2SH)) continue; // SCRIPT_VERIFY_TAPROOT requires SCRIPT_VERIFY_WITNESS if (flag & SCRIPT_VERIFY_TAPROOT && !(flag & SCRIPT_VERIFY_WITNESS)) continue; + // SCRIPT_VERIFY_SIMPLICITY requires SCRIPT_VERIFY_TAPROOT + if (flag & SCRIPT_VERIFY_SIMPLICITY && !(flag & SCRIPT_VERIFY_TAPROOT)) continue; ret.push_back(flag); } diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 8426288801..16b92acef3 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -64,6 +64,7 @@ static std::map mapFlagNames = { {std::string("DISCOURAGE_UPGRADABLE_PUBKEYTYPE"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE}, {std::string("DISCOURAGE_OP_SUCCESS"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_OP_SUCCESS}, {std::string("DISCOURAGE_UPGRADABLE_TAPROOT_VERSION"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION}, + {std::string("SIMPLICITY"), (unsigned int)SCRIPT_VERIFY_SIMPLICITY}, }; unsigned int ParseScriptFlags(std::string strFlags) diff --git a/src/validation.cpp b/src/validation.cpp index b6fc6d4fd7..d62f942720 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1072,6 +1072,10 @@ bool MemPoolAccept::PolicyScriptChecks(const ATMPArgs& args, Workspace& ws) scriptVerifyFlags |= SCRIPT_SIGHASH_RANGEPROOF; } + if (DeploymentActiveAfter(m_active_chainstate.m_chain.Tip(), args.m_chainparams.GetConsensus(), Consensus::DEPLOYMENT_SIMPLICITY)) { + scriptVerifyFlags |= SCRIPT_VERIFY_SIMPLICITY; + } + // Check input scripts and signatures. // This is done last to help prevent CPU exhaustion denial-of-service attacks. if (!CheckInputScripts(tx, state, m_view, scriptVerifyFlags, true, false, ws.m_precomputed_txdata)) { @@ -2049,6 +2053,10 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens flags |= SCRIPT_SIGHASH_RANGEPROOF; } + if (DeploymentActiveAfter(pindex->pprev, consensusparams, Consensus::DEPLOYMENT_SIMPLICITY)) { + flags |= SCRIPT_VERIFY_SIMPLICITY; + } + return flags; } diff --git a/test/functional/feature_taproot.py b/test/functional/feature_taproot.py index 06dcf56926..ce8d88e13d 100755 --- a/test/functional/feature_taproot.py +++ b/test/functional/feature_taproot.py @@ -37,6 +37,7 @@ from test_framework.script import ( CScriptOp, hash256, LEAF_VERSION_TAPSCRIPT, + LEAF_VERSION_TAPSIMPLICITY, LegacySignatureMsg, LOCKTIME_THRESHOLD, MAX_SCRIPT_ELEMENT_SIZE, @@ -1093,8 +1094,8 @@ def spenders_taproot_active(): # Future leaf versions for leafver in range(0, 0x100, 2): - if leafver == LEAF_VERSION_TAPSCRIPT or leafver == ANNEX_TAG: - # Skip the defined LEAF_VERSION_TAPSCRIPT, and the ANNEX_TAG which is not usable as leaf version + if leafver in [LEAF_VERSION_TAPSCRIPT, LEAF_VERSION_TAPSIMPLICITY, ANNEX_TAG]: + # Skip allocated tapleaf versions and the ANNEX_TAG which is not usable as leaf version continue scripts = [ ("bare_c0", CScript([OP_NOP])), diff --git a/test/functional/test_framework/script.py b/test/functional/test_framework/script.py index de83cafbda..a985b31971 100644 --- a/test/functional/test_framework/script.py +++ b/test/functional/test_framework/script.py @@ -35,6 +35,7 @@ LOCKTIME_THRESHOLD = 500000000 ANNEX_TAG = 0x50 LEAF_VERSION_TAPSCRIPT = 0xc4 +LEAF_VERSION_TAPSIMPLICITY = 0xbe def hash160(s): return ripemd160(sha256(s))