Skip to content

Commit d9fef89

Browse files
committed
feat: enforce DIP0001 from first block on regtest
1 parent ae0712d commit d9fef89

File tree

8 files changed

+18
-11
lines changed

8 files changed

+18
-11
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/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ static bool ContextualCheckTransaction(const CTransaction& tx, TxValidationState
318318

319319
// Size limits
320320
if (fDIP0001Active_context && ::GetSerializeSize(tx, PROTOCOL_VERSION) > MAX_STANDARD_TX_SIZE)
321-
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-oversize");
321+
return state.Invalid(TxValidationResult::TX_CONSENSUS, "tx-size");
322322

323323
return true;
324324
}

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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"""
1313
from collections import defaultdict
1414

15-
from test_framework.messages import CInv, MAX_BLOCK_SIZE, MSG_BLOCK, msg_getdata
15+
from test_framework.messages import CInv, MSG_BLOCK, msg_getdata
1616
from test_framework.p2p import P2PInterface
1717
from test_framework.test_framework import BitcoinTestFramework
1818
from test_framework.util import assert_equal, mine_large_block, set_node_times
@@ -38,7 +38,8 @@ def set_test_params(self):
3838
self.extra_args = [[
3939
"-maxuploadtarget=200",
4040
"-blockmaxsize=999000",
41-
"-acceptnonstdtxn=1"
41+
"-acceptnonstdtxn=1",
42+
"-testactivationheight=dip0001@2000",
4243
]]
4344
self.supports_cli = False
4445

@@ -96,7 +97,7 @@ def run_test(self):
9697
getdata_request.inv.append(CInv(MSG_BLOCK, big_old_block))
9798

9899
max_bytes_per_day = 200*1024*1024
99-
daily_buffer = 144 * MAX_BLOCK_SIZE
100+
daily_buffer = 144 * 1000000
100101
max_bytes_available = max_bytes_per_day - daily_buffer
101102
success_count = max_bytes_available // old_block_size
102103

test/functional/rpc_blockchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def _test_getblockchaininfo(self):
147147
'bip65': {'type': 'buried', 'active': True, 'height': 1},
148148
'bip147': { 'type': 'buried', 'active': True, 'height': 1},
149149
'csv': {'type': 'buried', 'active': True, 'height': 1},
150-
'dip0001': { 'type': 'buried', 'active': False, 'height': 2000},
150+
'dip0001': { 'type': 'buried', 'active': True, 'height': 1},
151151
'dip0003': { 'type': 'buried', 'active': False, 'height': 432},
152152
'dip0008': { 'type': 'buried', 'active': True, 'height': 1},
153153
'dip0020': { 'type': 'buried', 'active': True, 'height': 1},

test/functional/test_framework/blocktools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from .util import assert_equal, hex_str_to_bytes
2828
from io import BytesIO
2929

30-
MAX_BLOCK_SIGOPS = 20000
30+
MAX_BLOCK_SIGOPS = 40000
3131

3232
# Genesis block time (regtest)
3333
TIME_GENESIS_BLOCK = 1417713337

test/functional/test_framework/messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)
3838

3939
MAX_LOCATOR_SZ = 101
40-
MAX_BLOCK_SIZE = 1000000
40+
MAX_BLOCK_SIZE = 2000000
4141
MAX_BLOOM_FILTER_SIZE = 36000
4242
MAX_BLOOM_HASH_FUNCS = 50
4343

0 commit comments

Comments
 (0)