Skip to content

Conversation

@Fuzzbawls
Copy link
Collaborator

This introduces the ability to do most of the heavy computation required for zPIV spends before actually initiating the spend. A new thread, ThreadPrecomputeSpends, is added which constantly runs in the background.

ThreadPrecomputeSpends' purpose is to monitor the wallet's zPIV mints and perform partial witness accumulations up to nHeight - 20 blocks from the chain's tip (to ensure that it only ever computes data that is at least 2 accumulator checkpoints deep), retaining the results in memory.

Additionally, a file based cache is introduced, precomputes.dat, which serves as a place to store any precomputed data between sessions, or when the in-memory cache size is exhausted. Swapping data between memory and disk file is done as needed, and periodic cache flushes to the disk are routine.

This also introduces 2 new runtime configuration options -precompute and precomputecachelength.

  • -precompute is a binary boolean option (1 or 0) that determines wither or not pre-computation should be activated at runtime (default value is to activate, 1).
  • -precomputecachelength is a numeric value between 500 and 2000 that tells the precompute thread how many blocks to include during each pass (default is 1000).

A new RPC command, clearspendcache, has been added that allows for the clearing/resetting of the precompute cache (both memory and disk). This command takes no additional arguments.

Finally, the "security level" option for spending zPIV has been completely removed, and all zPIV spends now spend at what was formerly "security level" 100. This change has been reflected in any RPC command that previously took a security level argument, as well as in the GUI's Privacy section for spending zPIV.

presstab and others added 30 commits March 22, 2019 16:05
Moves the spend precomputation process into it's own thread, instead of
being tied to the staking thread.

Loop currently has a 5000ms sleep at the end so as to not overconsume
locks.
Adds a new column to the zPIV control UI showing the mint's completed
precompute percentage.
Adds a new command line (conf) option `-precompute` to disable
precomputing. Default is to enable.
@Fuzzbawls Fuzzbawls added RPC Wallet Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes zPiv labels Mar 23, 2019
@Fuzzbawls Fuzzbawls added this to the 3.2.0 milestone Mar 23, 2019
@ghost ghost assigned Fuzzbawls Mar 23, 2019
@ghost ghost added the review label Mar 23, 2019
@Fuzzbawls Fuzzbawls removed the Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes label Mar 23, 2019
Copy link

@Warrows Warrows left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as intended as far as I can tell.

@Fuzzbawls Fuzzbawls requested a review from random-zebra March 24, 2019 22:45
@Fuzzbawls
Copy link
Collaborator Author

Added 2 additional commits, details are in the commit messages

Copy link

@blondfrogs blondfrogs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

Copy link

@Mrs-X Mrs-X left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK and about 70% utACK.

Will try to review the remaining code tomorrow, it's quite a lot of changes...

When a range of blocks has already been computed, use that existing data
 instead of erroring out. This is used in the zPoS pipeline where, after
  precomputation, the passed `pindexCheckpoint` is likely to be at a
  block height below the accumulator's tip/end.
Since security level has been removed, this status message needed to be
changed.

Also removed some stale unused code that was left over from when
security level was used.
New debug category "staking" added with some previous `LogPrintf`
messages recategorized to reduce log spam.

