Skip to content

Commit 8ca90f3

Browse files
MarcoFalkeMunkybooty
authored andcommitted
Merge bitcoin#15891: test: Require standard txs in regtest by default
fa89bad test: Require standard txs in regtest (MarcoFalke) fa9b419 test: Add test that mainnet requires standard txs (MarcoFalke) fa613ca chainparams: Remove unused fMineBlocksOnDemand (MarcoFalke) Pull request description: I don't see a reason why regtest should allow non-standard txs, as it makes testing mainnet behaviour such as bitcoin#15846 unnecessarily hard and unintuitive. Of course, testnet policy remains unchanged to allow propagation of non-standard txs. ACKs for top commit: ajtowns: ACK fa89bad Tree-SHA512: c4c675affb054868850bd2683aa07f4c741a448cbacb2ea8334191e105f426b0790fe6a468be61e9c5880d24154f7bf1c7075051697172dce92180c1bc3a1c90
1 parent 41f9bfa commit 8ca90f3

16 files changed

+55
-23
lines changed

src/chainparams.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ class CMainParams : public CChainParams {
309309
fDefaultConsistencyChecks = false;
310310
fRequireStandard = true;
311311
fRequireRoutableExternalIP = true;
312-
fMineBlocksOnDemand = false;
312+
m_is_test_chain = false;
313313
fAllowMultipleAddressesFromGroup = false;
314314
fAllowMultiplePorts = false;
315315
nLLMQConnectionRetryTimeout = 60;
@@ -525,7 +525,7 @@ class CTestNetParams : public CChainParams {
525525
fDefaultConsistencyChecks = false;
526526
fRequireStandard = false;
527527
fRequireRoutableExternalIP = true;
528-
fMineBlocksOnDemand = false;
528+
m_is_test_chain = true;
529529
fAllowMultipleAddressesFromGroup = false;
530530
fAllowMultiplePorts = true;
531531
nLLMQConnectionRetryTimeout = 60;
@@ -726,7 +726,7 @@ class CDevNetParams : public CChainParams {
726726
fDefaultConsistencyChecks = false;
727727
fRequireStandard = false;
728728
fRequireRoutableExternalIP = true;
729-
fMineBlocksOnDemand = false;
729+
m_is_test_chain = true;
730730
fAllowMultipleAddressesFromGroup = true;
731731
fAllowMultiplePorts = true;
732732
nLLMQConnectionRetryTimeout = 60;
@@ -908,9 +908,9 @@ class CRegTestParams : public CChainParams {
908908
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
909909

910910
fDefaultConsistencyChecks = true;
911-
fRequireStandard = false;
911+
fRequireStandard = true;
912912
fRequireRoutableExternalIP = false;
913-
fMineBlocksOnDemand = true;
913+
m_is_test_chain = true;
914914
fAllowMultipleAddressesFromGroup = true;
915915
fAllowMultiplePorts = true;
916916
nLLMQConnectionRetryTimeout = 1; // must be lower then the LLMQ signing session timeout so that tests have control over failing behavior

src/chainparams.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ class CChainParams
7070
bool RequireStandard() const { return fRequireStandard; }
7171
/** Require addresses specified with "-externalip" parameter to be routable */
7272
bool RequireRoutableExternalIP() const { return fRequireRoutableExternalIP; }
73+
/** If this is a test chain */
74+
bool IsTestChain() const { return m_is_test_chain; }
7375
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
7476
/** Minimum free space (in GB) needed for data directory */
7577
uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
7678
/** Minimum free space (in GB) needed for data directory when pruned; Does not include prune target*/
7779
uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
78-
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
79-
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
80+
/** Whether it is possible to mine blocks on demand (no retargeting) */
81+
bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
8082
/** Allow multiple addresses to be selected from the same network group (e.g. 192.168.x.x) */
8183
bool AllowMultipleAddressesFromGroup() const { return fAllowMultipleAddressesFromGroup; }
8284
/** Allow nodes with the same address and multiple ports */
@@ -130,7 +132,7 @@ class CChainParams
130132
bool fDefaultConsistencyChecks;
131133
bool fRequireStandard;
132134
bool fRequireRoutableExternalIP;
133-
bool fMineBlocksOnDemand;
135+
bool m_is_test_chain;
134136
bool fAllowMultipleAddressesFromGroup;
135137
bool fAllowMultiplePorts;
136138
int nLLMQConnectionRetryTimeout;

src/init.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,8 +1494,9 @@ bool AppInitParameterInteraction()
14941494
}
14951495

14961496
fRequireStandard = !gArgs.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
1497-
if (chainparams.RequireStandard() && !fRequireStandard)
1497+
if (!chainparams.IsTestChain() && !fRequireStandard) {
14981498
return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));
1499+
}
14991500
nBytesPerSigOp = gArgs.GetArg("-bytespersigop", nBytesPerSigOp);
15001501

15011502
if (!g_wallet_init_interface.ParameterInteraction()) return false;

test/functional/feature_bip68_sequence.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
class BIP68Test(BitcoinTestFramework):
2222
def set_test_params(self):
2323
self.num_nodes = 2
24-
self.extra_args = [[], ["-acceptnonstdtxn=0"]]
24+
self.extra_args = [
25+
["-acceptnonstdtxn=1"],
26+
["-acceptnonstdtxn=0"],
27+
]
2528

2629
def skip_test_if_missing_module(self):
2730
self.skip_if_no_wallet()

test/functional/feature_block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def set_test_params(self):
8282
# which causes RPC to hang, so we need to increase RPC timeouts
8383
self.rpc_timeout = 180
8484
# Must set '-dip3params=2000:2000' to create pre-dip3 blocks only
85-
self.extra_args = [['-dip3params=2000:2000']]
85+
self.extra_args = [['-dip3params=2000:2000', '-acceptnonstdtxn=1']] # This is a consensus block test, we don't care about tx policy
8686

8787
def setup_nodes(self):
8888
self.add_nodes(self.num_nodes, self.extra_args)

test/functional/feature_cltv.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ def cltv_validate(node, tx, height):
5959
class BIP65Test(BitcoinTestFramework):
6060
def set_test_params(self):
6161
self.num_nodes = 1
62-
self.extra_args = [['-whitelist=127.0.0.1', '-dip3params=9000:9000', '-par=1']] # Use only one script thread to get the exact reject reason for testing
62+
self.extra_args = [[
63+
'-whitelist=127.0.0.1',
64+
'-dip3params=9000:9000',
65+
'-par=1', # Use only one script thread to get the exact reject reason for testing
66+
'-acceptnonstdtxn=1', # cltv_invalidate is nonstandard
67+
]]
6368
self.setup_clean_chain = True
6469
self.rpc_timeout = 120
6570

test/functional/feature_config_args.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def test_config_file_parser(self):
4040
conf.write("wallet=foo\n")
4141
self.nodes[0].assert_start_raises_init_error(expected_msg='Error: Config setting for -wallet only applied on regtest network when in [regtest] section.')
4242

43+
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
44+
conf.write('regtest=0\n') # mainnet
45+
conf.write('acceptnonstdtxn=1\n')
46+
self.nodes[0].assert_start_raises_init_error(expected_msg='Error: acceptnonstdtxn is not currently supported for main chain')
47+
4348
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
4449
conf.write('nono\n')
4550
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 1: nono, if you intended to specify a negated option, use nono=1 instead')

test/functional/feature_dip0020_activation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
class DIP0020ActivationTest(BitcoinTestFramework):
2020
def set_test_params(self):
2121
self.num_nodes = 1
22+
self.extra_args = [["-acceptnonstdtxn=1"]]
2223

2324
def skip_test_if_missing_module(self):
2425
self.skip_if_no_wallet()
@@ -31,7 +32,7 @@ def run_test(self):
3132
utxos = self.node.listunspent()
3233
assert len(utxos) > 0
3334

34-
# Send some coins to a P2SH address constructed using disabled opcodes
35+
# Lock some coins using disabled opcodes
3536
utxo = utxos[len(utxos) - 1]
3637
value = int(satoshi_round(utxo["amount"] - self.relayfee) * COIN)
3738
tx = CTransaction()

test/functional/feature_fee_estimation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ def set_test_params(self):
126126
self.num_nodes = 3
127127
# mine non-standard txs (e.g. txs with "dust" outputs)
128128
self.extra_args = [
129-
["-maxorphantxsize=1000", "-whitelist=127.0.0.1"],
130-
["-blockmaxsize=17000", "-maxorphantxsize=1000", "-whitelist=127.0.0.1"],
131-
["-blockmaxsize=8000", "-maxorphantxsize=1000", "-whitelist=127.0.0.1"]
129+
["-acceptnonstdtxn=1", "-maxorphantxsize=1000", "-whitelist=127.0.0.1"],
130+
["-acceptnonstdtxn=1", "-blockmaxsize=17000", "-maxorphantxsize=1000", "-whitelist=127.0.0.1"],
131+
["-acceptnonstdtxn=1", "-blockmaxsize=8000", "-maxorphantxsize=1000", "-whitelist=127.0.0.1"]
132132
]
133133

134134
def skip_test_if_missing_module(self):

test/functional/feature_maxuploadtarget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class MaxUploadTest(BitcoinTestFramework):
3535
def set_test_params(self):
3636
self.setup_clean_chain = True
3737
self.num_nodes = 1
38-
self.extra_args = [["-maxuploadtarget=200", "-blockmaxsize=999000", "-maxtipage="+str(2*60*60*24*7)]]
38+
self.extra_args = [["-maxuploadtarget=200", "-blockmaxsize=999000", "-maxtipage="+str(2*60*60*24*7), "-acceptnonstdtxn=1"]]
3939

4040
# Cache for utxos, as the listunspent may take a long time later in the test
4141
self.utxo_cache = []

0 commit comments

Comments
 (0)