Skip to content

Commit 24dbcf3

Browse files
author
MarcoFalke
committed
Merge #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 #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
2 parents 8f60436 + fa89bad commit 24dbcf3

18 files changed

+68
-17
lines changed

doc/release-notes.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ Low-level Changes section below.
103103
Low-level changes
104104
=================
105105

106+
RPC
107+
---
108+
109+
110+
Tests
111+
-----
112+
113+
- The regression test chain, that can be enabled by the `-regtest` command line
114+
flag, now requires transactions to not violate standard policy by default.
115+
Making the default the same as for mainnet, makes it easier to test mainnet
116+
behavior on regtest. Be reminded that the testnet still allows non-standard
117+
txs by default and that the policy can be locally adjusted with the
118+
`-acceptnonstdtxn` command line flag for both test chains.
119+
106120
Configuration
107121
------------
108122

src/chainparams.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class CMainParams : public CChainParams {
141141

142142
fDefaultConsistencyChecks = false;
143143
fRequireStandard = true;
144-
fMineBlocksOnDemand = false;
144+
m_is_test_chain = false;
145145

146146
checkpointData = {
147147
{
@@ -247,7 +247,7 @@ class CTestNetParams : public CChainParams {
247247

248248
fDefaultConsistencyChecks = false;
249249
fRequireStandard = false;
250-
fMineBlocksOnDemand = false;
250+
m_is_test_chain = true;
251251

252252

253253
checkpointData = {
@@ -324,8 +324,8 @@ class CRegTestParams : public CChainParams {
324324
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
325325

326326
fDefaultConsistencyChecks = true;
327-
fRequireStandard = false;
328-
fMineBlocksOnDemand = true;
327+
fRequireStandard = true;
328+
m_is_test_chain = true;
329329

330330
checkpointData = {
331331
{

src/chainparams.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ class CChainParams
6666
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
6767
/** Policy: Filter transactions that do not match well-defined patterns */
6868
bool RequireStandard() const { return fRequireStandard; }
69+
/** If this is a test chain */
70+
bool IsTestChain() const { return m_is_test_chain; }
6971
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
7072
/** Minimum free space (in GB) needed for data directory */
7173
uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
7274
/** Minimum free space (in GB) needed for data directory when pruned; Does not include prune target*/
7375
uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
74-
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
75-
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
76+
/** Whether it is possible to mine blocks on demand (no retargeting) */
77+
bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
7678
/** Return the BIP70 network string (main, test or regtest) */
7779
std::string NetworkIDString() const { return strNetworkID; }
7880
/** Return true if the fallback fee is by default enabled for this network */
@@ -101,7 +103,7 @@ class CChainParams
101103
std::vector<SeedSpec6> vFixedSeeds;
102104
bool fDefaultConsistencyChecks;
103105
bool fRequireStandard;
104-
bool fMineBlocksOnDemand;
106+
bool m_is_test_chain;
105107
CCheckpointData checkpointData;
106108
ChainTxData chainTxData;
107109
bool m_fallback_fee_enabled;

src/init.cpp

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

11521152
fRequireStandard = !gArgs.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
1153-
if (chainparams.RequireStandard() && !fRequireStandard)
1153+
if (!chainparams.IsTestChain() && !fRequireStandard) {
11541154
return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));
1155+
}
11551156
nBytesPerSigOp = gArgs.GetArg("-bytespersigop", nBytesPerSigOp);
11561157

11571158
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
@@ -29,7 +29,10 @@
2929
class BIP68Test(BitcoinTestFramework):
3030
def set_test_params(self):
3131
self.num_nodes = 2
32-
self.extra_args = [[], ["-acceptnonstdtxn=0"]]
32+
self.extra_args = [
33+
["-acceptnonstdtxn=1"],
34+
["-acceptnonstdtxn=0"],
35+
]
3336

3437
def skip_test_if_missing_module(self):
3538
self.skip_if_no_wallet()

test/functional/feature_block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class FullBlockTest(BitcoinTestFramework):
7878
def set_test_params(self):
7979
self.num_nodes = 1
8080
self.setup_clean_chain = True
81-
self.extra_args = [[]]
81+
self.extra_args = [['-acceptnonstdtxn=1']] # This is a consensus block test, we don't care about tx policy
8282

8383
def run_test(self):
8484
node = self.nodes[0] # convenience reference to the node

test/functional/feature_cltv.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ def cltv_validate(node, tx, height):
5757
class BIP65Test(BitcoinTestFramework):
5858
def set_test_params(self):
5959
self.num_nodes = 1
60-
self.extra_args = [['-whitelist=127.0.0.1', '-par=1']] # Use only one script thread to get the exact reject reason for testing
60+
self.extra_args = [[
61+
'-whitelist=127.0.0.1',
62+
'-par=1', # Use only one script thread to get the exact reject reason for testing
63+
'-acceptnonstdtxn=1', # cltv_invalidate is nonstandard
64+
]]
6165
self.setup_clean_chain = True
6266
self.rpc_timeout = 120
6367

test/functional/feature_config_args.py

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

42+
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
43+
conf.write('regtest=0\n') # mainnet
44+
conf.write('acceptnonstdtxn=1\n')
45+
self.nodes[0].assert_start_raises_init_error(expected_msg='Error: acceptnonstdtxn is not currently supported for main chain')
46+
4247
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
4348
conf.write('nono\n')
4449
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_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=800"]]
38+
self.extra_args = [["-maxuploadtarget=800", "-acceptnonstdtxn=1"]]
3939

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

test/functional/feature_rbf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def set_test_params(self):
6767
self.num_nodes = 1
6868
self.extra_args = [
6969
[
70+
"-acceptnonstdtxn=1",
7071
"-maxorphantx=1000",
71-
"-whitelist=127.0.0.1",
7272
"-limitancestorcount=50",
7373
"-limitancestorsize=101",
7474
"-limitdescendantcount=200",

0 commit comments

Comments
 (0)