Also noted both "staking" and "precompute" in the init help message and
added them to the "pivx" umbrella category.
@Fuzzbawls Fuzzbawls force-pushed the precomputation-up-to-date-3 branch from 3850fd8 to 0772a68 Compare March 28, 2019 09:41
@Fuzzbawls Fuzzbawls merged commit 0772a68 into PIVX-Project:master Mar 28, 2019
Fuzzbawls added a commit that referenced this pull request Mar 28, 2019
0772a68 Reduce log spam (Fuzzbawls)
d367d5d Fix irrelevant receipt status message (Fuzzbawls)
417261d Don't error out when a range has already been computed (Fuzzbawls)
8082f27 fixup makefile.am (Fuzzbawls)
c224501 Fixup bad logprintf (Fuzzbawls)
e95e8ea Cleanup arbitrary sleep times in CreateCoinStake (Fuzzbawls)
8376665 Prevent lock spamming when no stakable inputs are present (Fuzzbawls)
4e5dc84 Better logging for CheckCoinSpend (Fuzzbawls)
b3bb83a Fixup the interface_rest functional test (Fuzzbawls)
4da1dca Disable precompute for functional tests (Fuzzbawls)
53dd8f5 Remove security level in `DoZpivSpend()` call (Fuzzbawls)
7491d6c Fix wrapped serial functional test (Fuzzbawls)
c503cd9 Fixup coinspend unit test header includes (Fuzzbawls)
580bec5 Fix assertion failure in mining/staking (Fuzzbawls)
4841189 Remove duplicate functions from rebase (Fuzzbawls)
092a027 re added LNZP removed files (furszy)
32e863c getaccumulatorwitness method fix (furszy)
6eaf457 precomputation-upstream conflicts solved (furszy)
f3f7a32 reorg + refactoring + conflicts (furszy)
803f46e Add global boolean, that stop precompute cache lock (blondfrogs)
8e0f565 Convert precompute cache into LRU cache (blondfrogs)
eca3fe8 Clear database cache with rpc call (blondfrogs)
135f19b Fix rebase conflicts from precomputing (warrows)
6e3df1f Update precompute cache (blondfrogs)
540120b Add Databasing of zpiv precomputes, they are not encrypted yet (blondfrogs)
6702fa5 Allow zPIV precomputing to be disabled (Fuzzbawls)
e8e6d48 Qt: Add precomputed percentage indicator column to zPIV control UI (Fuzzbawls)
07d590f Precompute zPIV spends in a dedicated thread (Fuzzbawls)
6e9d7af Fix RPC spendzerocoin (Fuzzbawls)
be02574 Make GetSerialHash return const again (Fuzzbawls)
39e80f5 more work on pre-computing (Fuzzbawls)
1f0b5b5 re-add zpivchain.h (fixes merge conflict error) (Fuzzbawls)
84b4f5f Add clearspendcache RPC command (Fuzzbawls)
f668d67 Remove security level from UI (Fuzzbawls)
e736149 don't hold cd_spendcache for the entire loop (Fuzzbawls)
6e2cf8d benchmark fixup (Fuzzbawls)
7c7fd45 don't duplicate function call (Fuzzbawls)
67b2e45 fully initialize member variables when setting the witness data (Fuzzbawls)
326f4e4 add benchmarking to zPIV spend inner functions (Fuzzbawls)
452a2b1 remove spam log output in stakeTargetHit() (Fuzzbawls)
cfa7852 set the accumulator start height when initializing the witness (Fuzzbawls)
92e3819 Include dependent headers in stakeinput.h (Fuzzbawls)
571b9fd ensure override is set for GetSerialHash() (Fuzzbawls)
a612119 prevent infinate loop in miner (Fuzzbawls)
924ede4 Remove security level from zerocoin spending. (presstab)
7adb7f2 More progress on caching spend data. (presstab)
fdb6c07 more progress (presstab)
928e6df In progress multi-input witness generation. (presstab)

Tree-SHA512: 3beffd57e005f4d6b82d8f1bf6ea09a09b9aa519dc1727ea6341c817970be2a17a84cfa838587492d8dd1fdcc382d184c9cdd28ff794be640f3bc12c241df3a9
@ghost ghost removed the review label Mar 28, 2019
random-zebra added a commit that referenced this pull request Jan 6, 2020
51cbb00 [Cleanup][Tests] Remove precompute option in default framework node conf (random-zebra)
7960c6e [Cleanup] remove fPrecompute option in SelectStakeCoins (random-zebra)
0187f0d [Cleanup][Tests] Remove crazy useful unittest created by "Tom" (random-zebra)
29a934c [Cleanup][Wallet] Remove zpiv spend cache from zpiv tracker (random-zebra)
bd3eebb [Cleanup][DB] Remove DB functions for zerocoin precomputing (random-zebra)
837f4e2 [Cleanup] Remove zPIV precomputing global variables. (random-zebra)
520284e [Cleanup][Qt] remove COLUMN_PRECOMPUTE from zpivcontroldialog (random-zebra)
2585532 [Cleanup] Init: remove precompute-related helps in strUsage (random-zebra)
fbcf37b [Cleanup] Init: remove "precompute" debug category (not used anywhere) (random-zebra)

Pull request description:

  Builds on top of #1234 .
  Reviewers should double check with #842 to ensure that the cleanup is complete

ACKs for top commit:
  Fuzzbawls:
    ACK 51cbb00
  furszy:
    Tested ACK 51cbb00.

Tree-SHA512: d496a314e3c9fa61efbc0e48d24806776ab43a8218941e04505aeafd278ad26c95fddaf0705cb0cda0d9b0e06a14bd3f20c18766b508931b8d3e2ac3789191c1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants