Skip to content

Commit

Permalink
feat: enforce DIP0001 from first block on regtest
Browse files Browse the repository at this point in the history
  • Loading branch information
knst committed Aug 15, 2024
1 parent 5fa64bc commit c01226e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ class CRegTestParams : public CChainParams {
consensus.BIP66Height = 1; // Always active unless overridden
consensus.BIP147Height = 1; // Always active unless overridden
consensus.CSVHeight = 1; // Always active unless overridden
consensus.DIP0001Height = 2000;
consensus.DIP0001Height = 1; // Always active unless overridden
consensus.DIP0003Height = 432;
consensus.DIP0003EnforcementHeight = 500;
consensus.DIP0003EnforcementHash = uint256();
Expand Down Expand Up @@ -1056,6 +1056,8 @@ static void MaybeUpdateHeights(const ArgsManager& args, Consensus::Params& conse
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") {
Expand Down
2 changes: 1 addition & 1 deletion src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
argsman.AddArg("-dip3params=<activation>:<enforcement>", "Override DIP3 activation and enforcement heights (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-dip8params=<activation>", "Override DIP8 activation height (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-bip147height=<activation>", "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, dip0008, dip0020). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
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=<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);
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);
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);
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ static bool ContextualCheckTransaction(const CTransaction& tx, TxValidationState

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

return true;
}
Expand Down
8 changes: 6 additions & 2 deletions test/functional/feature_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -22,7 +21,6 @@
CTransaction,
CTxIn,
CTxOut,
MAX_BLOCK_SIZE,
uint256_from_compact,
uint256_from_str,
)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -87,6 +90,7 @@ def set_test_params(self):
'-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):
Expand Down
7 changes: 4 additions & 3 deletions test/functional/feature_maxuploadtarget.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""
from collections import defaultdict

from test_framework.messages import CInv, MAX_BLOCK_SIZE, MSG_BLOCK, msg_getdata
from test_framework.messages import CInv, MSG_BLOCK, msg_getdata
from test_framework.p2p import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, mine_large_block, set_node_times
Expand All @@ -38,7 +38,8 @@ def set_test_params(self):
self.extra_args = [[
"-maxuploadtarget=200",
"-blockmaxsize=999000",
"-acceptnonstdtxn=1"
"-acceptnonstdtxn=1",
"-testactivationheight=dip0001@2000",
]]
self.supports_cli = False

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

max_bytes_per_day = 200*1024*1024
daily_buffer = 144 * MAX_BLOCK_SIZE
daily_buffer = 144 * 1000000
max_bytes_available = max_bytes_per_day - daily_buffer
success_count = max_bytes_available // old_block_size

Expand Down
2 changes: 1 addition & 1 deletion test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _test_getblockchaininfo(self):
'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': False, 'height': 2000},
'dip0001': { 'type': 'buried', 'active': True, 'height': 1},
'dip0003': { 'type': 'buried', 'active': False, 'height': 432},
'dip0008': { 'type': 'buried', 'active': True, 'height': 1},
'dip0020': { 'type': 'buried', 'active': True, 'height': 1},
Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_framework/blocktools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_framework/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c01226e

Please sign in to comment.