diff options
Diffstat (limited to 'src/bench')
-rw-r--r-- | src/bench/base58.cpp | 1 | ||||
-rw-r--r-- | src/bench/bench.h | 1 | ||||
-rw-r--r-- | src/bench/bench_bitcoin.cpp | 11 | ||||
-rw-r--r-- | src/bench/block_assemble.cpp | 5 | ||||
-rw-r--r-- | src/bench/chacha20.cpp | 1 | ||||
-rw-r--r-- | src/bench/chacha_poly_aead.cpp | 1 | ||||
-rw-r--r-- | src/bench/checkblock.cpp | 2 | ||||
-rw-r--r-- | src/bench/coin_selection.cpp | 7 | ||||
-rw-r--r-- | src/bench/crypto_hash.cpp | 1 | ||||
-rw-r--r-- | src/bench/duplicate_inputs.cpp | 5 | ||||
-rw-r--r-- | src/bench/lockedpool.cpp | 1 | ||||
-rw-r--r-- | src/bench/mempool_eviction.cpp | 2 | ||||
-rw-r--r-- | src/bench/poly1305.cpp | 1 | ||||
-rw-r--r-- | src/bench/rollingbloom.cpp | 1 | ||||
-rw-r--r-- | src/bench/rpc_blockchain.cpp | 1 | ||||
-rw-r--r-- | src/bench/rpc_mempool.cpp | 2 | ||||
-rw-r--r-- | src/bench/verify_script.cpp | 40 | ||||
-rw-r--r-- | src/bench/wallet_balance.cpp | 4 |
18 files changed, 24 insertions, 63 deletions
diff --git a/src/bench/base58.cpp b/src/bench/base58.cpp index 0f4b52cf79..40a7b5e320 100644 --- a/src/bench/base58.cpp +++ b/src/bench/base58.cpp @@ -8,7 +8,6 @@ #include <array> #include <vector> -#include <string> static void Base58Encode(benchmark::State& state) diff --git a/src/bench/bench.h b/src/bench/bench.h index 35eeab3393..3a8c487b9a 100644 --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -6,7 +6,6 @@ #define BITCOIN_BENCH_BENCH_H #include <functional> -#include <limits> #include <map> #include <string> #include <vector> diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp index d0d7c03ee1..9235d5fe6a 100644 --- a/src/bench/bench_bitcoin.cpp +++ b/src/bench/bench_bitcoin.cpp @@ -36,7 +36,7 @@ int main(int argc, char** argv) SetupBenchArgs(); std::string error; if (!gArgs.ParseParameters(argc, argv, error)) { - tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error.c_str()); + tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error); return EXIT_FAILURE; } @@ -51,9 +51,16 @@ int main(int argc, char** argv) std::string scaling_str = gArgs.GetArg("-scaling", DEFAULT_BENCH_SCALING); bool is_list_only = gArgs.GetBoolArg("-list", false); + if (evaluations == 0) { + return EXIT_SUCCESS; + } else if (evaluations < 0) { + tfm::format(std::cerr, "Error parsing evaluations argument: %d\n", evaluations); + return EXIT_FAILURE; + } + double scaling_factor; if (!ParseDouble(scaling_str, &scaling_factor)) { - tfm::format(std::cerr, "Error parsing scaling factor as double: %s\n", scaling_str.c_str()); + tfm::format(std::cerr, "Error parsing scaling factor as double: %s\n", scaling_str); return EXIT_FAILURE; } diff --git a/src/bench/block_assemble.cpp b/src/bench/block_assemble.cpp index fb33c09ab2..2f47398d99 100644 --- a/src/bench/block_assemble.cpp +++ b/src/bench/block_assemble.cpp @@ -10,7 +10,6 @@ #include <validation.h> -#include <list> #include <vector> static void AssembleBlock(benchmark::State& state) @@ -39,8 +38,8 @@ static void AssembleBlock(benchmark::State& state) LOCK(::cs_main); // Required for ::AcceptToMemoryPool. for (const auto& txr : txs) { - CValidationState state; - bool ret{::AcceptToMemoryPool(::mempool, state, txr, nullptr /* pfMissingInputs */, nullptr /* plTxnReplaced */, false /* bypass_limits */, /* nAbsurdFee */ 0)}; + TxValidationState state; + bool ret{::AcceptToMemoryPool(::mempool, state, txr, nullptr /* plTxnReplaced */, false /* bypass_limits */, /* nAbsurdFee */ 0)}; assert(ret); } } diff --git a/src/bench/chacha20.cpp b/src/bench/chacha20.cpp index 030067aca5..f1b0a9a989 100644 --- a/src/bench/chacha20.cpp +++ b/src/bench/chacha20.cpp @@ -2,7 +2,6 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include <iostream> #include <bench/bench.h> #include <crypto/chacha20.h> diff --git a/src/bench/chacha_poly_aead.cpp b/src/bench/chacha_poly_aead.cpp index f5f7297490..a02a5315a4 100644 --- a/src/bench/chacha_poly_aead.cpp +++ b/src/bench/chacha_poly_aead.cpp @@ -2,7 +2,6 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include <iostream> #include <bench/bench.h> #include <crypto/chacha_poly_aead.h> diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp index 4b13381e16..edf43bd4dc 100644 --- a/src/bench/checkblock.cpp +++ b/src/bench/checkblock.cpp @@ -42,7 +42,7 @@ static void DeserializeAndCheckBlockTest(benchmark::State& state) bool rewound = stream.Rewind(benchmark::data::block413567.size()); assert(rewound); - CValidationState validationState; + BlockValidationState validationState; bool checked = CheckBlock(block, validationState, chainParams->GetConsensus()); assert(checked); } diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp index f2ab03e20e..29a145bfe6 100644 --- a/src/bench/coin_selection.cpp +++ b/src/bench/coin_selection.cpp @@ -4,6 +4,7 @@ #include <bench/bench.h> #include <interfaces/chain.h> +#include <node/context.h> #include <wallet/coinselection.h> #include <wallet/wallet.h> @@ -28,7 +29,8 @@ static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<st // (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484) static void CoinSelection(benchmark::State& state) { - auto chain = interfaces::MakeChain(); + NodeContext node; + auto chain = interfaces::MakeChain(node); const CWallet wallet(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); std::vector<std::unique_ptr<CWalletTx>> wtxs; LOCK(wallet.cs_wallet); @@ -60,7 +62,8 @@ static void CoinSelection(benchmark::State& state) } typedef std::set<CInputCoin> CoinSet; -static auto testChain = interfaces::MakeChain(); +static NodeContext testNode; +static auto testChain = interfaces::MakeChain(testNode); static const CWallet testWallet(testChain.get(), WalletLocation(), WalletDatabase::CreateDummy()); std::vector<std::unique_ptr<CWalletTx>> wtxn; diff --git a/src/bench/crypto_hash.cpp b/src/bench/crypto_hash.cpp index fb2bab9dee..674753c191 100644 --- a/src/bench/crypto_hash.cpp +++ b/src/bench/crypto_hash.cpp @@ -2,7 +2,6 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include <iostream> #include <bench/bench.h> #include <hash.h> diff --git a/src/bench/duplicate_inputs.cpp b/src/bench/duplicate_inputs.cpp index 2440341287..a783370b4e 100644 --- a/src/bench/duplicate_inputs.cpp +++ b/src/bench/duplicate_inputs.cpp @@ -4,15 +4,12 @@ #include <bench/bench.h> #include <chainparams.h> -#include <coins.h> #include <consensus/merkle.h> #include <consensus/validation.h> #include <pow.h> #include <txmempool.h> #include <validation.h> -#include <list> -#include <vector> static void DuplicateInputs(benchmark::State& state) @@ -57,7 +54,7 @@ static void DuplicateInputs(benchmark::State& state) block.hashMerkleRoot = BlockMerkleRoot(block); while (state.KeepRunning()) { - CValidationState cvstate{}; + BlockValidationState cvstate{}; assert(!CheckBlock(block, cvstate, chainparams.GetConsensus(), false, false)); assert(cvstate.GetRejectReason() == "bad-txns-inputs-duplicate"); } diff --git a/src/bench/lockedpool.cpp b/src/bench/lockedpool.cpp index 0712eab4bc..0d9b123400 100644 --- a/src/bench/lockedpool.cpp +++ b/src/bench/lockedpool.cpp @@ -6,7 +6,6 @@ #include <support/lockedpool.h> -#include <iostream> #include <vector> #define ASIZE 2048 diff --git a/src/bench/mempool_eviction.cpp b/src/bench/mempool_eviction.cpp index ac8a182358..a2a21c673b 100644 --- a/src/bench/mempool_eviction.cpp +++ b/src/bench/mempool_eviction.cpp @@ -6,8 +6,6 @@ #include <policy/policy.h> #include <txmempool.h> -#include <list> -#include <vector> static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs) { diff --git a/src/bench/poly1305.cpp b/src/bench/poly1305.cpp index 16342d0fbe..02e5fecc0d 100644 --- a/src/bench/poly1305.cpp +++ b/src/bench/poly1305.cpp @@ -2,7 +2,6 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include <iostream> #include <bench/bench.h> #include <crypto/poly1305.h> diff --git a/src/bench/rollingbloom.cpp b/src/bench/rollingbloom.cpp index 4016530dac..cffdb388f8 100644 --- a/src/bench/rollingbloom.cpp +++ b/src/bench/rollingbloom.cpp @@ -2,7 +2,6 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include <iostream> #include <bench/bench.h> #include <bloom.h> diff --git a/src/bench/rpc_blockchain.cpp b/src/bench/rpc_blockchain.cpp index 29e448fc43..2fc6f116a4 100644 --- a/src/bench/rpc_blockchain.cpp +++ b/src/bench/rpc_blockchain.cpp @@ -7,7 +7,6 @@ #include <validation.h> #include <streams.h> -#include <consensus/validation.h> #include <rpc/blockchain.h> #include <univalue.h> diff --git a/src/bench/rpc_mempool.cpp b/src/bench/rpc_mempool.cpp index b35a744055..bf63cccf09 100644 --- a/src/bench/rpc_mempool.cpp +++ b/src/bench/rpc_mempool.cpp @@ -8,8 +8,6 @@ #include <univalue.h> -#include <list> -#include <vector> static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs) { diff --git a/src/bench/verify_script.cpp b/src/bench/verify_script.cpp index 4891c57b3a..c9947f192e 100644 --- a/src/bench/verify_script.cpp +++ b/src/bench/verify_script.cpp @@ -10,44 +10,10 @@ #include <script/script.h> #include <script/standard.h> #include <streams.h> +#include <test/lib/transaction_utils.h> #include <array> -// FIXME: Dedup with BuildCreditingTransaction in test/script_tests.cpp. -static CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey) -{ - CMutableTransaction txCredit; - txCredit.nVersion = 1; - txCredit.nLockTime = 0; - txCredit.vin.resize(1); - txCredit.vout.resize(1); - txCredit.vin[0].prevout.SetNull(); - txCredit.vin[0].scriptSig = CScript() << CScriptNum(0) << CScriptNum(0); - txCredit.vin[0].nSequence = CTxIn::SEQUENCE_FINAL; - txCredit.vout[0].scriptPubKey = scriptPubKey; - txCredit.vout[0].nValue = 1; - - return txCredit; -} - -// FIXME: Dedup with BuildSpendingTransaction in test/script_tests.cpp. -static CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CMutableTransaction& txCredit) -{ - CMutableTransaction txSpend; - txSpend.nVersion = 1; - txSpend.nLockTime = 0; - txSpend.vin.resize(1); - txSpend.vout.resize(1); - txSpend.vin[0].prevout.hash = txCredit.GetHash(); - txSpend.vin[0].prevout.n = 0; - txSpend.vin[0].scriptSig = scriptSig; - txSpend.vin[0].nSequence = CTxIn::SEQUENCE_FINAL; - txSpend.vout[0].scriptPubKey = CScript(); - txSpend.vout[0].nValue = txCredit.vout[0].nValue; - - return txSpend; -} - // Microbenchmark for verification of a basic P2WPKH script. Can be easily // modified to measure performance of other types of scripts. static void VerifyScriptBench(benchmark::State& state) @@ -71,8 +37,8 @@ static void VerifyScriptBench(benchmark::State& state) CScript scriptPubKey = CScript() << witnessversion << ToByteVector(pubkeyHash); CScript scriptSig; CScript witScriptPubkey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(pubkeyHash) << OP_EQUALVERIFY << OP_CHECKSIG; - const CMutableTransaction& txCredit = BuildCreditingTransaction(scriptPubKey); - CMutableTransaction txSpend = BuildSpendingTransaction(scriptSig, txCredit); + const CMutableTransaction& txCredit = BuildCreditingTransaction(scriptPubKey, 1); + CMutableTransaction txSpend = BuildSpendingTransaction(scriptSig, CScriptWitness(), CTransaction(txCredit)); CScriptWitness& witness = txSpend.vin[0].scriptWitness; witness.stack.emplace_back(); key.Sign(SignatureHash(witScriptPubkey, txSpend, 0, SIGHASH_ALL, txCredit.vout[0].nValue, SigVersion::WITNESS_V0), witness.stack.back()); diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp index 313b5a3ba0..0e660d6bcd 100644 --- a/src/bench/wallet_balance.cpp +++ b/src/bench/wallet_balance.cpp @@ -4,6 +4,7 @@ #include <bench/bench.h> #include <interfaces/chain.h> +#include <node/context.h> #include <optional.h> #include <test/util.h> #include <validationinterface.h> @@ -13,7 +14,8 @@ static void WalletBalance(benchmark::State& state, const bool set_dirty, const b { const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE; - std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(); + NodeContext node; + std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node); CWallet wallet{chain.get(), WalletLocation(), WalletDatabase::CreateMock()}; { bool first_run; |