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 @@ -1797,7 +1797,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/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 @@ -44,6 +44,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 @@ -39,8 +39,7 @@ def set_test_params(self): 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