Skip to content

Commit f1e8452

Browse files
Merge #6214: feat: fire up test chains by first block: bitcoin#22818, dip1, dip8, dip20, brr - 3/n
f4ba2bb feat: enforce DIP0001 from first block on regtest and drop fDIP0001ActiveAtTip (Konstantin Akimov) 5fa64bc feat: put brr activation to height=1 (Konstantin Akimov) 593c6cf feat: instant activation dip-0008 on regtest on first block (Konstantin Akimov) cfd7ea2 feat: activate DIP0020 on regtest from block 1 (Konstantin Akimov) d1676b0 Merge bitcoin#22818: test: Activate all regtest softforks at height 1, unless overridden (merge-script) Pull request description: ## Issue being fixed or feature implemented ## What was done? Backport bitcoin#22818 which helped to activate all forks from block-1 at regtest. Activate next dash's softforks at block 1: - DIP-0001 (blocksize 2mb) - DIP-0020 (opcodes) - DIP-0008 (chainlocks) - BRR (block reward reallocation) ## How Has This Been Tested? ## Breaking Changes All changes are relevant to RegTest only ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: PastaPastaPasta: utACK f4ba2bb Tree-SHA512: 8d095365ff9e06ddcf47dbd457310ea2326998f0627d409651ab2fd35f6c1407cd3d2a23a4c636de359547782f4c43821944528229f3ea800cc65d3537595ea8
2 parents ada8591 + f4ba2bb commit f1e8452

40 files changed

+170
-131
lines changed

doc/release-notes-6189.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ Tests
22
-----
33

