diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -6,6 +6,16 @@ - Removed deprecated `getinfo` RPC. - Update univalue to 1.0.5 +Tests +----- + +- The regression test chain, that can be enabled by the `-regtest` command line + flag, now requires transactions to not violate standard policy by default. + Making the default the same as for mainnet, makes it easier to test mainnet + behavior on regtest. Be reminded that the testnet still allows non-standard + txs by default and that the policy can be locally adjusted with the + `-acceptnonstdtxn` command line flag for both test chains. + Configuration ------------ diff --git a/src/chainparams.h b/src/chainparams.h --- a/src/chainparams.h +++ b/src/chainparams.h @@ -66,6 +66,8 @@ bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; } /** Policy: Filter transactions that do not match well-defined patterns */ bool RequireStandard() const { return fRequireStandard; } + /** If this is a test chain */ + bool IsTestChain() const { return m_is_test_chain; } uint64_t PruneAfterHeight() const { return nPruneAfterHeight; } /** Minimum free space (in GB) needed for data directory */ uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; } @@ -76,11 +78,8 @@ uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; } - /** - * Make miner stop after a block is found. In RPC, don't return until - * nGenProcLimit blocks are generated. - */ - bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; } + /** Whether it is possible to mine blocks on demand (no retargeting) */ + bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; } /** Return the BIP70 network string (main, test or regtest) */ std::string NetworkIDString() const { return strNetworkID; } /** Return the list of hostnames to look up for DNS seeds */ @@ -111,7 +110,7 @@ std::vector vFixedSeeds; bool fDefaultConsistencyChecks; bool fRequireStandard; - bool fMineBlocksOnDemand; + bool m_is_test_chain; CCheckpointData checkpointData; ChainTxData chainTxData; }; diff --git a/src/chainparams.cpp b/src/chainparams.cpp --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -235,7 +235,7 @@ fDefaultConsistencyChecks = false; fRequireStandard = true; - fMineBlocksOnDemand = false; + m_is_test_chain = false; checkpointData = { .mapCheckpoints = { @@ -452,7 +452,7 @@ fDefaultConsistencyChecks = false; fRequireStandard = false; - fMineBlocksOnDemand = false; + m_is_test_chain = true; checkpointData = { .mapCheckpoints = { @@ -612,8 +612,8 @@ vSeeds.clear(); fDefaultConsistencyChecks = true; - fRequireStandard = false; - fMineBlocksOnDemand = true; + fRequireStandard = true; + m_is_test_chain = true; checkpointData = { .mapCheckpoints = { diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -1830,7 +1830,7 @@ fRequireStandard = !gArgs.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard()); - if (chainparams.RequireStandard() && !fRequireStandard) { + if (!chainparams.IsTestChain() && !fRequireStandard) { return InitError( strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString())); diff --git a/test/functional/abc-block-sigchecks-activation.py b/test/functional/abc-block-sigchecks-activation.py --- a/test/functional/abc-block-sigchecks-activation.py +++ b/test/functional/abc-block-sigchecks-activation.py @@ -120,7 +120,8 @@ "-replayprotectionactivationtime={}".format( REPLAY_PROTECTION_START_TIME), "-excessiveblocksize={}".format(MAXBLOCKSIZE), - "-blockmaxsize={}".format(MAXBLOCKSIZE)]] + "-blockmaxsize={}".format(MAXBLOCKSIZE), + "-acceptnonstdtxn=1"]] def getbestblock(self, node): """Get the best block. Register its height so we can use build_block.""" diff --git a/test/functional/abc-mempool-accept-txn.py b/test/functional/abc-mempool-accept-txn.py --- a/test/functional/abc-mempool-accept-txn.py +++ b/test/functional/abc-mempool-accept-txn.py @@ -71,7 +71,8 @@ self.tip = None self.blocks = {} self.extra_args = [ - ['-phononactivationtime={}'.format(SIGOPS_DEACTIVATION_TIME)]] + ['-phononactivationtime={}'.format(SIGOPS_DEACTIVATION_TIME), + '-acceptnonstdtxn=1']] def add_options(self, parser): super().add_options(parser) diff --git a/test/functional/abc-mempool-coherence-on-activations.py b/test/functional/abc-mempool-coherence-on-activations.py --- a/test/functional/abc-mempool-coherence-on-activations.py +++ b/test/functional/abc-mempool-coherence-on-activations.py @@ -131,7 +131,8 @@ self.tip = None self.blocks = {} self.extra_args = [['-whitelist=127.0.0.1', - EXTRA_ARG]] + EXTRA_ARG, + '-acceptnonstdtxn=1']] def next_block(self, number): if self.tip is None: diff --git a/test/functional/abc-minimaldata.py b/test/functional/abc-minimaldata.py --- a/test/functional/abc-minimaldata.py +++ b/test/functional/abc-minimaldata.py @@ -51,6 +51,7 @@ def set_test_params(self): self.num_nodes = 1 self.block_heights = {} + self.extra_args = [['-acceptnonstdtxn=1']] def bootstrap_p2p(self, *, num_connections=1): """Add a P2P connection to the node. diff --git a/test/functional/abc-op-reversebytes-activation.py b/test/functional/abc-op-reversebytes-activation.py --- a/test/functional/abc-op-reversebytes-activation.py +++ b/test/functional/abc-op-reversebytes-activation.py @@ -53,7 +53,8 @@ self.num_nodes = 1 self.block_heights = {} self.extra_args = [ - ["-phononactivationtime={}".format(PHONON_START_TIME)]] + ["-phononactivationtime={}".format(PHONON_START_TIME), + "-acceptnonstdtxn=1"]] def bootstrap_p2p(self, *, num_connections=1): """Add a P2P connection to the node. diff --git a/test/functional/abc-p2p-compactblocks.py b/test/functional/abc-p2p-compactblocks.py --- a/test/functional/abc-p2p-compactblocks.py +++ b/test/functional/abc-p2p-compactblocks.py @@ -97,7 +97,9 @@ '-limitdescendantcount=999999', '-limitdescendantsize=999999', '-maxmempool=99999', - "-excessiveblocksize={}".format(self.excessive_block_size)]] + '-excessiveblocksize={}'.format( + self.excessive_block_size), + '-acceptnonstdtxn=1']] # UBSAN will cause this test to timeout without this. self.rpc_timeout = 180 diff --git a/test/functional/abc-phonon-mempoolpolicy.py b/test/functional/abc-phonon-mempoolpolicy.py --- a/test/functional/abc-phonon-mempoolpolicy.py +++ b/test/functional/abc-phonon-mempoolpolicy.py @@ -53,7 +53,8 @@ self.extra_args = [[ "-phononactivationtime={}".format(PHONON_START_TIME), "-replayprotectionactivationtime={}".format( - REPLAY_PROTECTION_TIME)]] + REPLAY_PROTECTION_TIME), + "-acceptnonstdtxn=1"]] def bootstrap_p2p(self): self.nodes[0].add_p2p_connection(P2PDataStore()) diff --git a/test/functional/abc-replay-protection.py b/test/functional/abc-replay-protection.py --- a/test/functional/abc-replay-protection.py +++ b/test/functional/abc-replay-protection.py @@ -61,7 +61,9 @@ self.tip = None self.blocks = {} self.extra_args = [['-whitelist=127.0.0.1', - "-replayprotectionactivationtime={}".format(REPLAY_PROTECTION_START_TIME)]] + "-replayprotectionactivationtime={}".format( + REPLAY_PROTECTION_START_TIME), + "-acceptnonstdtxn=1"]] def next_block(self, number): if self.tip is None: diff --git a/test/functional/abc-schnorr.py b/test/functional/abc-schnorr.py --- a/test/functional/abc-schnorr.py +++ b/test/functional/abc-schnorr.py @@ -66,6 +66,8 @@ def set_test_params(self): self.num_nodes = 1 self.block_heights = {} + self.extra_args = [[ + "-acceptnonstdtxn=1"]] def bootstrap_p2p(self, *, num_connections=1): """Add a P2P connection to the node. diff --git a/test/functional/abc-schnorrmultisig.py b/test/functional/abc-schnorrmultisig.py --- a/test/functional/abc-schnorrmultisig.py +++ b/test/functional/abc-schnorrmultisig.py @@ -70,6 +70,7 @@ def set_test_params(self): self.num_nodes = 1 self.block_heights = {} + self.extra_args = [["-acceptnonstdtxn=1"]] def bootstrap_p2p(self, *, num_connections=1): """Add a P2P connection to the node. diff --git a/test/functional/abc-sigchecks-inputstandardness-activation.py b/test/functional/abc-sigchecks-inputstandardness-activation.py --- a/test/functional/abc-sigchecks-inputstandardness-activation.py +++ b/test/functional/abc-sigchecks-inputstandardness-activation.py @@ -83,7 +83,8 @@ self.extra_args = [["-phononactivationtime={}".format( SIGCHECKS_ACTIVATION_TIME), "-replayprotectionactivationtime={}".format( - REPLAY_PROTECTION_START_TIME), ]] + REPLAY_PROTECTION_START_TIME), + "-acceptnonstdtxn=1"]] def getbestblock(self, node): """Get the best block. Register its height so we can use build_block.""" diff --git a/test/functional/abc-sigops-deactivation.py b/test/functional/abc-sigops-deactivation.py --- a/test/functional/abc-sigops-deactivation.py +++ b/test/functional/abc-sigops-deactivation.py @@ -133,7 +133,7 @@ REPLAY_PROTECTION_START_TIME)] # many standardness rules are actually enforced on regtest, except for # P2SH sigops. - self.extra_args = [timeargs, timeargs + ['-acceptnonstdtxn=0']] + self.extra_args = [timeargs + ['-acceptnonstdtxn=1'], timeargs] def getbestblock(self, node): """Get the best block. Register its height so we can use build_block.""" diff --git a/test/functional/abc-sigops-mempool-mining.py b/test/functional/abc-sigops-mempool-mining.py --- a/test/functional/abc-sigops-mempool-mining.py +++ b/test/functional/abc-sigops-mempool-mining.py @@ -112,7 +112,8 @@ self.setup_clean_chain = True self.num_nodes = 1 self.extra_args = [ - ["-maxmempool=5", '-phononactivationtime={}'.format(SIGOPS_DEACTIVATION_TIME)]] + ["-maxmempool=5", '-phononactivationtime={}'.format(SIGOPS_DEACTIVATION_TIME), + "-acceptnonstdtxn=1"]] self.block_heights = {} def skip_test_if_missing_module(self): diff --git a/test/functional/feature_bip68_sequence.py b/test/functional/feature_bip68_sequence.py --- a/test/functional/feature_bip68_sequence.py +++ b/test/functional/feature_bip68_sequence.py @@ -46,7 +46,7 @@ class BIP68Test(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 - self.extra_args = [["-noparkdeepreorg", "-maxreorgdepth=-1"], + self.extra_args = [["-noparkdeepreorg", "-maxreorgdepth=-1", "-acceptnonstdtxn=1"], ["-acceptnonstdtxn=0", "-maxreorgdepth=-1"]] def skip_test_if_missing_module(self): diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py --- a/test/functional/feature_block.py +++ b/test/functional/feature_block.py @@ -70,7 +70,9 @@ def set_test_params(self): self.num_nodes = 1 self.setup_clean_chain = True - self.extra_args = [['-noparkdeepreorg', '-maxreorgdepth=-1']] + # This is a consensus block test, we don't care about tx policy + self.extra_args = [['-noparkdeepreorg', + '-maxreorgdepth=-1', '-acceptnonstdtxn=1']] def run_test(self): node = self.nodes[0] # convenience reference to the node diff --git a/test/functional/feature_cltv.py b/test/functional/feature_cltv.py --- a/test/functional/feature_cltv.py +++ b/test/functional/feature_cltv.py @@ -84,7 +84,11 @@ class BIP65Test(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 - self.extra_args = [['-whitelist=127.0.0.1']] + self.extra_args = [[ + '-whitelist=127.0.0.1', + '-par=1', # Use only one script thread to get the exact reject reason for testing + '-acceptnonstdtxn=1', # cltv_invalidate is nonstandard + ]] self.setup_clean_chain = True self.rpc_timeout = 120 diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -45,6 +45,12 @@ self.nodes[0].assert_start_raises_init_error( expected_msg='Error: Config setting for -wallet only applied on regtest network when in [regtest] section.') + with open(inc_conf_file_path, 'w', encoding='utf-8') as conf: + conf.write('regtest=0\n') # mainnet + conf.write('acceptnonstdtxn=1\n') + self.nodes[0].assert_start_raises_init_error( + expected_msg='Error: acceptnonstdtxn is not currently supported for main chain') + with open(inc_conf_file_path, 'w', encoding='utf-8') as conf: conf.write('nono\n') self.nodes[0].assert_start_raises_init_error( diff --git a/test/functional/feature_maxuploadtarget.py b/test/functional/feature_maxuploadtarget.py --- a/test/functional/feature_maxuploadtarget.py +++ b/test/functional/feature_maxuploadtarget.py @@ -40,7 +40,7 @@ self.setup_clean_chain = True self.num_nodes = 1 # Start a node with maxuploadtarget of 200 MB (/24h) - self.extra_args = [["-maxuploadtarget=200"]] + self.extra_args = [["-maxuploadtarget=200", "-acceptnonstdtxn=1"]] # Cache for utxos, as the listunspent may take a long time later in the # test diff --git a/test/functional/mempool_limit.py b/test/functional/mempool_limit.py --- a/test/functional/mempool_limit.py +++ b/test/functional/mempool_limit.py @@ -22,8 +22,11 @@ def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 - - self.extra_args = [["-maxmempool=5", "-spendzeroconfchange=0"]] + self.extra_args = [[ + "-acceptnonstdtxn=1", + "-maxmempool=5", + "-spendzeroconfchange=0", + ]] def skip_test_if_missing_module(self): self.skip_if_no_wallet() diff --git a/test/functional/mining_prioritisetransaction.py b/test/functional/mining_prioritisetransaction.py --- a/test/functional/mining_prioritisetransaction.py +++ b/test/functional/mining_prioritisetransaction.py @@ -21,7 +21,10 @@ def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 - self.extra_args = [["-printpriority=1"], ["-printpriority=1"]] + self.extra_args = [[ + "-printpriority=1", + "-acceptnonstdtxn=1", + ]] * self.num_nodes def skip_test_if_missing_module(self): self.skip_if_no_wallet() diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py --- a/test/functional/p2p_compactblocks.py +++ b/test/functional/p2p_compactblocks.py @@ -133,7 +133,8 @@ def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 - self.extra_args = [[], ["-txindex"]] + self.extra_args = [["-acceptnonstdtxn=1"], + ["-txindex", "-acceptnonstdtxn=1"]] self.utxos = [] def skip_test_if_missing_module(self): diff --git a/test/functional/p2p_invalid_tx.py b/test/functional/p2p_invalid_tx.py --- a/test/functional/p2p_invalid_tx.py +++ b/test/functional/p2p_invalid_tx.py @@ -32,6 +32,9 @@ def set_test_params(self): self.num_nodes = 1 + self.extra_args = [ + ["-acceptnonstdtxn=1", ] + ] self.setup_clean_chain = True def bootstrap_p2p(self, *, num_connections=1): @@ -170,7 +173,8 @@ # disconnects without sending the reject message self.log.info( 'Test a transaction that is rejected, with BIP61 disabled') - self.restart_node(0, ['-enablebip61=0', '-persistmempool=0']) + self.restart_node( + 0, self.extra_args[0] + ['-enablebip61=0', '-persistmempool=0']) self.reconnect_p2p(num_connections=1) node.p2p.send_txs_and_test( [tx1], node, success=False, reject_reason="{} from peer=0 was not accepted: mandatory-script-verify-flag-failed (Invalid OP_IF construction) (code 16)".format(tx1.hash), expect_disconnect=True) diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -24,6 +24,9 @@ class WalletTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 4 + self.extra_args = [ + ["-acceptnonstdtxn=1"], + ] * self.num_nodes self.setup_clean_chain = True def skip_test_if_missing_module(self): @@ -31,9 +34,9 @@ def setup_network(self): self.add_nodes(4) - self.start_node(0) - self.start_node(1) - self.start_node(2) + self.start_node(0, self.extra_args[0]) + self.start_node(1, self.extra_args[1]) + self.start_node(2, self.extra_args[2]) connect_nodes_bi(self.nodes[0], self.nodes[1]) connect_nodes_bi(self.nodes[1], self.nodes[2]) connect_nodes_bi(self.nodes[0], self.nodes[2]) @@ -243,7 +246,7 @@ txid2 = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1) sync_mempools(self.nodes[0:2]) - self.start_node(3) + self.start_node(3, self.extra_args[3]) connect_nodes_bi(self.nodes[0], self.nodes[3]) sync_blocks(self.nodes) @@ -290,9 +293,9 @@ # do some -walletbroadcast tests self.stop_nodes() - self.start_node(0, ["-walletbroadcast=0"]) - self.start_node(1, ["-walletbroadcast=0"]) - self.start_node(2, ["-walletbroadcast=0"]) + self.start_node(0, self.extra_args[0] + ["-walletbroadcast=0"]) + self.start_node(1, self.extra_args[1] + ["-walletbroadcast=0"]) + self.start_node(2, self.extra_args[2] + ["-walletbroadcast=0"]) connect_nodes_bi(self.nodes[0], self.nodes[1]) connect_nodes_bi(self.nodes[1], self.nodes[2]) connect_nodes_bi(self.nodes[0], self.nodes[2]) @@ -321,9 +324,9 @@ # restart the nodes with -walletbroadcast=1 self.stop_nodes() - self.start_node(0) - self.start_node(1) - self.start_node(2) + self.start_node(0, self.extra_args[0]) + self.start_node(1, self.extra_args[1]) + self.start_node(2, self.extra_args[2]) connect_nodes_bi(self.nodes[0], self.nodes[1]) connect_nodes_bi(self.nodes[1], self.nodes[2]) connect_nodes_bi(self.nodes[0], self.nodes[2]) @@ -434,9 +437,12 @@ self.log.info("check " + m) self.stop_nodes() # set lower ancestor limit for later - self.start_node(0, [m, "-limitancestorcount=" + str(chainlimit)]) - self.start_node(1, [m, "-limitancestorcount=" + str(chainlimit)]) - self.start_node(2, [m, "-limitancestorcount=" + str(chainlimit)]) + self.start_node( + 0, self.extra_args[0] + [m, "-limitancestorcount=" + str(chainlimit)]) + self.start_node( + 1, self.extra_args[1] + [m, "-limitancestorcount=" + str(chainlimit)]) + self.start_node( + 2, self.extra_args[2] + [m, "-limitancestorcount=" + str(chainlimit)]) if m == '-reindex': # reindex will leave rpc warm up "early"; Wait for it to finish wait_until(lambda: [block_count] * 3 == @@ -495,8 +501,9 @@ # Double chain limit but require combining inputs, so we pass # SelectCoinsMinConf self.stop_node(0) - self.start_node(0, extra_args=[ - "-walletrejectlongchains", "-limitancestorcount=" + str(2 * chainlimit)]) + self.start_node(0, + self.extra_args[0] + ["-walletrejectlongchains", + "-limitancestorcount=" + str(2 * chainlimit)]) # wait for loadmempool timeout = 10