Make number of inputs configurable in validatelargetx test
This commit is contained in:
@@ -195,7 +195,7 @@ case "$1" in
|
|||||||
zcash_rpc zcbenchmark verifyequihash 1000
|
zcash_rpc zcbenchmark verifyequihash 1000
|
||||||
;;
|
;;
|
||||||
validatelargetx)
|
validatelargetx)
|
||||||
zcash_rpc zcbenchmark validatelargetx 5
|
zcash_rpc zcbenchmark validatelargetx 10 "${@:3}"
|
||||||
;;
|
;;
|
||||||
trydecryptnotes)
|
trydecryptnotes)
|
||||||
zcash_rpc zcbenchmark trydecryptnotes 1000 "${@:3}"
|
zcash_rpc zcbenchmark trydecryptnotes 1000 "${@:3}"
|
||||||
|
|||||||
@@ -2581,7 +2581,12 @@ UniValue zc_benchmark(const UniValue& params, bool fHelp)
|
|||||||
} else if (benchmarktype == "verifyequihash") {
|
} else if (benchmarktype == "verifyequihash") {
|
||||||
sample_times.push_back(benchmark_verify_equihash());
|
sample_times.push_back(benchmark_verify_equihash());
|
||||||
} else if (benchmarktype == "validatelargetx") {
|
} else if (benchmarktype == "validatelargetx") {
|
||||||
sample_times.push_back(benchmark_large_tx());
|
// Number of inputs in the spending transaction that we will simulate
|
||||||
|
int nInputs = 555;
|
||||||
|
if (params.size() >= 3) {
|
||||||
|
nInputs = params[2].get_int();
|
||||||
|
}
|
||||||
|
sample_times.push_back(benchmark_large_tx(nInputs));
|
||||||
} else if (benchmarktype == "trydecryptnotes") {
|
} else if (benchmarktype == "trydecryptnotes") {
|
||||||
int nAddrs = params[2].get_int();
|
int nAddrs = params[2].get_int();
|
||||||
sample_times.push_back(benchmark_try_decrypt_notes(nAddrs));
|
sample_times.push_back(benchmark_try_decrypt_notes(nAddrs));
|
||||||
|
|||||||
@@ -222,11 +222,8 @@ double benchmark_verify_equihash()
|
|||||||
return timer_stop(tv_start);
|
return timer_stop(tv_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
double benchmark_large_tx()
|
double benchmark_large_tx(size_t nInputs)
|
||||||
{
|
{
|
||||||
// Number of inputs in the spending transaction that we will simulate
|
|
||||||
const size_t NUM_INPUTS = 555;
|
|
||||||
|
|
||||||
// Create priv/pub key
|
// Create priv/pub key
|
||||||
CKey priv;
|
CKey priv;
|
||||||
priv.MakeNewKey(false);
|
priv.MakeNewKey(false);
|
||||||
@@ -246,35 +243,24 @@ double benchmark_large_tx()
|
|||||||
|
|
||||||
CMutableTransaction spending_tx;
|
CMutableTransaction spending_tx;
|
||||||
auto input_hash = orig_tx.GetHash();
|
auto input_hash = orig_tx.GetHash();
|
||||||
// Add NUM_INPUTS inputs
|
// Add nInputs inputs
|
||||||
for (size_t i = 0; i < NUM_INPUTS; i++) {
|
for (size_t i = 0; i < nInputs; i++) {
|
||||||
spending_tx.vin.emplace_back(input_hash, 0);
|
spending_tx.vin.emplace_back(input_hash, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sign for all the inputs
|
// Sign for all the inputs
|
||||||
auto consensusBranchId = NetworkUpgradeInfo[Consensus::UPGRADE_OVERWINTER].nBranchId;
|
auto consensusBranchId = NetworkUpgradeInfo[Consensus::UPGRADE_OVERWINTER].nBranchId;
|
||||||
for (size_t i = 0; i < NUM_INPUTS; i++) {
|
for (size_t i = 0; i < nInputs; i++) {
|
||||||
SignSignature(tempKeystore, prevPubKey, spending_tx, i, 1000000, SIGHASH_ALL, consensusBranchId);
|
SignSignature(tempKeystore, prevPubKey, spending_tx, i, 1000000, SIGHASH_ALL, consensusBranchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize:
|
|
||||||
{
|
|
||||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
|
||||||
ss << spending_tx;
|
|
||||||
//std::cout << "SIZE OF SPENDING TX: " << ss.size() << std::endl;
|
|
||||||
|
|
||||||
auto error = MAX_TX_SIZE / 20; // 5% error
|
|
||||||
assert(ss.size() < MAX_TX_SIZE + error);
|
|
||||||
assert(ss.size() > MAX_TX_SIZE - error);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spending tx has all its inputs signed and does not need to be mutated anymore
|
// Spending tx has all its inputs signed and does not need to be mutated anymore
|
||||||
CTransaction final_spending_tx(spending_tx);
|
CTransaction final_spending_tx(spending_tx);
|
||||||
|
|
||||||
// Benchmark signature verification costs:
|
// Benchmark signature verification costs:
|
||||||
struct timeval tv_start;
|
struct timeval tv_start;
|
||||||
timer_start(tv_start);
|
timer_start(tv_start);
|
||||||
for (size_t i = 0; i < NUM_INPUTS; i++) {
|
for (size_t i = 0; i < nInputs; i++) {
|
||||||
ScriptError serror = SCRIPT_ERR_OK;
|
ScriptError serror = SCRIPT_ERR_OK;
|
||||||
assert(VerifyScript(final_spending_tx.vin[i].scriptSig,
|
assert(VerifyScript(final_spending_tx.vin[i].scriptSig,
|
||||||
prevPubKey,
|
prevPubKey,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ extern double benchmark_solve_equihash();
|
|||||||
extern std::vector<double> benchmark_solve_equihash_threaded(int nThreads);
|
extern std::vector<double> benchmark_solve_equihash_threaded(int nThreads);
|
||||||
extern double benchmark_verify_joinsplit(const JSDescription &joinsplit);
|
extern double benchmark_verify_joinsplit(const JSDescription &joinsplit);
|
||||||
extern double benchmark_verify_equihash();
|
extern double benchmark_verify_equihash();
|
||||||
extern double benchmark_large_tx();
|
extern double benchmark_large_tx(size_t nInputs);
|
||||||
extern double benchmark_try_decrypt_notes(size_t nAddrs);
|
extern double benchmark_try_decrypt_notes(size_t nAddrs);
|
||||||
extern double benchmark_increment_note_witnesses(size_t nTxs);
|
extern double benchmark_increment_note_witnesses(size_t nTxs);
|
||||||
extern double benchmark_connectblock_slow();
|
extern double benchmark_connectblock_slow();
|
||||||
|
|||||||
Reference in New Issue
Block a user