mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 14:37:42 -03:00
fuzz: Speed up *_package_eval fuzz targets a bit
This commit is contained in:
parent
35000e34cf
commit
fa33818978
1 changed files with 9 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2023 The Bitcoin Core developers
|
// Copyright (c) 2023-present The Bitcoin Core developers
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@ void initialize_tx_pool()
|
||||||
}
|
}
|
||||||
|
|
||||||
struct OutpointsUpdater final : public CValidationInterface {
|
struct OutpointsUpdater final : public CValidationInterface {
|
||||||
std::set<COutPoint>& m_mempool_outpoints;
|
std::unordered_set<COutPoint, SaltedOutpointHasher>& m_mempool_outpoints;
|
||||||
|
|
||||||
explicit OutpointsUpdater(std::set<COutPoint>& r)
|
explicit OutpointsUpdater(std::unordered_set<COutPoint, SaltedOutpointHasher>& r)
|
||||||
: m_mempool_outpoints{r} {}
|
: m_mempool_outpoints{r} {}
|
||||||
|
|
||||||
void TransactionAddedToMempool(const NewMempoolTransactionInfo& tx, uint64_t /* mempool_sequence */) override
|
void TransactionAddedToMempool(const NewMempoolTransactionInfo& tx, uint64_t /* mempool_sequence */) override
|
||||||
|
@ -195,8 +195,8 @@ FUZZ_TARGET(ephemeral_package_eval, .init = initialize_tx_pool)
|
||||||
MockTime(fuzzed_data_provider, chainstate);
|
MockTime(fuzzed_data_provider, chainstate);
|
||||||
|
|
||||||
// All RBF-spendable outpoints outside of the unsubmitted package
|
// All RBF-spendable outpoints outside of the unsubmitted package
|
||||||
std::set<COutPoint> mempool_outpoints;
|
std::unordered_set<COutPoint, SaltedOutpointHasher> mempool_outpoints;
|
||||||
std::map<COutPoint, CAmount> outpoints_value;
|
std::unordered_map<COutPoint, CAmount, SaltedOutpointHasher> outpoints_value;
|
||||||
for (const auto& outpoint : g_outpoints_coinbase_init_mature) {
|
for (const auto& outpoint : g_outpoints_coinbase_init_mature) {
|
||||||
Assert(mempool_outpoints.insert(outpoint).second);
|
Assert(mempool_outpoints.insert(outpoint).second);
|
||||||
outpoints_value[outpoint] = 50 * COIN;
|
outpoints_value[outpoint] = 50 * COIN;
|
||||||
|
@ -222,7 +222,7 @@ FUZZ_TARGET(ephemeral_package_eval, .init = initialize_tx_pool)
|
||||||
// Make small packages
|
// Make small packages
|
||||||
const auto num_txs = outpoint_to_rbf ? 1 : (size_t) fuzzed_data_provider.ConsumeIntegralInRange<int>(1, 4);
|
const auto num_txs = outpoint_to_rbf ? 1 : (size_t) fuzzed_data_provider.ConsumeIntegralInRange<int>(1, 4);
|
||||||
|
|
||||||
std::set<COutPoint> package_outpoints;
|
std::unordered_set<COutPoint, SaltedOutpointHasher> package_outpoints;
|
||||||
while (txs.size() < num_txs) {
|
while (txs.size() < num_txs) {
|
||||||
// Create transaction to add to the mempool
|
// Create transaction to add to the mempool
|
||||||
txs.emplace_back([&] {
|
txs.emplace_back([&] {
|
||||||
|
@ -349,8 +349,8 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
|
||||||
MockTime(fuzzed_data_provider, chainstate);
|
MockTime(fuzzed_data_provider, chainstate);
|
||||||
|
|
||||||
// All RBF-spendable outpoints outside of the unsubmitted package
|
// All RBF-spendable outpoints outside of the unsubmitted package
|
||||||
std::set<COutPoint> mempool_outpoints;
|
std::unordered_set<COutPoint, SaltedOutpointHasher> mempool_outpoints;
|
||||||
std::map<COutPoint, CAmount> outpoints_value;
|
std::unordered_map<COutPoint, CAmount, SaltedOutpointHasher> outpoints_value;
|
||||||
for (const auto& outpoint : g_outpoints_coinbase_init_mature) {
|
for (const auto& outpoint : g_outpoints_coinbase_init_mature) {
|
||||||
Assert(mempool_outpoints.insert(outpoint).second);
|
Assert(mempool_outpoints.insert(outpoint).second);
|
||||||
outpoints_value[outpoint] = 50 * COIN;
|
outpoints_value[outpoint] = 50 * COIN;
|
||||||
|
@ -372,7 +372,7 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
|
||||||
|
|
||||||
// Make packages of 1-to-26 transactions
|
// Make packages of 1-to-26 transactions
|
||||||
const auto num_txs = (size_t) fuzzed_data_provider.ConsumeIntegralInRange<int>(1, 26);
|
const auto num_txs = (size_t) fuzzed_data_provider.ConsumeIntegralInRange<int>(1, 26);
|
||||||
std::set<COutPoint> package_outpoints;
|
std::unordered_set<COutPoint, SaltedOutpointHasher> package_outpoints;
|
||||||
while (txs.size() < num_txs) {
|
while (txs.size() < num_txs) {
|
||||||
// Create transaction to add to the mempool
|
// Create transaction to add to the mempool
|
||||||
txs.emplace_back([&] {
|
txs.emplace_back([&] {
|
||||||
|
|
Loading…
Add table
Reference in a new issue