This adds two new CuckooCaches in validation, each caching whether all
of a transaction bundle's proofs and signatures were valid.
Bundles which match the validation cache never have proofs or signatures
added to the batch validators. For blocks where all transactions have
been previously observed in the mempool, the final validation of the
batches should be a no-op.
Part of zcash/zcash#6049.
Once a note has been spent for at least 100 blocks, the wallet will not
see that spend be rolled back, as the node itself will reject rollbacks
of that magnitude. We can therefore stop tracking witnesses for these
notes, improving the performance of block scanning.
Part of zcash/zcash#6052.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
Leaving the main thread unnamed causes it to be displayed as the executable name (i.e. `zcashd`)
or command line in process monitoring tools. fixes#6066
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This switches the Merkle tree logic for blocks to one that runs in constant (small) space.
The old code is moved to tests, and a new test is added that for various combinations of
block sizes, transaction positions to compute a branch for, and mutations:
* Verifies that the old code and new code agree for the Merkle root.
* Verifies that the old code and new code agree for the Merkle branch.
* Verifies that the computed Merkle branch is valid.
* Verifies that mutations don't change the Merkle root.
* Verifies that mutations are correctly detected.
(cherry picked from commit bitcoin/bitcoin@eece63fa72)
Assume that when a wallet transaction has a valid block hash and transaction position
in it, the transaction is actually there. We're already trusting wallet data in a
much more fundamental way anyway.
To prevent backward compatibility issues, a new record is used for storing the
block locator in the wallet. Old wallets will see a wallet file synchronized up
to the genesis block, and rescan automatically.
(cherry picked from commit bitcoin/bitcoin@391dff16fe)
Identifiers beginning with an underscore followed immediately by an uppercase letter are reserved.
(cherry picked from commit bitcoin/bitcoin@bc70ab5dff)
Zcash: We merged the other half of this in zcash/zcash@36463d42c0.
This moves the SignatureCacheHasher to the sigcache header, out of the anonymous
namespace, so that the tests can import it.
(cherry picked from commit bitcoin/bitcoin@f9c88079df)
In Olaoluwa Osuntokun's recent protocol proposal they were using a
mod in an inner loop. I wanted to suggest a normative protocol
change to use the trick we use here, but to find an explanation
of it I had to dig up the PR on github. After I posted about it
several other developers commented that it was very interesting
and they were unaware of it.
I think ideally the code should be self documenting and help
educate other contributors about non-obvious techniques that
we use. So I've written a description of the technique with
citations for future reference.
(cherry picked from commit bitcoin/bitcoin@dd869c60ca)
SQUASHME: Change cuckoocache to only work for powers of two, to avoid mod operator
SQUASHME: Update Documentation and simplify logarithm logic
SQUASHME: OSX Build Errors
SQUASHME: minor Feedback from sipa + bluematt
SQUASHME: DOCONLY: Clarify a few comments.
(cherry picked from commit bitcoin/bitcoin@c9e69fbf39)
This particular assertion has a large fixed cost per block on current
mainnet (and has done since shortly after NU5 activation), but we
haven't figured out what is causing the performance hit. It is only a
consistency check, and commenting it out decreases single-account rescan
times by around 6% on a Ryzen 9 5950X.
Part of zcash/zcash#6052.
std::chrono::system_clock.time_since_epoch and time_t(0) are not guaranteed
to use the Unix epoch timestamp, but in practice they almost certainly will.
Any differing behavior will be assumed to be an error, unless certain
platforms prove to consistently deviate, at which point we'll cope with it
by adding offsets.
Do a quick runtime check to verify that
time_t(0) == std::chrono::system_clock's epoch time == unix epoch.
Co-authored-by: Anthony Towns <aj@erisian.com.au>
Zcash: The first commit of bitcoin/bitcoin#21110; we intend to handle
the changes made by the second commit of that PR in a separate fashion;
see zcash/zcash#6042.
(cherry picked from commit bitcoin/bitcoin@3c2e16be22)
This improves the portability of the codebase and fixes compilation
with mingw-w64 7.0+.
Co-authored-by: fanquake <fanquake@gmail.com>
Zcash: We do not yet have FormatISO8601DateTime or FormatISO8601Date,
so those parts of the backport are omitted.
(cherry-picked from commit bitcoin/bitcoin@a46484c8b3)
The only source of transactions for `CreateNewBlock` is the mempool, and
every transaction added to the mempool goes through `AcceptToMemoryPool`
which checks proofs and signatures.
We maintain the ability to enable these checks in `TestBlockValidity`
because it is also used in an (undocumented) `getblocktemplate` mode to
check a proposed block (minus PoW), where we cannot assume the
transactions are valid.
Co-authored-by: Kris Nuttycombe <kris@nutty.land>