mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
Remove ::fRequireStandard global
This commit is contained in:
parent
fa468bdfb6
commit
fa148602e6
9 changed files with 20 additions and 17 deletions
|
@ -1004,10 +1004,6 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
|
|||
}
|
||||
}
|
||||
|
||||
fRequireStandard = !args.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
|
||||
if (!chainparams.IsTestChain() && !fRequireStandard) {
|
||||
return InitError(strprintf(Untranslated("acceptnonstdtxn is not currently supported for %s chain"), chainparams.NetworkIDString()));
|
||||
}
|
||||
nBytesPerSigOp = args.GetIntArg("-bytespersigop", nBytesPerSigOp);
|
||||
|
||||
if (!g_wallet_init_interface.ParameterInteraction()) return false;
|
||||
|
|
|
@ -33,6 +33,7 @@ struct MemPoolOptions {
|
|||
int check_ratio{0};
|
||||
int64_t max_size_bytes{DEFAULT_MAX_MEMPOOL_SIZE_MB * 1'000'000};
|
||||
std::chrono::seconds expiry{std::chrono::hours{DEFAULT_MEMPOOL_EXPIRY_HOURS}};
|
||||
bool require_standard{true};
|
||||
bool full_rbf{DEFAULT_MEMPOOL_FULL_RBF};
|
||||
MemPoolLimits limits{};
|
||||
};
|
||||
|
|
|
@ -39,6 +39,11 @@ std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& argsman, con
|
|||
|
||||
if (auto hours = argsman.GetIntArg("-mempoolexpiry")) mempool_opts.expiry = std::chrono::hours{*hours};
|
||||
|
||||
mempool_opts.require_standard = !argsman.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
|
||||
if (!chainparams.IsTestChain() && !mempool_opts.require_standard) {
|
||||
return strprintf(Untranslated("acceptnonstdtxn is not currently supported for %s chain"), chainparams.NetworkIDString());
|
||||
}
|
||||
|
||||
mempool_opts.full_rbf = argsman.GetBoolArg("-mempoolfullrbf", mempool_opts.full_rbf);
|
||||
|
||||
ApplyArgsManOptions(argsman, mempool_opts.limits);
|
||||
|
|
|
@ -116,7 +116,7 @@ void MockTime(FuzzedDataProvider& fuzzed_data_provider, const CChainState& chain
|
|||
SetMockTime(time);
|
||||
}
|
||||
|
||||
CTxMemPool MakeMempool(const NodeContext& node)
|
||||
CTxMemPool MakeMempool(FuzzedDataProvider& fuzzed_data_provider, const NodeContext& node)
|
||||
{
|
||||
// Take the default options for tests...
|
||||
CTxMemPool::Options mempool_opts{MemPoolOptionsForTest(node)};
|
||||
|
@ -124,6 +124,7 @@ CTxMemPool MakeMempool(const NodeContext& node)
|
|||
// ...override specific options for this specific fuzz suite
|
||||
mempool_opts.estimator = nullptr;
|
||||
mempool_opts.check_ratio = 1;
|
||||
mempool_opts.require_standard = fuzzed_data_provider.ConsumeBool();
|
||||
|
||||
// ...and construct a CTxMemPool from it
|
||||
return CTxMemPool{mempool_opts};
|
||||
|
@ -150,7 +151,7 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
|
|||
constexpr CAmount SUPPLY_TOTAL{COINBASE_MATURITY * 50 * COIN};
|
||||
|
||||
SetMempoolConstraints(*node.args, fuzzed_data_provider);
|
||||
CTxMemPool tx_pool_{MakeMempool(node)};
|
||||
CTxMemPool tx_pool_{MakeMempool(fuzzed_data_provider, node)};
|
||||
MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(&tx_pool_);
|
||||
|
||||
chainstate.SetMempool(&tx_pool);
|
||||
|
@ -237,7 +238,6 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
|
|||
auto txr = std::make_shared<TransactionsDelta>(removed, added);
|
||||
RegisterSharedValidationInterface(txr);
|
||||
const bool bypass_limits = fuzzed_data_provider.ConsumeBool();
|
||||
::fRequireStandard = fuzzed_data_provider.ConsumeBool();
|
||||
|
||||
// Make sure ProcessNewPackage on one transaction works.
|
||||
// The result is not guaranteed to be the same as what is returned by ATMP.
|
||||
|
@ -325,7 +325,7 @@ FUZZ_TARGET_INIT(tx_pool, initialize_tx_pool)
|
|||
}
|
||||
|
||||
SetMempoolConstraints(*node.args, fuzzed_data_provider);
|
||||
CTxMemPool tx_pool_{MakeMempool(node)};
|
||||
CTxMemPool tx_pool_{MakeMempool(fuzzed_data_provider, node)};
|
||||
MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(&tx_pool_);
|
||||
|
||||
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 300)
|
||||
|
@ -348,7 +348,6 @@ FUZZ_TARGET_INIT(tx_pool, initialize_tx_pool)
|
|||
|
||||
const auto tx = MakeTransactionRef(mut_tx);
|
||||
const bool bypass_limits = fuzzed_data_provider.ConsumeBool();
|
||||
::fRequireStandard = fuzzed_data_provider.ConsumeBool();
|
||||
const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), bypass_limits, /*test_accept=*/false));
|
||||
const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
|
||||
if (accepted) {
|
||||
|
|
|
@ -458,6 +458,7 @@ CTxMemPool::CTxMemPool(const Options& opts)
|
|||
minerPolicyEstimator{opts.estimator},
|
||||
m_max_size_bytes{opts.max_size_bytes},
|
||||
m_expiry{opts.expiry},
|
||||
m_require_standard{opts.require_standard},
|
||||
m_full_rbf{opts.full_rbf},
|
||||
m_limits{opts.limits}
|
||||
{
|
||||
|
|
|
@ -568,6 +568,7 @@ public:
|
|||
|
||||
const int64_t m_max_size_bytes;
|
||||
const std::chrono::seconds m_expiry;
|
||||
const bool m_require_standard;
|
||||
const bool m_full_rbf;
|
||||
|
||||
using Limits = kernel::MemPoolLimits;
|
||||
|
|
|
@ -124,7 +124,6 @@ GlobalMutex g_best_block_mutex;
|
|||
std::condition_variable g_best_block_cv;
|
||||
uint256 g_best_block;
|
||||
bool g_parallel_script_checks{false};
|
||||
bool fRequireStandard = true;
|
||||
bool fCheckBlockIndex = false;
|
||||
bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED;
|
||||
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
|
||||
|
@ -700,8 +699,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||
|
||||
// Rather not work on nonstandard transactions (unless -testnet/-regtest)
|
||||
std::string reason;
|
||||
if (fRequireStandard && !IsStandardTx(tx, reason))
|
||||
if (m_pool.m_require_standard && !IsStandardTx(tx, reason)) {
|
||||
return state.Invalid(TxValidationResult::TX_NOT_STANDARD, reason);
|
||||
}
|
||||
|
||||
// Do not work on transactions that are too small.
|
||||
// A transaction with 1 segwit input and 1 P2WPHK output has non-witness size of 82 bytes.
|
||||
|
@ -807,13 +807,14 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||
return false; // state filled in by CheckTxInputs
|
||||
}
|
||||
|
||||
if (fRequireStandard && !AreInputsStandard(tx, m_view)) {
|
||||
if (m_pool.m_require_standard && !AreInputsStandard(tx, m_view)) {
|
||||
return state.Invalid(TxValidationResult::TX_INPUTS_NOT_STANDARD, "bad-txns-nonstandard-inputs");
|
||||
}
|
||||
|
||||
// Check for non-standard witnesses.
|
||||
if (tx.HasWitness() && fRequireStandard && !IsWitnessStandard(tx, m_view))
|
||||
if (tx.HasWitness() && m_pool.m_require_standard && !IsWitnessStandard(tx, m_view)) {
|
||||
return state.Invalid(TxValidationResult::TX_WITNESS_MUTATED, "bad-witness-nonstandard");
|
||||
}
|
||||
|
||||
int64_t nSigOpsCost = GetTransactionSigOpCost(tx, m_view, STANDARD_SCRIPT_VERIFY_FLAGS);
|
||||
|
||||
|
|
|
@ -100,7 +100,6 @@ extern uint256 g_best_block;
|
|||
* False indicates all script checking is done on the main threadMessageHandler thread.
|
||||
*/
|
||||
extern bool g_parallel_script_checks;
|
||||
extern bool fRequireStandard;
|
||||
extern bool fCheckBlockIndex;
|
||||
extern bool fCheckpointsEnabled;
|
||||
/** If the tip is older than this (in seconds), the node is considered to be in initial block download. */
|
||||
|
|
|
@ -245,7 +245,7 @@ class SegWitTest(BitcoinTestFramework):
|
|||
self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn(), services=P2P_SERVICES)
|
||||
# self.old_node sets only NODE_NETWORK
|
||||
self.old_node = self.nodes[0].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK)
|
||||
# self.std_node is for testing node1 (fRequireStandard=true)
|
||||
# self.std_node is for testing node1 (requires standard txs)
|
||||
self.std_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=P2P_SERVICES)
|
||||
# self.std_wtx_node is for testing node1 with wtxid relay
|
||||
self.std_wtx_node = self.nodes[1].add_p2p_connection(TestP2PConn(wtxidrelay=True), services=P2P_SERVICES)
|
||||
|
@ -1382,7 +1382,7 @@ class SegWitTest(BitcoinTestFramework):
|
|||
tx3.vout.append(CTxOut(total_value - 1000, script_pubkey))
|
||||
tx3.rehash()
|
||||
|
||||
# First we test this transaction against fRequireStandard=true node
|
||||
# First we test this transaction against std_node
|
||||
# making sure the txid is added to the reject filter
|
||||
self.std_node.announce_tx_and_wait_for_getdata(tx3)
|
||||
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-nonstandard-inputs")
|
||||
|
@ -1390,7 +1390,7 @@ class SegWitTest(BitcoinTestFramework):
|
|||
self.std_node.announce_tx_and_wait_for_getdata(tx3, success=False)
|
||||
|
||||
# Spending a higher version witness output is not allowed by policy,
|
||||
# even with fRequireStandard=false.
|
||||
# even with the node that accepts non-standard txs.
|
||||
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, with_witness=True, accepted=False, reason="reserved for soft-fork upgrades")
|
||||
|
||||
# Building a block with the transaction must be valid, however.
|
||||
|
|
Loading…
Add table
Reference in a new issue