Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
verify_script.cpp
Go to the documentation of this file.
1// Copyright (c) 2016-2018 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <bench/bench.h>
6#include <key.h>
7#if defined(HAVE_CONSENSUS_LIB)
9#endif
10#include <script/interpreter.h>
11#include <script/script.h>
12#include <script/script_error.h>
13#include <script/standard.h>
14#include <streams.h>
15#include <test/util/transaction_utils.h>
16
17#include <array>
18
20 std::vector<std::vector<uint8_t>> stack;
21 CScript script;
22 for (int i = 0; i < 100; ++i) {
23 script << OP_1 << OP_IF;
24 }
25 for (int i = 0; i < 1000; ++i) {
26 script << OP_1;
27 }
28 for (int i = 0; i < 100; ++i) {
29 script << OP_ENDIF;
30 }
31 bench.run([&] {
32 auto stack_copy = stack;
33 ScriptExecutionMetrics metrics = {};
35 bool ret = EvalScript(stack_copy, script, 0, BaseSignatureChecker(),
36 metrics, &error);
37 assert(ret);
38 });
39}
40
#define BENCHMARK(n)
Definition bench.h:65
Serialized script, used inside transaction inputs and outputs.
Definition script.h:431
Main entry point to nanobench's benchmarking facility.
Definition nanobench.h:616
bool EvalScript(std::vector< valtype > &stack, const CScript &script, uint32_t flags, const BaseSignatureChecker &checker, ScriptExecutionMetrics &metrics, ScriptError *serror)
bool error(const char *fmt, const Args &...args)
Definition logging.h:226
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
@ OP_IF
Definition script.h:77
@ OP_ENDIF
Definition script.h:82
@ OP_1
Definition script.h:56
ScriptError
Struct for holding cumulative results from executing a script or a sequence of scripts.
assert(!tx.IsCoinBase())
static void VerifyNestedIfScript(benchmark::Bench &bench)