desprout
This commit is contained in:
@@ -93,29 +93,6 @@ double benchmark_sleep()
|
||||
return timer_stop(tv_start);
|
||||
}
|
||||
|
||||
double benchmark_create_joinsplit()
|
||||
{
|
||||
uint256 joinSplitPubKey;
|
||||
|
||||
/* Get the anchor of an empty commitment tree. */
|
||||
uint256 anchor = SproutMerkleTree().root();
|
||||
|
||||
struct timeval tv_start;
|
||||
timer_start(tv_start);
|
||||
JSDescription jsdesc(*pzcashParams,
|
||||
joinSplitPubKey,
|
||||
anchor,
|
||||
{JSInput(), JSInput()},
|
||||
{JSOutput(), JSOutput()},
|
||||
0,
|
||||
0);
|
||||
double ret = timer_stop(tv_start);
|
||||
|
||||
auto verifier = libzcash::ProofVerifier::Strict();
|
||||
assert(jsdesc.Verify(*pzcashParams, verifier, joinSplitPubKey));
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<double> benchmark_create_joinsplit_threaded(int nThreads)
|
||||
{
|
||||
std::vector<double> ret;
|
||||
@@ -263,160 +240,6 @@ double benchmark_large_tx(size_t nInputs)
|
||||
return timer_stop(tv_start);
|
||||
}
|
||||
|
||||
double benchmark_try_decrypt_notes(size_t nAddrs)
|
||||
{
|
||||
CWallet wallet;
|
||||
for (int i = 0; i < nAddrs; i++) {
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
}
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
auto tx = GetValidReceive(*pzcashParams, sk, 10, true);
|
||||
|
||||
struct timeval tv_start;
|
||||
timer_start(tv_start);
|
||||
auto nd = wallet.FindMySproutNotes(tx);
|
||||
return timer_stop(tv_start);
|
||||
}
|
||||
|
||||
double benchmark_increment_note_witnesses(size_t nTxs)
|
||||
{
|
||||
CWallet wallet;
|
||||
SproutMerkleTree sproutTree;
|
||||
SaplingMerkleTree saplingTree;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
||||
// First block
|
||||
CBlock block1;
|
||||
for (int i = 0; i < nTxs; i++) {
|
||||
auto wtx = GetValidReceive(*pzcashParams, sk, 10, true);
|
||||
auto note = GetNote(*pzcashParams, sk, wtx, 0, 1);
|
||||
auto nullifier = note.nullifier(sk);
|
||||
|
||||
mapSproutNoteData_t noteData;
|
||||
JSOutPoint jsoutpt {wtx.GetHash(), 0, 1};
|
||||
SproutNoteData nd {sk.address(), nullifier};
|
||||
noteData[jsoutpt] = nd;
|
||||
|
||||
wtx.SetSproutNoteData(noteData);
|
||||
wallet.AddToWallet(wtx, true, NULL);
|
||||
block1.vtx.push_back(wtx);
|
||||
}
|
||||
CBlockIndex index1(block1);
|
||||
index1.SetHeight(1);
|
||||
|
||||
// Increment to get transactions witnessed
|
||||
wallet.ChainTip(&index1, &block1, std::make_pair(sproutTree, saplingTree));
|
||||
|
||||
// Second block
|
||||
CBlock block2;
|
||||
block2.hashPrevBlock = block1.GetHash();
|
||||
{
|
||||
auto wtx = GetValidReceive(*pzcashParams, sk, 10, true);
|
||||
auto note = GetNote(*pzcashParams, sk, wtx, 0, 1);
|
||||
auto nullifier = note.nullifier(sk);
|
||||
|
||||
mapSproutNoteData_t noteData;
|
||||
JSOutPoint jsoutpt {wtx.GetHash(), 0, 1};
|
||||
SproutNoteData nd {sk.address(), nullifier};
|
||||
noteData[jsoutpt] = nd;
|
||||
|
||||
wtx.SetSproutNoteData(noteData);
|
||||
wallet.AddToWallet(wtx, true, NULL);
|
||||
block2.vtx.push_back(wtx);
|
||||
}
|
||||
CBlockIndex index2(block2);
|
||||
index2.SetHeight(2);
|
||||
|
||||
struct timeval tv_start;
|
||||
timer_start(tv_start);
|
||||
wallet.ChainTip(&index2, &block2, std::make_pair(sproutTree, saplingTree));
|
||||
return timer_stop(tv_start);
|
||||
}
|
||||
|
||||
// Fake the input of a given block
|
||||
class FakeCoinsViewDB : public CCoinsViewDB {
|
||||
uint256 hash;
|
||||
SproutMerkleTree t;
|
||||
|
||||
public:
|
||||
FakeCoinsViewDB(std::string dbName, uint256& hash) : CCoinsViewDB(dbName, 100, false, false), hash(hash) {}
|
||||
|
||||
bool GetAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const {
|
||||
if (rt == t.root()) {
|
||||
tree = t;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetNullifier(const uint256 &nf, ShieldedType type) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint256 GetBestBlock() const {
|
||||
return hash;
|
||||
}
|
||||
|
||||
uint256 GetBestAnchor() const {
|
||||
return t.root();
|
||||
}
|
||||
|
||||
bool BatchWrite(CCoinsMap &mapCoins,
|
||||
const uint256 &hashBlock,
|
||||
const uint256 &hashAnchor,
|
||||
CAnchorsSproutMap &mapSproutAnchors,
|
||||
CNullifiersMap &mapSproutNullifiers,
|
||||
CNullifiersMap& mapSaplingNullifiers) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetStats(CCoinsStats &stats) const {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
double benchmark_connectblock_slow()
|
||||
{
|
||||
// Test for issue 2017-05-01.a
|
||||
SelectParams(CBaseChainParams::MAIN);
|
||||
CBlock block;
|
||||
FILE* fp = fopen((GetDataDir() / "benchmark/block-107134.dat").string().c_str(), "rb");
|
||||
if (!fp) throw new std::runtime_error("Failed to open block data file");
|
||||
CAutoFile blkFile(fp, SER_DISK, CLIENT_VERSION);
|
||||
blkFile >> block;
|
||||
blkFile.fclose();
|
||||
|
||||
// Fake its inputs
|
||||
auto hashPrev = uint256S("00000000159a41f468e22135942a567781c3f3dc7ad62257993eb3c69c3f95ef");
|
||||
FakeCoinsViewDB fakeDB("benchmark/block-107134-inputs", hashPrev);
|
||||
CCoinsViewCache view(&fakeDB);
|
||||
|
||||
// Fake the chain
|
||||
CBlockIndex index(block);
|
||||
index.SetHeight(107134);
|
||||
CBlockIndex indexPrev;
|
||||
indexPrev.phashBlock = &hashPrev;
|
||||
indexPrev.SetHeight(index.GetHeight() - 1);
|
||||
index.pprev = &indexPrev;
|
||||
mapBlockIndex.insert(std::make_pair(hashPrev, &indexPrev));
|
||||
|
||||
CValidationState state;
|
||||
struct timeval tv_start;
|
||||
timer_start(tv_start);
|
||||
assert(ConnectBlock(block, state, &index, view, true));
|
||||
auto duration = timer_stop(tv_start);
|
||||
|
||||
// Undo alterations to global state
|
||||
mapBlockIndex.erase(hashPrev);
|
||||
SelectParamsFromCommandLine();
|
||||
|
||||
return duration;
|
||||
}
|
||||
|
||||
extern UniValue getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
||||
extern UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user