Browse Source
Add benchmark for attempting decryption of notes
pull/4/head
Jack Grigg
8 years ago
No known key found for this signature in database
GPG Key ID: 6A6914DAFBEA00DA
4 changed files with
35 additions and
2 deletions
-
qa/zcash/performance-measurements.sh
-
src/wallet/rpcwallet.cpp
-
src/zcbenchmarks.cpp
-
src/zcbenchmarks.h
|
|
@ -56,7 +56,7 @@ function zcashd_valgrind_stop { |
|
|
|
case "$1" in |
|
|
|
*) |
|
|
|
case "$2" in |
|
|
|
verifyjoinsplit) |
|
|
|
verifyjoinsplit|trydecryptnotes) |
|
|
|
zcashd_start |
|
|
|
RAWJOINSPLIT=$(zcash_rpc zcsamplejoinsplit) |
|
|
|
zcashd_stop |
|
|
@ -88,6 +88,9 @@ case "$1" in |
|
|
|
validatelargetx) |
|
|
|
zcash_rpc zcbenchmark validatelargetx 5 |
|
|
|
;; |
|
|
|
trydecryptnotes) |
|
|
|
zcash_rpc zcbenchmark trydecryptnotes 1000 "\"$RAWJOINSPLIT\"" |
|
|
|
;; |
|
|
|
*) |
|
|
|
zcashd_stop |
|
|
|
echo "Bad arguments." |
|
|
@ -116,6 +119,9 @@ case "$1" in |
|
|
|
verifyequihash) |
|
|
|
zcash_rpc zcbenchmark verifyequihash 1 |
|
|
|
;; |
|
|
|
trydecryptnotes) |
|
|
|
zcash_rpc zcbenchmark trydecryptnotes 1 "\"$RAWJOINSPLIT\"" |
|
|
|
;; |
|
|
|
*) |
|
|
|
zcashd_massif_stop |
|
|
|
echo "Bad arguments." |
|
|
@ -145,6 +151,9 @@ case "$1" in |
|
|
|
verifyequihash) |
|
|
|
zcash_rpc zcbenchmark verifyequihash 1 |
|
|
|
;; |
|
|
|
trydecryptnotes) |
|
|
|
zcash_rpc zcbenchmark trydecryptnotes 1 "\"$RAWJOINSPLIT\"" |
|
|
|
;; |
|
|
|
*) |
|
|
|
zcashd_valgrind_stop |
|
|
|
echo "Bad arguments." |
|
|
|
|
|
@ -2454,7 +2454,8 @@ Value zc_benchmark(const json_spirit::Array& params, bool fHelp) |
|
|
|
|
|
|
|
JSDescription samplejoinsplit; |
|
|
|
|
|
|
|
if (benchmarktype == "verifyjoinsplit") { |
|
|
|
if (benchmarktype == "verifyjoinsplit" || |
|
|
|
benchmarktype == "trydecryptnotes") { |
|
|
|
CDataStream ss(ParseHexV(params[2].get_str(), "js"), SER_NETWORK, PROTOCOL_VERSION); |
|
|
|
ss >> samplejoinsplit; |
|
|
|
} |
|
|
@ -2480,6 +2481,8 @@ Value zc_benchmark(const json_spirit::Array& params, bool fHelp) |
|
|
|
sample_times.push_back(benchmark_verify_equihash()); |
|
|
|
} else if (benchmarktype == "validatelargetx") { |
|
|
|
sample_times.push_back(benchmark_large_tx()); |
|
|
|
} else if (benchmarktype == "trydecryptnotes") { |
|
|
|
sample_times.push_back(benchmark_try_decrypt_notes(samplejoinsplit)); |
|
|
|
} else { |
|
|
|
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid benchmarktype"); |
|
|
|
} |
|
|
|
|
|
@ -223,3 +223,23 @@ double benchmark_large_tx() |
|
|
|
return timer_stop(tv_start); |
|
|
|
} |
|
|
|
|
|
|
|
double benchmark_try_decrypt_notes(const JSDescription &joinsplit) |
|
|
|
{ |
|
|
|
const size_t NUM_ADDRS = 10; |
|
|
|
|
|
|
|
CWallet wallet; |
|
|
|
for (int i = 0; i < NUM_ADDRS; i++) { |
|
|
|
auto sk = libzcash::SpendingKey::random(); |
|
|
|
wallet.AddSpendingKey(sk); |
|
|
|
} |
|
|
|
|
|
|
|
CMutableTransaction mtx; |
|
|
|
mtx.vjoinsplit.push_back(joinsplit); |
|
|
|
CTransaction tx(mtx); |
|
|
|
|
|
|
|
struct timeval tv_start; |
|
|
|
timer_start(tv_start); |
|
|
|
auto nd = wallet.FindMyNotes(tx); |
|
|
|
return timer_stop(tv_start); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -12,5 +12,6 @@ extern std::vector<double> benchmark_solve_equihash_threaded(int nThreads); |
|
|
|
extern double benchmark_verify_joinsplit(const JSDescription &joinsplit); |
|
|
|
extern double benchmark_verify_equihash(); |
|
|
|
extern double benchmark_large_tx(); |
|
|
|
extern double benchmark_try_decrypt_notes(const JSDescription &joinsplit); |
|
|
|
|
|
|
|
#endif |
|
|
|