mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-15 08:23:46 +02:00
d8f4e7caf0doc: add release notes (ismaelsadeeq)248c175e3dtest: ensure `ValidateInputsStandardness` optionally returns debug string (ismaelsadeeq)d2716e9e5bpolicy: update `AreInputsStandard` to return error string (ismaelsadeeq) Pull request description: This PR is another attempt at #13525. Transactions that fail `PreChecks` Validation due to non-standard inputs now returns invalid validation state`TxValidationResult::TX_INPUTS_NOT_STANDARD` along with a debug error message. Previously, the debug error message for non-standard inputs do not specify why the inputs were considered non-standard. Instead, the same error string, `bad-txns-nonstandard-inputs`, used for all types of non-standard input scriptSigs. This PR updates the `AreInputsStandard` to include the reason why inputs are non-standard in the debug message. This improves the `Precheck` debug message to be more descriptive. Furthermore, I have addressed all remaining comments from #13525 in this PR. ACKs for top commit: instagibbs: ACKd8f4e7caf0achow101: ACKd8f4e7caf0sedited: Re-ACKd8f4e7caf0Tree-SHA512: 19b1a73c68584522f863b9ee2c8d3a735348667f3628dc51e36be3ba59158509509fcc1ffc5683555112c09c8b14da3ad140bb879eac629b6f60b8313cfd8b91
57 lines
2.0 KiB
C++
57 lines
2.0 KiB
C++
// Copyright (c) 2016-present The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <bench/bench.h>
|
|
#include <coins.h>
|
|
#include <consensus/amount.h>
|
|
#include <key.h>
|
|
#include <policy/policy.h>
|
|
#include <primitives/transaction.h>
|
|
#include <script/script.h>
|
|
#include <script/signingprovider.h>
|
|
#include <test/util/transaction_utils.h>
|
|
|
|
#include <cassert>
|
|
#include <vector>
|
|
|
|
// Microbenchmark for simple accesses to a CCoinsViewCache database. Note from
|
|
// laanwj, "replicating the actual usage patterns of the client is hard though,
|
|
// many times micro-benchmarks of the database showed completely different
|
|
// characteristics than e.g. reindex timings. But that's not a requirement of
|
|
// every benchmark."
|
|
// (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484)
|
|
static void CCoinsCaching(benchmark::Bench& bench)
|
|
{
|
|
ECC_Context ecc_context{};
|
|
|
|
FillableSigningProvider keystore;
|
|
CCoinsView coinsDummy;
|
|
CCoinsViewCache coins(&coinsDummy);
|
|
std::vector<CMutableTransaction> dummyTransactions =
|
|
SetupDummyInputs(keystore, coins, {11 * COIN, 50 * COIN, 21 * COIN, 22 * COIN});
|
|
|
|
CMutableTransaction t1;
|
|
t1.vin.resize(3);
|
|
t1.vin[0].prevout.hash = dummyTransactions[0].GetHash();
|
|
t1.vin[0].prevout.n = 1;
|
|
t1.vin[0].scriptSig << std::vector<unsigned char>(65, 0);
|
|
t1.vin[1].prevout.hash = dummyTransactions[1].GetHash();
|
|
t1.vin[1].prevout.n = 0;
|
|
t1.vin[1].scriptSig << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4);
|
|
t1.vin[2].prevout.hash = dummyTransactions[1].GetHash();
|
|
t1.vin[2].prevout.n = 1;
|
|
t1.vin[2].scriptSig << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4);
|
|
t1.vout.resize(2);
|
|
t1.vout[0].nValue = 90 * COIN;
|
|
t1.vout[0].scriptPubKey << OP_1;
|
|
|
|
// Benchmark.
|
|
const CTransaction tx_1(t1);
|
|
bench.run([&] {
|
|
assert(ValidateInputsStandardness(tx_1, coins).IsValid());
|
|
});
|
|
}
|
|
|
|
BENCHMARK(CCoinsCaching);
|