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/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-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 @@ -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): 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):