diff --git a/doc/release-notes-6189.md b/doc/release-notes-6189.md index b88a030d8258..b4b2678516df 100644 --- a/doc/release-notes-6189.md +++ b/doc/release-notes-6189.md @@ -2,7 +2,5 @@ Tests ----- - For the `regtest` network the activation heights of several softforks were - changed. (dash#6189) - * BIP 34 (blockheight in coinbase) from 500 to 2 - * BIP 66 (DERSIG) from 1251 to 102 - * BIP 65 (CLTV) from 1351 to 111 + set to block height 1. They can be changed by the runtime setting + `-testactivationheight=name@height`. (dash#6214) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index c67d349e542b..2798deed85a8 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -794,19 +794,19 @@ class CRegTestParams : public CChainParams { consensus.nGovernanceMinQuorum = 1; consensus.nGovernanceFilterElements = 100; consensus.nMasternodeMinimumConfirmations = 1; - consensus.BIP34Height = 2; // BIP34 activated on regtest (Block at height 1 not enforced for testing purposes) + consensus.BIP34Height = 1; // Always active unless overridden consensus.BIP34Hash = uint256(); - consensus.BIP65Height = 111; // BIP65 activated on regtest (Block at height 110 and earlier not enforced for testing purposes) - consensus.BIP66Height = 102; // BIP66 activated on regtest (Block at height 101 and earlier not enforced for testing purposes) - consensus.BIP147Height = 432; // BIP147 activated on regtest (Used in functional tests) - consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests) - consensus.DIP0001Height = 2000; + consensus.BIP65Height = 1; // Always active unless overridden + consensus.BIP66Height = 1; // Always active unless overridden + consensus.BIP147Height = 1; // Always active unless overridden + consensus.CSVHeight = 1; // Always active unless overridden + consensus.DIP0001Height = 1; // Always active unless overridden consensus.DIP0003Height = 432; consensus.DIP0003EnforcementHeight = 500; consensus.DIP0003EnforcementHash = uint256(); - consensus.DIP0008Height = 432; - consensus.BRRHeight = 1000; // see block_reward_reallocation_tests - consensus.DIP0020Height = 300; + consensus.DIP0008Height = 1; // Always active unless overridden + consensus.BRRHeight = 1; // Always active unless overridden + consensus.DIP0020Height = 1; consensus.DIP0024Height = 900; consensus.DIP0024QuorumsHeight = 900; consensus.V19Height = 900; @@ -1031,8 +1031,47 @@ class CRegTestParams : public CChainParams { void UpdateLLMQInstantSendDIP0024FromArgs(const ArgsManager& args); }; +static void MaybeUpdateHeights(const ArgsManager& args, Consensus::Params& consensus) +{ + for (const std::string& arg : args.GetArgs("-testactivationheight")) { + const auto found{arg.find('@')}; + if (found == std::string::npos) { + throw std::runtime_error(strprintf("Invalid format (%s) for -testactivationheight=name@height.", arg)); + } + const auto name{arg.substr(0, found)}; + const auto value{arg.substr(found + 1)}; + int32_t height; + if (!ParseInt32(value, &height) || height < 0 || height >= std::numeric_limits::max()) { + throw std::runtime_error(strprintf("Invalid height value (%s) for -testactivationheight=name@height.", arg)); + } + if (name == "bip147") { + consensus.BIP147Height = int{height}; + } else if (name == "bip34") { + consensus.BIP34Height = int{height}; + } else if (name == "dersig") { + consensus.BIP66Height = int{height}; + } else if (name == "cltv") { + consensus.BIP65Height = int{height}; + } else if (name == "csv") { + consensus.CSVHeight = int{height}; + } else if (name == "brr") { + consensus.BRRHeight = int{height}; + } else if (name == "dip0001") { + consensus.DIP0001Height = int{height}; + } else if (name == "dip0008") { + consensus.DIP0008Height = int{height}; + } else if (name == "dip0020") { + consensus.DIP0020Height = int{height}; + } else { + throw std::runtime_error(strprintf("Invalid name (%s) for -testactivationheight=name@height.", arg)); + } + } +} + void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args) { + MaybeUpdateHeights(args, consensus); + if (!args.IsArgSet("-vbparams")) return; for (const std::string& strDeployment : args.GetArgs("-vbparams")) { diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index d18ba6da8d8f..c9700e3626a7 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -22,6 +22,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman) argsman.AddArg("-dip3params=:", "Override DIP3 activation and enforcement heights (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-dip8params=", "Override DIP8 activation height (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-bip147height=", "Override BIP147 activation height (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); + argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (bip147, bip34, dersig, cltv, csv, brr, dip0001, dip0008, dip0020). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); argsman.AddArg("-highsubsidyblocks=", "The number of blocks with a higher than normal subsidy to mine at the start of a chain. Block after that height will have fixed subsidy base. (default: 0, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-highsubsidyfactor=", "The factor to multiply the normal block subsidy by while in the highsubsidyblocks window of a chain (default: 1, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-llmqchainlocks=", "Override the default LLMQ type used for ChainLocks. Allows using ChainLocks with smaller LLMQs. (default: llmq_devnet, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index e5b7613650cf..3a30fec2c0b2 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -81,9 +81,6 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con m_mn_sync.UpdatedBlockTip(WITH_LOCK(::cs_main, return m_chainman.m_best_header), pindexNew, fInitialDownload); - // Update global DIP0001 activation status - fDIP0001ActiveAtTip = pindexNew->nHeight >= Params().GetConsensus().DIP0001Height; - if (fInitialDownload) return; diff --git a/src/net.cpp b/src/net.cpp index a61361bc7001..73569a96b8a4 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -33,7 +33,6 @@ #include #include #include -#include // for fDIP0001ActiveAtTip #include #include @@ -4079,7 +4078,7 @@ bool CConnman::OutboundTargetReached(bool historicalBlockServingLimit) const { // keep a large enough buffer to at least relay each block once const std::chrono::seconds timeLeftInCycle = GetMaxOutboundTimeLeftInCycle_(); - const uint64_t buffer = timeLeftInCycle / std::chrono::minutes{10} * MaxBlockSize(fDIP0001ActiveAtTip); + const uint64_t buffer = timeLeftInCycle / std::chrono::minutes{10} * MaxBlockSize(); if (buffer >= nMaxOutboundLimit || nMaxOutboundTotalBytesSentInCycle >= nMaxOutboundLimit - buffer) return true; } diff --git a/src/test/block_reward_reallocation_tests.cpp b/src/test/block_reward_reallocation_tests.cpp index c4affec2eec3..bd87cf7f0673 100644 --- a/src/test/block_reward_reallocation_tests.cpp +++ b/src/test/block_reward_reallocation_tests.cpp @@ -35,7 +35,11 @@ using SimpleUTXOMap = std::map>; struct TestChainBRRBeforeActivationSetup : public TestChainSetup { // Force fast DIP3 activation - TestChainBRRBeforeActivationSetup() : TestChainSetup(497, {"-dip3params=30:50", "-vbparams=mn_rr:0:999999999999:0:20:16:12:5:1"}) {} + TestChainBRRBeforeActivationSetup() : + TestChainSetup(497, {"-dip3params=30:50", "-testactivationheight=brr@1000", + "-vbparams=mn_rr:0:999999999999:0:20:16:12:5:1"}) + { + } }; static SimpleUTXOMap BuildSimpleUtxoMap(const std::vector& txs) diff --git a/src/test/txvalidation_tests.cpp b/src/test/txvalidation_tests.cpp index 0f637df308b1..65afd6a7960b 100644 --- a/src/test/txvalidation_tests.cpp +++ b/src/test/txvalidation_tests.cpp @@ -15,6 +15,12 @@ #include +struct TestChain100NoDIP0001Setup : public TestChain100Setup { + TestChain100NoDIP0001Setup() + : TestChain100Setup{{"-testactivationheight=dip0001@2000"}} {} +}; + + BOOST_AUTO_TEST_SUITE(txvalidation_tests) /** @@ -69,7 +75,7 @@ inline CTransactionRef create_placeholder_tx(size_t num_inputs, size_t num_outpu return MakeTransactionRef(mtx); } -BOOST_FIXTURE_TEST_CASE(package_tests, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(package_tests, TestChain100NoDIP0001Setup) { LOCK(cs_main); unsigned int initialPoolSize = m_node.mempool->size(); diff --git a/src/test/txvalidationcache_tests.cpp b/src/test/txvalidationcache_tests.cpp index b6ad88af57fa..f8db20c73e9a 100644 --- a/src/test/txvalidationcache_tests.cpp +++ b/src/test/txvalidationcache_tests.cpp @@ -12,11 +12,16 @@ #include +struct Dersig100Setup : public TestChain100Setup { + Dersig100Setup() + : TestChain100Setup{{"-testactivationheight=dersig@102"}} {} +}; + bool CheckInputScripts(const CTransaction& tx, TxValidationState &state, const CCoinsViewCache &inputs, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData& txdata, std::vector *pvChecks); BOOST_AUTO_TEST_SUITE(txvalidationcache_tests) -BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, Dersig100Setup) { // Make sure skipping validation of transactions that were // validated going into the memory pool does not allow @@ -144,7 +149,7 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail } } -BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup) { // Test that passing CheckInputScripts with one set of script flags doesn't imply // that we would pass again with a different set of flags. diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 72b723645e0a..3e8fa5521c82 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -306,6 +306,11 @@ TestingSetup::~TestingSetup() m_node.banman.reset(); } +TestChain100Setup::TestChain100Setup(const std::vector& extra_args) + : TestChainSetup{100, extra_args} +{ +} + TestChainSetup::TestChainSetup(int num_blocks, const std::vector& extra_args) : RegTestingSetup(extra_args) { @@ -336,7 +341,7 @@ TestChainSetup::TestChainSetup(int num_blocks, const std::vector& e /* TestChainDIP3Setup */ { 431, uint256S("0x49db248651517f3fc3725fbbc7087db90552d487d11e0962b0148fc4788aeb77") }, /* TestChainBRRBeforeActivationSetup */ - { 497, uint256S("0x15445246f9f9fd4fdb1021dd8278ace7246b3e3cb545e1632a277d3a02eb011f") }, + { 497, uint256S("0x626036f6adff51fbbdd0c609e827ef6a3730ce2498a3eb33edeb27092d006170") }, /* TestChainV19BeforeActivationSetup */ { 894, uint256S("0x03cbf1871d7d915cda10aded00ced45f71a4e2acf6a3c7a77a1ff488267dd1cd") }, /* TestChainV19Setup */ diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 7b623355bf2c..28af81f0f122 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -177,7 +177,7 @@ struct TestChainSetup : public RegTestingSetup * Testing fixture that pre-creates a 100-block REGTEST-mode block chain */ struct TestChain100Setup : public TestChainSetup { - TestChain100Setup() : TestChainSetup(100) {} + TestChain100Setup(const std::vector& extra_args = {}); }; struct TestChainDIP3Setup : public TestChainSetup diff --git a/src/validation.cpp b/src/validation.cpp index dd463bcc5642..bfd2bb06747b 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -114,9 +114,6 @@ bool fCheckBlockIndex = false; bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED; int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; -// TODO: drop this global variable. Used by net.cpp module only -std::atomic fDIP0001ActiveAtTip{false}; - uint256 hashAssumeValid; arith_uint256 nMinimumChainWork; diff --git a/src/validation.h b/src/validation.h index 2764afb42f5c..ec9237f267aa 100644 --- a/src/validation.h +++ b/src/validation.h @@ -142,8 +142,6 @@ extern int64_t nMaxTipAge; extern bool fLargeWorkForkFound; extern bool fLargeWorkInvalidChainFound; -extern std::atomic fDIP0001ActiveAtTip; - /** Block hash whose ancestors we will assume to have valid scripts without checking them. */ extern uint256 hashAssumeValid; diff --git a/test/functional/feature_bip68_sequence.py b/test/functional/feature_bip68_sequence.py index db95f28a5148..d434a51da553 100755 --- a/test/functional/feature_bip68_sequence.py +++ b/test/functional/feature_bip68_sequence.py @@ -38,8 +38,14 @@ class BIP68Test(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 self.extra_args = [ - ["-acceptnonstdtxn=1"], - ["-acceptnonstdtxn=0"], + [ + '-testactivationheight=csv@432', + "-acceptnonstdtxn=1", + ], + [ + '-testactivationheight=csv@432', + "-acceptnonstdtxn=0", + ], ] def skip_test_if_missing_module(self): diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py index e4bc12a46a70..50140901eafc 100755 --- a/test/functional/feature_block.py +++ b/test/functional/feature_block.py @@ -12,7 +12,6 @@ create_coinbase, create_tx_with_script, get_legacy_sigopcount_block, - MAX_BLOCK_SIGOPS, ) from test_framework.key import ECKey from test_framework.messages import ( @@ -22,7 +21,6 @@ CTransaction, CTxIn, CTxOut, - MAX_BLOCK_SIZE, uint256_from_compact, uint256_from_str, ) @@ -53,6 +51,11 @@ from test_framework.util import assert_equal from data import invalid_txs +# This functional test assumes DIP0001 is disabled +# Blocks after activation DIP0001 can not have a transaction bigger than 100k bytes +MAX_BLOCK_SIZE = 1000000 +MAX_BLOCK_SIGOPS = 20000 + # Use this class for tests that require behavior other than normal p2p behavior. # For now, it is used to serialize a bloated varint (b64). class CBrokenBlock(CBlock): @@ -83,7 +86,12 @@ def set_test_params(self): # which causes RPC to hang, so we need to increase RPC timeouts self.rpc_timeout = 180 # Must set '-dip3params=2000:2000' to create pre-dip3 blocks only - self.extra_args = [['-dip3params=2000:2000', '-acceptnonstdtxn=1']] # This is a consensus block test, we don't care about tx policy + self.extra_args = [[ + '-dip3params=2000:2000', + '-acceptnonstdtxn=1', # This is a consensus block test, we don't care about tx policy + '-testactivationheight=bip34@2', + '-testactivationheight=dip0001@2000', + ]] def setup_nodes(self): self.add_nodes(self.num_nodes, self.extra_args) diff --git a/test/functional/feature_cltv.py b/test/functional/feature_cltv.py index 60a0ec453814..00b0800e975e 100755 --- a/test/functional/feature_cltv.py +++ b/test/functional/feature_cltv.py @@ -8,7 +8,6 @@ """ from test_framework.blocktools import ( - CLTV_HEIGHT, create_block, create_coinbase, ) @@ -79,10 +78,14 @@ def cltv_validate(tx, height): cltv_modify_tx(tx, prepend_scriptsig=scheme[0], nsequence=scheme[1], nlocktime=scheme[2]) +CLTV_HEIGHT = 111 + + class BIP65Test(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 self.extra_args = [[ + f'-testactivationheight=cltv@{CLTV_HEIGHT}', '-whitelist=noban@127.0.0.1', '-dip3params=9000:9000', '-par=1', # Use only one script thread to get the exact reject reason for testing diff --git a/test/functional/feature_csv_activation.py b/test/functional/feature_csv_activation.py index 503f3eb24334..4502c74a2965 100755 --- a/test/functional/feature_csv_activation.py +++ b/test/functional/feature_csv_activation.py @@ -40,7 +40,6 @@ from itertools import product from test_framework.blocktools import ( - CSV_ACTIVATION_HEIGHT, create_block, create_coinbase, TIME_GENESIS_BLOCK, @@ -89,6 +88,9 @@ def all_rlt_txs(txs): return [tx['tx'] for tx in txs] +CSV_ACTIVATION_HEIGHT = 432 + + class BIP68_112_113Test(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 @@ -98,6 +100,7 @@ def set_test_params(self): '-peertimeout=999999', # bump because mocktime might cause a disconnect otherwise '-whitelist=noban@127.0.0.1', '-dip3params=2000:2000', + f'-testactivationheight=csv@{CSV_ACTIVATION_HEIGHT}', '-par=1', # Use only one script thread to get the exact reject reason for testing ]] self.supports_cli = False diff --git a/test/functional/feature_dersig.py b/test/functional/feature_dersig.py index 597bce5a7ef5..834e07e6fe01 100755 --- a/test/functional/feature_dersig.py +++ b/test/functional/feature_dersig.py @@ -8,7 +8,6 @@ """ from test_framework.blocktools import ( - DERSIG_HEIGHT, create_block, create_coinbase, ) @@ -43,10 +42,18 @@ def unDERify(tx): tx.vin[0].scriptSig = CScript(newscript) +DERSIG_HEIGHT = 102 + + class BIP66Test(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 - self.extra_args = [['-whitelist=noban@127.0.0.1', '-dip3params=9000:9000', '-par=1', '-vbparams=v20:0:999999999999:0:480:384:288:5:0']] # Use only one script thread to get the exact reject reason for testing + self.extra_args = [[ + f'-testactivationheight=dersig@{DERSIG_HEIGHT}', + '-whitelist=noban@127.0.0.1', + '-dip3params=9000:9000', + '-par=1', # Use only one script thread to get the exact log msg for testing + '-vbparams=v20:0:999999999999:0:480:384:288:5:0']] self.setup_clean_chain = True self.rpc_timeout = 240 @@ -81,7 +88,6 @@ def run_test(self): tip = self.nodes[0].getbestblockhash() block_time = self.nodes[0].getblockheader(tip)['mediantime'] + 1 block = create_block(int(tip, 16), create_coinbase(DERSIG_HEIGHT - 1), block_time) - block.nVersion = 2 block.vtx.append(spendtx) block.hashMerkleRoot = block.calc_merkle_root() block.rehash() @@ -108,7 +114,7 @@ def run_test(self): peer.sync_with_ping() self.log.info("Test that transactions with non-DER signatures cannot appear in a block") - block.nVersion = 3 + block.nVersion = 4 spendtx = self.create_tx(self.coinbase_txids[1]) unDERify(spendtx) @@ -129,7 +135,7 @@ def run_test(self): assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip) peer.sync_with_ping() - self.log.info("Test that a version 3 block with a DERSIG-compliant transaction is accepted") + self.log.info("Test that a block with a DERSIG-compliant transaction is accepted") block.vtx[1] = self.create_tx(self.coinbase_txids[1]) block.hashMerkleRoot = block.calc_merkle_root() block.rehash() diff --git a/test/functional/feature_dip0020_activation.py b/test/functional/feature_dip0020_activation.py index 020616b7f3ee..9ace934cb212 100755 --- a/test/functional/feature_dip0020_activation.py +++ b/test/functional/feature_dip0020_activation.py @@ -16,10 +16,14 @@ DISABLED_OPCODE_ERROR = "non-mandatory-script-verify-flag (Attempted to use a disabled opcode)" +DIP0020_HEIGHT = 300 class DIP0020ActivationTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 - self.extra_args = [["-acceptnonstdtxn=1"]] + self.extra_args = [[ + f'-testactivationheight=dip0020@{DIP0020_HEIGHT}', + "-acceptnonstdtxn=1", + ]] def skip_test_if_missing_module(self): self.skip_if_no_wallet() diff --git a/test/functional/feature_dip3_v19.py b/test/functional/feature_dip3_v19.py index 3ec14437d066..fd987c7be218 100755 --- a/test/functional/feature_dip3_v19.py +++ b/test/functional/feature_dip3_v19.py @@ -57,8 +57,6 @@ def run_test(self): if i != 0: self.connect_nodes(i, 0) - self.activate_dip8() - self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.wait_for_sporks_same() diff --git a/test/functional/feature_dip4_coinbasemerkleroots.py b/test/functional/feature_dip4_coinbasemerkleroots.py index 40bcac3d0a33..f0287c0796b5 100755 --- a/test/functional/feature_dip4_coinbasemerkleroots.py +++ b/test/functional/feature_dip4_coinbasemerkleroots.py @@ -17,6 +17,7 @@ from test_framework.test_framework import DashTestFramework from test_framework.util import assert_equal +DIP0008_HEIGHT = 432 # TODO: this helper used in many tests, find a new home for it class TestP2PConn(P2PInterface): @@ -42,8 +43,8 @@ def getmnlistdiff(self, baseBlockHash, blockHash): class LLMQCoinbaseCommitmentsTest(DashTestFramework): def set_test_params(self): - self.set_dash_test_params(4, 3, fast_dip3_enforcement=True) - + self.extra_args = [[ f'-testactivationheight=dip0008@{DIP0008_HEIGHT}', "-vbparams=testdummy:999999999999:999999999999" ]] * 4 + self.set_dash_test_params(4, 3, extra_args = self.extra_args, fast_dip3_enforcement=True) def run_test(self): # No IS or Chainlocks in this test self.bump_mocktime(1) @@ -240,6 +241,18 @@ def test_getmnlistdiff_base(self, baseBlockHash, blockHash): return d + def activate_dip8(self, slow_mode=False): + # NOTE: set slow_mode=True if you are activating dip8 after a huge reorg + # or nodes might fail to catch up otherwise due to a large + # (MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16 blocks) reorg error. + self.log.info("Wait for dip0008 activation") + while self.nodes[0].getblockcount() < DIP0008_HEIGHT: + self.bump_mocktime(10) + self.nodes[0].generate(10) + if slow_mode: + self.sync_blocks() + self.sync_blocks() + def test_dip8_quorum_merkle_root_activation(self, with_initial_quorum, slow_mode=False): if with_initial_quorum: self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) diff --git a/test/functional/feature_governance.py b/test/functional/feature_governance.py index 9cc92277023a..e5f7322cec1c 100755 --- a/test/functional/feature_governance.py +++ b/test/functional/feature_governance.py @@ -12,7 +12,7 @@ class DashGovernanceTest (DashTestFramework): def set_test_params(self): - self.v20_start_time = 1417713500 + self.v20_start_time = 1417713500 + 80 # using adjusted v20 deployment params to test an edge case where superblock maturity window is equal to deployment window size self.set_dash_test_params(6, 5, [["-budgetparams=10:10:10", f"-vbparams=v20:{self.v20_start_time}:999999999999:0:10:8:6:5:0"]] * 6, fast_dip3_enforcement=True) @@ -118,14 +118,16 @@ def run_test(self): self.expected_old_budget = satoshi_round("928.57142840") self.expected_v20_budget = satoshi_round("18.57142860") - self.activate_dip8() - self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 4070908800) self.nodes[0].sporkupdate("SPORK_9_SUPERBLOCKS_ENABLED", 0) self.wait_for_sporks_same() assert_equal(len(self.nodes[0].gobject("list-prepared")), 0) + # TODO: drop these extra 80 blocks - doesn't work without them + self.nodes[0].generate(80) + self.bump_mocktime(80) + self.nodes[0].generate(3) self.bump_mocktime(3) self.sync_blocks() diff --git a/test/functional/feature_llmq_chainlocks.py b/test/functional/feature_llmq_chainlocks.py index 4e1618b5824b..a7ce0d6a5d18 100755 --- a/test/functional/feature_llmq_chainlocks.py +++ b/test/functional/feature_llmq_chainlocks.py @@ -31,8 +31,6 @@ def run_test(self): if i != 1: self.connect_nodes(i, 1) - self.activate_dip8() - self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=False) self.activate_v20(expected_activation_height=1200) diff --git a/test/functional/feature_llmq_data_recovery.py b/test/functional/feature_llmq_data_recovery.py index 2ebdbec1ae2e..f6dcc395bbf0 100755 --- a/test/functional/feature_llmq_data_recovery.py +++ b/test/functional/feature_llmq_data_recovery.py @@ -144,7 +144,6 @@ def run_test(self): node.sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) node.sporkupdate("SPORK_21_QUORUM_ALL_CONNECTED", 0) self.wait_for_sporks_same() - self.activate_dip8() logger.info("Test automated DGK data recovery") # This two nodes will remain the only ones with valid DKG data diff --git a/test/functional/feature_llmq_dkgerrors.py b/test/functional/feature_llmq_dkgerrors.py index 0d687fe0e120..762dfe09bb4b 100755 --- a/test/functional/feature_llmq_dkgerrors.py +++ b/test/functional/feature_llmq_dkgerrors.py @@ -17,8 +17,6 @@ def set_test_params(self): self.set_dash_test_params(4, 3, [["-whitelist=127.0.0.1"]] * 4, fast_dip3_enforcement=True) def run_test(self): - self.activate_dip8() - self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.wait_for_sporks_same() diff --git a/test/functional/feature_llmq_evo.py b/test/functional/feature_llmq_evo.py index 6543b9fa6ab9..91edd74991f5 100755 --- a/test/functional/feature_llmq_evo.py +++ b/test/functional/feature_llmq_evo.py @@ -61,8 +61,6 @@ def run_test(self): if i != 0: self.connect_nodes(i, 0) - self.activate_dip8() - self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 1) self.wait_for_sporks_same() diff --git a/test/functional/feature_llmq_is_cl_conflicts.py b/test/functional/feature_llmq_is_cl_conflicts.py index 3af1b3504159..1eaf09ba3b55 100755 --- a/test/functional/feature_llmq_is_cl_conflicts.py +++ b/test/functional/feature_llmq_is_cl_conflicts.py @@ -54,8 +54,6 @@ def set_test_params(self): self.supports_cli = False def run_test(self): - self.activate_dip8() - self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn()) self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) diff --git a/test/functional/feature_llmq_is_retroactive.py b/test/functional/feature_llmq_is_retroactive.py index 37e6265baf92..d4e5bb142949 100755 --- a/test/functional/feature_llmq_is_retroactive.py +++ b/test/functional/feature_llmq_is_retroactive.py @@ -25,8 +25,6 @@ def set_test_params(self): self.set_dash_test_params(5, 4, [["-whitelist=127.0.0.1"], [], [], [], ["-minrelaytxfee=0.001"]], fast_dip3_enforcement=True) def run_test(self): - self.activate_dip8() - self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) # Turn mempool IS signing off self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 1) diff --git a/test/functional/feature_llmq_rotation.py b/test/functional/feature_llmq_rotation.py index 827c46738c61..cd8c9b64ff4e 100755 --- a/test/functional/feature_llmq_rotation.py +++ b/test/functional/feature_llmq_rotation.py @@ -69,8 +69,6 @@ def run_test(self): if i != 1: self.connect_nodes(i, 0) - self.activate_dip8() - self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.wait_for_sporks_same() diff --git a/test/functional/feature_maxuploadtarget.py b/test/functional/feature_maxuploadtarget.py index 76417b2c246d..7772739bb2d0 100755 --- a/test/functional/feature_maxuploadtarget.py +++ b/test/functional/feature_maxuploadtarget.py @@ -36,9 +36,8 @@ def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 self.extra_args = [[ - "-maxuploadtarget=200", - "-blockmaxsize=999000", - "-acceptnonstdtxn=1" + "-maxuploadtarget=400", + "-acceptnonstdtxn=1", ]] self.supports_cli = False @@ -95,7 +94,7 @@ def run_test(self): getdata_request = msg_getdata() getdata_request.inv.append(CInv(MSG_BLOCK, big_old_block)) - max_bytes_per_day = 200*1024*1024 + max_bytes_per_day = 400*1024*1024 daily_buffer = 144 * MAX_BLOCK_SIZE max_bytes_available = max_bytes_per_day - daily_buffer success_count = max_bytes_available // old_block_size diff --git a/test/functional/feature_notifications.py b/test/functional/feature_notifications.py index bdffbf3c9de5..44957d0eecec 100755 --- a/test/functional/feature_notifications.py +++ b/test/functional/feature_notifications.py @@ -100,7 +100,6 @@ def run_test(self): self.activate_v19(expected_activation_height=900) self.log.info("Activated v19 at height:" + str(self.nodes[0].getblockcount())) - self.activate_dip8() self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 4070908800) self.wait_for_sporks_same() diff --git a/test/functional/feature_nulldummy.py b/test/functional/feature_nulldummy.py index 6769aa6b5448..ecae98761356 100755 --- a/test/functional/feature_nulldummy.py +++ b/test/functional/feature_nulldummy.py @@ -50,7 +50,7 @@ def set_test_params(self): self.extra_args = [[ '-whitelist=127.0.0.1', '-dip3params=105:105', - '-bip147height=105', + f'-testactivationheight=bip147@{COINBASE_MATURITY + 5}', '-par=1', # Use only one script thread to get the exact reject reason for testing ]] * 2 diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py index 5c34f7de1654..cf9e78ece3ab 100755 --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -86,16 +86,16 @@ def set_test_params(self): # Create nodes 0 and 1 to mine. # Create node 2 to test pruning. - self.full_node_default_args = ["-dip3params=2000:2000", "-dip8params=2000", "-maxreceivebuffer=20000", "-blockmaxsize=999000", "-checkblocks=5"] + self.full_node_default_args = ["-dip3params=2000:2000", "-testactivationheight=dip0008@2000", "-maxreceivebuffer=20000", "-blockmaxsize=999000", "-checkblocks=5"] # Create nodes 3 and 4 to test manual pruning (they will be re-started with manual pruning later) # Create nodes 5 to test wallet in prune mode, but do not connect self.extra_args = [ self.full_node_default_args, self.full_node_default_args, - ["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance","-txindex=0","-maxreceivebuffer=20000","-prune=550"], - ["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance","-txindex=0","-maxreceivebuffer=20000","-blockmaxsize=999000"], - ["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance","-txindex=0","-maxreceivebuffer=20000","-blockmaxsize=999000"], - ["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance","-txindex=0","-prune=550"], + ["-dip3params=2000:2000", "-testactivationheight=dip0008@2000", "-disablegovernance","-txindex=0","-maxreceivebuffer=20000","-prune=550"], + ["-dip3params=2000:2000", "-testactivationheight=dip0008@2000", "-disablegovernance","-txindex=0","-maxreceivebuffer=20000","-blockmaxsize=999000"], + ["-dip3params=2000:2000", "-testactivationheight=dip0008@2000", "-disablegovernance","-txindex=0","-maxreceivebuffer=20000","-blockmaxsize=999000"], + ["-dip3params=2000:2000", "-testactivationheight=dip0008@2000", "-disablegovernance","-txindex=0","-prune=550"], ] self.rpc_timeout = 120 @@ -283,13 +283,13 @@ def reorg_back(self): def manual_test(self, node_number, use_timestamp): # at this point, node has 995 blocks and has not yet run in prune mode - self.start_node(node_number, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0"]) + self.start_node(node_number, extra_args=["-dip3params=2000:2000", "-testactivationheight=dip0008@2000", "-disablegovernance", "-txindex=0"]) node = self.nodes[node_number] assert_equal(node.getblockcount(), 995) assert_raises_rpc_error(-1, "Cannot prune blocks because node is not in prune mode", node.pruneblockchain, 500) # now re-start in manual pruning mode - self.restart_node(node_number, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=1"], expected_stderr=EXPECTED_STDERR_NO_GOV) + self.restart_node(node_number, extra_args=["-dip3params=2000:2000", "-testactivationheight=dip0008@2000", "-disablegovernance", "-txindex=0", "-prune=1"], expected_stderr=EXPECTED_STDERR_NO_GOV) node = self.nodes[node_number] assert_equal(node.getblockcount(), 995) @@ -358,14 +358,14 @@ def has_block(index): assert not has_block(3), "blk00003.dat is still there, should be pruned by now" # stop node, start back up with auto-prune at 550 MiB, make sure still runs - self.restart_node(node_number, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=550"], expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) + self.restart_node(node_number, extra_args=["-dip3params=2000:2000", "-testactivationheight=dip0008@2000", "-disablegovernance", "-txindex=0", "-prune=550"], expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) self.log.info("Success") def wallet_test(self): # check that the pruning node's wallet is still in good shape self.log.info("Stop and start pruning node to trigger wallet rescan") - self.restart_node(2, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=550"], expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) + self.restart_node(2, extra_args=["-dip3params=2000:2000", "-testactivationheight=dip0008@2000", "-disablegovernance", "-txindex=0", "-prune=550"], expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) self.log.info("Success") # check that wallet loads successfully when restarting a pruned node after IBD. @@ -374,7 +374,7 @@ def wallet_test(self): self.connect_nodes(0, 5) nds = [self.nodes[0], self.nodes[5]] self.sync_blocks(nds, wait=5, timeout=300) - self.restart_node(5, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=550"], expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) # restart to trigger rescan + self.restart_node(5, extra_args=["-dip3params=2000:2000", "-testactivationheight=dip0008@2000", "-disablegovernance", "-txindex=0", "-prune=550"], expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) # restart to trigger rescan self.log.info("Success") def run_test(self): diff --git a/test/functional/interface_zmq_dash.py b/test/functional/interface_zmq_dash.py index ee8931d34064..c0366d27ef76 100755 --- a/test/functional/interface_zmq_dash.py +++ b/test/functional/interface_zmq_dash.py @@ -127,7 +127,6 @@ def run_test(self): # Setup the ZMQ subscriber context self.zmq_context = zmq.Context() # Initialize the network - self.activate_dip8() self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.wait_for_sporks_same() self.activate_v19(expected_activation_height=900) diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py index eb8749cf3c65..cce36c28850a 100755 --- a/test/functional/mempool_accept.py +++ b/test/functional/mempool_accept.py @@ -41,7 +41,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 self.extra_args = [[ - '-txindex','-permitbaremultisig=0', + '-txindex','-permitbaremultisig=0', '-testactivationheight=dip0001@2000', ]] * self.num_nodes self.supports_cli = False diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 10c8d961364e..b2db3e7b89eb 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -27,8 +27,6 @@ from test_framework.address import ADDRESS_BCRT1_P2SH_OP_TRUE from test_framework.blocktools import ( - CLTV_HEIGHT, - DERSIG_HEIGHT, create_block, create_coinbase, TIME_GENESIS_BLOCK, @@ -144,17 +142,17 @@ def _test_getblockchaininfo(self): assert_equal(res['prune_target_size'], 576716800) assert_greater_than(res['size_on_disk'], 0) assert_equal(res['softforks'], { - 'bip34': {'type': 'buried', 'active': True, 'height': 2}, - 'bip66': {'type': 'buried', 'active': True, 'height': DERSIG_HEIGHT}, - 'bip65': {'type': 'buried', 'active': True, 'height': CLTV_HEIGHT}, - 'bip147': { 'type': 'buried', 'active': False, 'height': 432}, - 'csv': {'type': 'buried', 'active': False, 'height': 432}, - 'dip0001': { 'type': 'buried', 'active': False, 'height': 2000}, + 'bip34': {'type': 'buried', 'active': True, 'height': 1}, + 'bip66': {'type': 'buried', 'active': True, 'height': 1}, + 'bip65': {'type': 'buried', 'active': True, 'height': 1}, + 'bip147': { 'type': 'buried', 'active': True, 'height': 1}, + 'csv': {'type': 'buried', 'active': True, 'height': 1}, + 'dip0001': { 'type': 'buried', 'active': True, 'height': 1}, 'dip0003': { 'type': 'buried', 'active': False, 'height': 432}, - 'dip0008': { 'type': 'buried', 'active': False, 'height': 432}, - 'dip0020': { 'type': 'buried', 'active': False, 'height': 300}, + 'dip0008': { 'type': 'buried', 'active': True, 'height': 1}, + 'dip0020': { 'type': 'buried', 'active': True, 'height': 1}, 'dip0024': { 'type': 'buried', 'active': False, 'height': 900}, - 'realloc': { 'type': 'buried', 'active': False, 'height': 1000}, + 'realloc': { 'type': 'buried', 'active': True, 'height': 1}, 'v19': { 'type': 'buried', 'active': False, 'height': 900}, 'v20': { 'type': 'bip9', diff --git a/test/functional/rpc_verifychainlock.py b/test/functional/rpc_verifychainlock.py index 235cf4e99ba6..4e3447048b4c 100755 --- a/test/functional/rpc_verifychainlock.py +++ b/test/functional/rpc_verifychainlock.py @@ -28,7 +28,6 @@ def cl_helper(self, height, chainlock, mempool): def run_test(self): node0 = self.nodes[0] node1 = self.nodes[1] - self.activate_dip8() self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.wait_for_sporks_same() self.mine_quorum() diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py index a77a11669c4f..8f2600787e41 100644 --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -27,7 +27,7 @@ from .util import assert_equal, hex_str_to_bytes from io import BytesIO -MAX_BLOCK_SIGOPS = 20000 +MAX_BLOCK_SIGOPS = 40000 # Genesis block time (regtest) TIME_GENESIS_BLOCK = 1417713337 @@ -35,11 +35,6 @@ # Coinbase transaction outputs can only be spent after this number of new blocks (network rule) COINBASE_MATURITY = 100 -# Soft-fork activation heights -DERSIG_HEIGHT = 102 # BIP 66 -CLTV_HEIGHT = 111 # BIP 65 -CSV_ACTIVATION_HEIGHT = 432 - NORMAL_GBT_REQUEST_PARAMS = {"rules": []} # type: ignore[var-annotated] VERSIONBITS_LAST_OLD_BLOCK_VERSION = 4 @@ -260,12 +255,13 @@ def filter_tip_keys(chaintips): return filtered_tips # Identical to GetMasternodePayment in C++ code +# TODO: remove it or make **proper** tests for various height def get_masternode_payment(nHeight, blockValue, fV20Active): ret = int(blockValue / 5) nMNPIBlock = 350 nMNPIPeriod = 10 - nReallocActivationHeight = 2500 + nReallocActivationHeight = 1 if nHeight > nMNPIBlock: ret += int(blockValue / 20) @@ -290,7 +286,7 @@ def get_masternode_payment(nHeight, blockValue, fV20Active): # Block Reward Realocation is not activated yet, nothing to do return ret - nSuperblockCycle = 10 + nSuperblockCycle = 20 # Actual realocation starts in the cycle next to one activation happens in nReallocStart = nReallocActivationHeight - nReallocActivationHeight % nSuperblockCycle + nSuperblockCycle diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index b634231253c8..37e721559512 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -37,7 +37,7 @@ MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37) MAX_LOCATOR_SZ = 101 -MAX_BLOCK_SIZE = 1000000 +MAX_BLOCK_SIZE = 2000000 MAX_BLOOM_FILTER_SIZE = 36000 MAX_BLOOM_HASH_FUNCS = 50 diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index e3abe2fd2ed5..38c95342f708 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -1079,9 +1079,6 @@ def set_dash_test_params(self, num_nodes, masterodes_count, extra_args=None, fas for i in range(0, num_nodes): self.extra_args[i].append("-dip3params=30:50") - # make sure to activate dip8 after prepare_masternodes has finished its job already - self.set_dash_dip8_activation(200) - # LLMQ default test params (no need to pass -llmqtestparams) self.llmq_size = 3 self.llmq_threshold = 2 @@ -1092,22 +1089,6 @@ def set_dash_test_params(self, num_nodes, masterodes_count, extra_args=None, fas # This is EXPIRATION_TIMEOUT + EXPIRATION_BIAS in CQuorumDataRequest self.quorum_data_request_expiration_timeout = 360 - def set_dash_dip8_activation(self, activate_after_block): - self.dip8_activation_height = activate_after_block - for i in range(0, self.num_nodes): - self.extra_args[i].append("-dip8params=%d" % (activate_after_block)) - - def activate_dip8(self, slow_mode=False): - # NOTE: set slow_mode=True if you are activating dip8 after a huge reorg - # or nodes might fail to catch up otherwise due to a large - # (MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16 blocks) reorg error. - self.log.info("Wait for dip0008 activation") - while self.nodes[0].getblockcount() < self.dip8_activation_height: - self.bump_mocktime(10) - self.nodes[0].generate(10) - if slow_mode: - self.sync_blocks() - self.sync_blocks() def activate_by_name(self, name, expected_activation_height=None): assert not softfork_active(self.nodes[0], name) diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 9f0930e40930..ec3c6dcde17d 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -601,17 +601,6 @@ def mine_large_block(node, utxos=None): node.generate(1) -def generate_to_height(node, target_height): - """Generates blocks until a given target block height has been reached. - To prevent timeouts, only up to 200 blocks are generated per RPC call. - Can be used to activate certain soft-forks (e.g. CSV, CLTV).""" - current_height = node.getblockcount() - while current_height < target_height: - nblocks = min(200, target_height - current_height) - current_height += len(node.generate(nblocks)) - assert_equal(node.getblockcount(), target_height) - - def find_vout_for_address(node, txid, addr): """ Locate the vout index of the given transaction sending to the