44
- For the `regtest` network the activation heights of several softforks were
5-
changed. (dash#6189)
6-
* BIP 34 (blockheight in coinbase) from 500 to 2
7-
* BIP 66 (DERSIG) from 1251 to 102
8-
* BIP 65 (CLTV) from 1351 to 111
5+
set to block height 1. They can be changed by the runtime setting
6+
`-testactivationheight=name@height`. (dash#6214)

src/chainparams.cpp

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -794,19 +794,19 @@ class CRegTestParams : public CChainParams {
794794
consensus.nGovernanceMinQuorum = 1;
795795
consensus.nGovernanceFilterElements = 100;
796796
consensus.nMasternodeMinimumConfirmations = 1;
797-
consensus.BIP34Height = 2; // BIP34 activated on regtest (Block at height 1 not enforced for testing purposes)
797+
consensus.BIP34Height = 1; // Always active unless overridden
798798
consensus.BIP34Hash = uint256();
799-
consensus.BIP65Height = 111; // BIP65 activated on regtest (Block at height 110 and earlier not enforced for testing purposes)
800-
consensus.BIP66Height = 102; // BIP66 activated on regtest (Block at height 101 and earlier not enforced for testing purposes)
801-
consensus.BIP147Height = 432; // BIP147 activated on regtest (Used in functional tests)
802-
consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
803-
consensus.DIP0001Height = 2000;
799+
consensus.BIP65Height = 1; // Always active unless overridden
800+
consensus.BIP66Height = 1; // Always active unless overridden
801+
consensus.BIP147Height = 1; // Always active unless overridden
802+
consensus.CSVHeight = 1; // Always active unless overridden
803+
consensus.DIP0001Height = 1; // Always active unless overridden
804804
consensus.DIP0003Height = 432;
805805
consensus.DIP0003EnforcementHeight = 500;
806806
consensus.DIP0003EnforcementHash = uint256();
807-
consensus.DIP0008Height = 432;
808-
consensus.BRRHeight = 1000; // see block_reward_reallocation_tests
809-
consensus.DIP0020Height = 300;
807+
consensus.DIP0008Height = 1; // Always active unless overridden
808+
consensus.BRRHeight = 1; // Always active unless overridden
809+
consensus.DIP0020Height = 1;
810810
consensus.DIP0024Height = 900;
811811
consensus.DIP0024QuorumsHeight = 900;
812812
consensus.V19Height = 900;
@@ -1031,8 +1031,47 @@ class CRegTestParams : public CChainParams {
10311031
void UpdateLLMQInstantSendDIP0024FromArgs(const ArgsManager& args);
10321032
};
10331033

1034+
static void MaybeUpdateHeights(const ArgsManager& args, Consensus::Params& consensus)
1035+
{
1036+
for (const std::string& arg : args.GetArgs("-testactivationheight")) {
1037+
const auto found{arg.find('@')};
1038+
if (found == std::string::npos) {
1039+
throw std::runtime_error(strprintf("Invalid format (%s) for -testactivationheight=name@height.", arg));
1040+
}
1041+
const auto name{arg.substr(0, found)};
1042+
const auto value{arg.substr(found + 1)};
1043+
int32_t height;
1044+
if (!ParseInt32(value, &height) || height < 0 || height >= std::numeric_limits<int>::max()) {
1045+
throw std::runtime_error(strprintf("Invalid height value (%s) for -testactivationheight=name@height.", arg));
1046+
}
1047+
if (name == "bip147") {
1048+
consensus.BIP147Height = int{height};
1049+
} else if (name == "bip34") {
1050+
consensus.BIP34Height = int{height};
1051+
} else if (name == "dersig") {
1052+
consensus.BIP66Height = int{height};
1053+
} else if (name == "cltv") {
1054+
consensus.BIP65Height = int{height};
1055+
} else if (name == "csv") {
1056+
consensus.CSVHeight = int{height};
1057+
} else if (name == "brr") {
1058+
consensus.BRRHeight = int{height};
1059+
} else if (name == "dip0001") {
1060+
consensus.DIP0001Height = int{height};
1061+
} else if (name == "dip0008") {
1062+
consensus.DIP0008Height = int{height};
1063+
} else if (name == "dip0020") {
1064+
consensus.DIP0020Height = int{height};
1065+
} else {
1066+
throw std::runtime_error(strprintf("Invalid name (%s) for -testactivationheight=name@height.", arg));
1067+
}
1068+
}
1069+
}
1070+
10341071
void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
10351072
{
1073+
MaybeUpdateHeights(args, consensus);
1074+
10361075
if (!args.IsArgSet("-vbparams")) return;
10371076

10381077
for (const std::string& strDeployment : args.GetArgs("-vbparams")) {

src/chainparamsbase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
2222
argsman.AddArg("-dip3params=<activation>:<enforcement>", "Override DIP3 activation and enforcement heights (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
2323
argsman.AddArg("-dip8params=<activation>", "Override DIP8 activation height (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
2424
argsman.AddArg("-bip147height=<activation>", "Override BIP147 activation height (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
25+
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);
2526
argsman.AddArg("-highsubsidyblocks=<n>", "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);
2627
argsman.AddArg("-highsubsidyfactor=<n>", "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);
2728
argsman.AddArg("-llmqchainlocks=<quorum name>", "Override the default LLMQ type used for ChainLocks. Allows using ChainLocks with smaller LLMQs. (default: llmq_devnet, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);

src/dsnotificationinterface.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
8181

8282
m_mn_sync.UpdatedBlockTip(WITH_LOCK(::cs_main, return m_chainman.m_best_header), pindexNew, fInitialDownload);
8383

84-
// Update global DIP0001 activation status
85-
fDIP0001ActiveAtTip = pindexNew->nHeight >= Params().GetConsensus().DIP0001Height;
86-
8784
if (fInitialDownload)
8885
return;
8986

src/net.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <util/time.h>
3434
#include <util/translation.h>
3535
#include <util/wpipe.h>
36-
#include <validation.h> // for fDIP0001ActiveAtTip
3736

3837
#include <masternode/meta.h>
3938
#include <masternode/sync.h>
@@ -4079,7 +4078,7 @@ bool CConnman::OutboundTargetReached(bool historicalBlockServingLimit) const
40794078
{
40804079
// keep a large enough buffer to at least relay each block once
40814080
const std::chrono::seconds timeLeftInCycle = GetMaxOutboundTimeLeftInCycle_();
4082-
const uint64_t buffer = timeLeftInCycle / std::chrono::minutes{10} * MaxBlockSize(fDIP0001ActiveAtTip);
4081+
const uint64_t buffer = timeLeftInCycle / std::chrono::minutes{10} * MaxBlockSize();
40834082
if (buffer >= nMaxOutboundLimit || nMaxOutboundTotalBytesSentInCycle >= nMaxOutboundLimit - buffer)
40844083
return true;
40854084
}

src/test/block_reward_reallocation_tests.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ using SimpleUTXOMap = std::map<COutPoint, std::pair<int, CAmount>>;
3535
struct TestChainBRRBeforeActivationSetup : public TestChainSetup
3636
{
3737
// Force fast DIP3 activation
38-
TestChainBRRBeforeActivationSetup() : TestChainSetup(497, {"-dip3params=30:50", "-vbparams=mn_rr:0:999999999999:0:20:16:12:5:1"}) {}
38+
TestChainBRRBeforeActivationSetup() :
39+
TestChainSetup(497, {"-dip3params=30:50", "-testactivationheight=brr@1000",
40+
"-vbparams=mn_rr:0:999999999999:0:20:16:12:5:1"})
41+
{
42+
}
3943
};
4044

4145
static SimpleUTXOMap BuildSimpleUtxoMap(const std::vector<CTransactionRef>& txs)

src/test/txvalidation_tests.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#include <boost/test/unit_test.hpp>
1616

1717

18+
struct TestChain100NoDIP0001Setup : public TestChain100Setup {
19+
TestChain100NoDIP0001Setup()
20+
: TestChain100Setup{{"-testactivationheight=dip0001@2000"}} {}
21+
};
22+
23+
1824
BOOST_AUTO_TEST_SUITE(txvalidation_tests)
1925

2026
/**
@@ -69,7 +75,7 @@ inline CTransactionRef create_placeholder_tx(size_t num_inputs, size_t num_outpu
6975
return MakeTransactionRef(mtx);
7076
}
7177

72-
BOOST_FIXTURE_TEST_CASE(package_tests, TestChain100Setup)
78+
BOOST_FIXTURE_TEST_CASE(package_tests, TestChain100NoDIP0001Setup)
7379
{
7480
LOCK(cs_main);
7581
unsigned int initialPoolSize = m_node.mempool->size();

src/test/txvalidationcache_tests.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212

1313
#include <boost/test/unit_test.hpp>
1414

15+
struct Dersig100Setup : public TestChain100Setup {
16+
Dersig100Setup()
17+
: TestChain100Setup{{"-testactivationheight=dersig@102"}} {}
18+
};
19+
1520
bool CheckInputScripts(const CTransaction& tx, TxValidationState &state, const CCoinsViewCache &inputs, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData& txdata, std::vector<CScriptCheck> *pvChecks);
1621

1722
BOOST_AUTO_TEST_SUITE(txvalidationcache_tests)
1823

19-
BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
24+
BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, Dersig100Setup)
2025
{
2126
// Make sure skipping validation of transactions that were
2227
// validated going into the memory pool does not allow
@@ -144,7 +149,7 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail
144149
}
145150
}
146151

147-
BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
152+
BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup)
148153
{
149154
// Test that passing CheckInputScripts with one set of script flags doesn't imply
150155
// that we would pass again with a different set of flags.

src/test/util/setup_common.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ TestingSetup::~TestingSetup()
306306
m_node.banman.reset();
307307
}
308308

309+
TestChain100Setup::TestChain100Setup(const std::vector<const char*>& extra_args)
310+
: TestChainSetup{100, extra_args}
311+
{
312+
}
313+
309314
TestChainSetup::TestChainSetup(int num_blocks, const std::vector<const char*>& extra_args)
310315
: RegTestingSetup(extra_args)
311316
{
@@ -336,7 +341,7 @@ TestChainSetup::TestChainSetup(int num_blocks, const std::vector<const char*>& e
336341
/* TestChainDIP3Setup */
337342
{ 431, uint256S("0x49db248651517f3fc3725fbbc7087db90552d487d11e0962b0148fc4788aeb77") },
338343
/* TestChainBRRBeforeActivationSetup */
339-
{ 497, uint256S("0x15445246f9f9fd4fdb1021dd8278ace7246b3e3cb545e1632a277d3a02eb011f") },
344+
{ 497, uint256S("0x626036f6adff51fbbdd0c609e827ef6a3730ce2498a3eb33edeb27092d006170") },
340345
/* TestChainV19BeforeActivationSetup */
341346
{ 894, uint256S("0x03cbf1871d7d915cda10aded00ced45f71a4e2acf6a3c7a77a1ff488267dd1cd") },
342347
/* TestChainV19Setup */

src/test/util/setup_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ struct TestChainSetup : public RegTestingSetup
177177
* Testing fixture that pre-creates a 100-block REGTEST-mode block chain
178178
*/
179179
struct TestChain100Setup : public TestChainSetup {
180-
TestChain100Setup() : TestChainSetup(100) {}
180+
TestChain100Setup(const std::vector<const char*>& extra_args = {});
181181
};
182182

183183
struct TestChainDIP3Setup : public TestChainSetup

0 commit comments

Comments
 (0)