Skip to content

Commit f4ba2bb

Browse files
committed
feat: enforce DIP0001 from first block on regtest and drop fDIP0001ActiveAtTip
The flag fDIP0001ActiveAtTip shows a status of activation of DIP0001 This flag is used currently only in net.cpp for setup block buffer size. Assume the bigger by default so far as DIP0001 is activated years ago
1 parent 5fa64bc commit f4ba2bb

File tree

13 files changed

+25
-23
lines changed

13 files changed

+25
-23
lines changed

src/chainparams.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ class CRegTestParams : public CChainParams {
800800
consensus.BIP66Height = 1; // Always active unless overridden
801801
consensus.BIP147Height = 1; // Always active unless overridden
802802
consensus.CSVHeight = 1; // Always active unless overridden
803-
consensus.DIP0001Height = 2000;
803+
consensus.DIP0001Height = 1; // Always active unless overridden
804804
consensus.DIP0003Height = 432;
805805
consensus.DIP0003EnforcementHeight = 500;
806806
consensus.DIP0003EnforcementHash = uint256();
@@ -1056,6 +1056,8 @@ static void MaybeUpdateHeights(const ArgsManager& args, Consensus::Params& conse
10561056
consensus.CSVHeight = int{height};
10571057
} else if (name == "brr") {
10581058
consensus.BRRHeight = int{height};
1059+
} else if (name == "dip0001") {
1060+
consensus.DIP0001Height = int{height};
10591061
} else if (name == "dip0008") {
10601062
consensus.DIP0008Height = int{height};
10611063
} else if (name == "dip0020") {

src/chainparamsbase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +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, dip0008, dip0020). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
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);
2626
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);
2727
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);
2828
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/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/validation.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ bool fCheckBlockIndex = false;
114114
bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED;
115115
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
116116

117-
// TODO: drop this global variable. Used by net.cpp module only
118-
std::atomic<bool> fDIP0001ActiveAtTip{false};
119-
120117
uint256 hashAssumeValid;
121118
arith_uint256 nMinimumChainWork;
122119

src/validation.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ extern int64_t nMaxTipAge;
142142
extern bool fLargeWorkForkFound;
143143
extern bool fLargeWorkInvalidChainFound;
144144

145-
extern std::atomic<bool> fDIP0001ActiveAtTip;
146-
147145
/** Block hash whose ancestors we will assume to have valid scripts without checking them. */
148146
extern uint256 hashAssumeValid;
149147

test/functional/feature_block.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
create_coinbase,
1313
create_tx_with_script,
1414
get_legacy_sigopcount_block,
15-
MAX_BLOCK_SIGOPS,
1615
)
1716
from test_framework.key import ECKey
1817
from test_framework.messages import (
@@ -22,7 +21,6 @@
2221
CTransaction,
2322
CTxIn,
2423
CTxOut,
25-
MAX_BLOCK_SIZE,
2624
uint256_from_compact,
2725
uint256_from_str,
2826
)
@@ -53,6 +51,11 @@
5351
from test_framework.util import assert_equal
5452
from data import invalid_txs
5553

54+
# This functional test assumes DIP0001 is disabled
55+
# Blocks after activation DIP0001 can not have a transaction bigger than 100k bytes
56+
MAX_BLOCK_SIZE = 1000000
57+
MAX_BLOCK_SIGOPS = 20000
58+
5659
# Use this class for tests that require behavior other than normal p2p behavior.
5760
# For now, it is used to serialize a bloated varint (b64).
5861
class CBrokenBlock(CBlock):
@@ -87,6 +90,7 @@ def set_test_params(self):
8790
'-dip3params=2000:2000',
8891
'-acceptnonstdtxn=1', # This is a consensus block test, we don't care about tx policy
8992
'-testactivationheight=bip34@2',
93+
'-testactivationheight=dip0001@2000',
9094
]]
9195

9296
def setup_nodes(self):

test/functional/feature_maxuploadtarget.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ def set_test_params(self):
3636
self.setup_clean_chain = True
3737
self.num_nodes = 1
3838
self.extra_args = [[
39-
"-maxuploadtarget=200",
40-
"-blockmaxsize=999000",
41-
"-acceptnonstdtxn=1"
39+
"-maxuploadtarget=400",
40+
"-acceptnonstdtxn=1",
4241
]]
4342
self.supports_cli = False
4443

@@ -95,7 +94,7 @@ def run_test(self):
9594
getdata_request = msg_getdata()
9695
getdata_request.inv.append(CInv(MSG_BLOCK, big_old_block))
9796

98-
max_bytes_per_day = 200*1024*1024
97+
max_bytes_per_day = 400*1024*1024
9998
daily_buffer = 144 * MAX_BLOCK_SIZE
10099
max_bytes_available = max_bytes_per_day - daily_buffer
101100
success_count = max_bytes_available // old_block_size

test/functional/mempool_accept.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
4141
def set_test_params(self):
4242
self.num_nodes = 1
4343
self.extra_args = [[
44-
'-txindex','-permitbaremultisig=0',
44+
'-txindex','-permitbaremultisig=0', '-testactivationheight=dip0001@2000',
4545
]] * self.num_nodes
4646
self.supports_cli = False
4747

0 commit comments

Comments
 (0)