Commit Graph

16807 Commits

Author SHA1 Message Date
Pieter Wuille eab53622f4 Add various insecure_rand wrappers for tests
(cherry picked from commit bitcoin/bitcoin@1119927df0)
2022-07-15 22:10:23 +00:00
Pieter Wuille f7a23218d1 Merge test_random.h into test_bitcoin.h
Zcash: Excludes changes to files we don't have, and removes the
duplicate definitions in `src/gtest/utils.h`.

(cherry picked from commit bitcoin/bitcoin@124d13a58c)
2022-07-15 22:10:23 +00:00
Pieter Wuille 0ef7ce2c61 scripted-diff: Rename cuckoo tests' local rand context
-BEGIN VERIFY SCRIPT-
sed -i 's/insecure_rand/local_rand_ctx/g' src/test/cuckoocache_tests.cpp
-END VERIFY SCRIPT-

(cherry picked from commit bitcoin/bitcoin@90620d66c9)
2022-07-15 22:10:23 +00:00
Pieter Wuille c9a9691a2f Add FastRandomContext::rand256() and ::randbytes()
FastRandomContext now provides all functionality that the real Rand* functions
provide.

(cherry picked from commit bitcoin/bitcoin@37e864eb9f)
2022-07-15 22:10:23 +00:00
Kris Nuttycombe 420f8dfe38
Merge pull request #6078 from nuttycom/bug/osx_missing_chrono_header
Add missing <chrono> header to util/time.h
2022-07-15 14:05:27 -06:00
Kris Nuttycombe 33d2dce183 Add missing <chrono> header to util/time.h 2022-07-15 12:54:37 -06:00
Kris Nuttycombe 95bbfd09aa Update feature_zip239 test to use persisted sprout chains. 2022-07-15 08:23:57 -06:00
Kris Nuttycombe b2fc56c24a Update sprout_sapling_migration test to use persisted sprout chains. 2022-07-15 08:23:57 -06:00
Kris Nuttycombe afea5c386d Add RPC test initialization using the persisted Sprout chains. 2022-07-15 08:23:57 -06:00
Kris Nuttycombe 532017e74e Remove the temporary test that was used for setup of the cached Sprout fixtures. 2022-07-15 08:23:57 -06:00
Kris Nuttycombe 5d44ce318e Add persistent Sprout test data.
This is in preparation for removing the ability to generate
Sprout outputs from z_shieldcoinbase. Once that is complete,
we will no longer be able to use `z_shieldcoinbase` for test
setup for uses of Sprout funds; instead, the persisted blockchain
state created in this commit will be used for tests that require
the use of Sprout funds.

This brings the test framework into line with how Sprout funds
are now used on mainnet and testnet; existing Sprout funds may
be spent, and Sprout change may be created, but no funds may
be transfered into the Sprout pool, since the activation of
ZIP 211.
2022-07-15 08:23:57 -06:00
Kris Nuttycombe 40df3d402e
Merge pull request #6042 from nuttycom/feature/clock_capability
Add a clock for testing with an offset from the system clock.
2022-07-15 08:23:23 -06:00
Kris Nuttycombe 0a4f3a3df0 Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-07-14 19:59:52 -06:00
str4d 0260b7e40b
Merge pull request #6073 from str4d/cache-proof-and-sig-validity
Cache Sapling and Orchard bundle validation
2022-07-15 01:34:27 +01:00
str4d 4689c59f3e
Improve bundlecache documentation
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-07-15 00:22:31 +01:00
Kris Nuttycombe e7922af588 Add a clock for testing with an offset from the system clock.
This change improves clock management for zcashd by ensuring
that all clock methods (obtaining seconds, milliseconds, and
microseconds since the epoch) agree under testing conditions
using `-mocktime`, and also adds a feature that allows tests
to specify an offset to the system clock; this is useful to
allow comprehensive testing of the "timejacking attack mitigation"
consensus rules.
2022-07-14 16:33:54 -06:00
Jack Grigg ebb37770a8 Move explicit instantiations for `BundleValidityCache` into `zcash/cache.cpp`
Also cleans them up a bit using the typedef.
2022-07-14 19:35:50 +00:00
str4d e75213ff65
Merge pull request #6069 from str4d/prune-witnesses-for-definitely-spent-notes
wallet: Prune witnesses for notes spent more than 100 blocks ago
2022-07-14 20:19:49 +01:00
Kris Nuttycombe aa6dbba5d2
Merge pull request #6074 from nuttycom/NO_zmq
Update documentation to refer to the actual two-hyphen `--nozmq` flag
2022-07-14 13:13:03 -06:00
Kris Nuttycombe d1dabd5a04
Merge pull request #6019 from zcash/add_docker_tromp_miner
Add environment variables for Equihash solver and number of threads to entrypoint.sh
2022-07-14 11:38:18 -06:00
Kris Nuttycombe 054334bbb4
Merge pull request #6029 from turrisxyz/Pinned-Dependencies-GitHub
chore: Set permissions for GitHub actions
2022-07-14 11:02:36 -06:00
Jack Grigg a5d2b8cd0c wallet: Improve documentation of `SproutNotData` and `SaplingNoteData` 2022-07-14 16:11:10 +00:00
Jack Grigg 847ce5375f wallet: Throw error if `ReadBlockFromDisk` fails 2022-07-14 16:06:13 +00:00
zancas a4a0fbb3c0 match the actual two hyphen flag 2022-07-14 07:44:17 -06:00
Kris Nuttycombe 4be354aad5
Merge pull request #6067 from daira/dont-rename-main-thread
Don't rename main thread
2022-07-14 07:37:23 -06:00
Kris Nuttycombe 51cc19d492
Merge pull request #5996 from adityapk00/gettx_version
Add tx version
2022-07-14 07:13:07 -06:00
Jack Grigg d5a271c7a4 Add bundle kind to `BundleValidityCache` initialization log message 2022-07-13 22:41:56 +00:00
Jack Grigg 087c85ec03 Cache Sapling and Orchard bundle validation
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.
2022-07-13 15:49:37 +00:00
Kris Nuttycombe 882935e35e
Merge pull request #5065 from str4d/merkle-backports
Bitcoin 0.12 Merkle tree PRs
2022-07-12 16:54:28 -06:00
Jack Grigg 12c3cfd339 wallet: Make `{Increment, Decrement}NoteWitnesses`-internal helpers static 2022-07-12 21:50:29 +00:00
Jack Grigg 82361aebc3 wallet: Prune witnesses for notes spent more than 100 blocks ago
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>
2022-07-12 21:50:29 +00:00
Kris Nuttycombe cc9449f905
Merge pull request #5066 from str4d/cuckoocache
Replace SigCache implementation with CuckooCache
2022-07-12 15:41:05 -06:00
str4d 4ae67b01f6
Merge pull request #6070 from str4d/wallet-useful-atmp-error
Return useful error message on ATMP failure
2022-07-12 02:59:31 +01:00
instagibbs 52ae7dbb90 Return useful error message on ATMP failure
Zcash: Excludes changes to QT wallet, includes our own uses of
CommitTransaction.

(cherry picked from commit bitcoin/bitcoin@169bdabe14)
2022-07-11 23:34:48 +00:00
Daira Hopwood c0bab39e4f This reverts part of 1f1810c37d in #5959.
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>
2022-07-09 11:27:03 +01:00
Jack Grigg 8e1fc6839d lint: Fix include guards 2022-07-08 22:24:26 +00:00
Pieter Wuille ef5a37138e Switch blocks to a constant-space Merkle root/branch algorithm.
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)
2022-07-08 22:24:23 +00:00
Pieter Wuille a8086dd41f Add merkle.{h,cpp}, generic merkle root/branch algorithm
(cherry picked from commit bitcoin/bitcoin@ee60e5625b)
2022-07-08 22:24:19 +00:00
Pieter Wuille 542fcfe69d Avoid duplicate CheckBlock checks
(cherry picked from commit bitcoin/bitcoin@3b33ec85ed)
2022-07-08 21:03:40 +00:00
Pieter Wuille 204d0c37ab Do not store Merkle branches in the wallet.
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)
2022-07-08 21:03:40 +00:00
Dan Raviv 7498c60341 Fix header guards using reserved identifiers
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.
2022-07-08 21:01:14 +00:00
Jeremy Rubin 8e053da3ee Deduplicate SignatureCacheHasher
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)
2022-07-08 21:01:14 +00:00
Jeremy Rubin 1fee91e4e7 Decrease testcase sizes in cuckoocache tests
(cherry picked from commit bitcoin/bitcoin@3f098cccf6)
2022-07-08 21:01:14 +00:00
Hennadii Stepanov 6c0861321e Use correct C++11 header for std::swap()
(cherry picked from commit bitcoin/bitcoin@98fbd1cdff)
2022-07-08 21:01:14 +00:00
Jon Layton d012fbf3fa doc: Doxygen-friendly CuckooCache comments
(cherry picked from commit bitcoin/bitcoin@7aad3b68e7)
2022-07-08 21:01:14 +00:00
practicalswift 43693df86d Use explicit casting in cuckoocache's compute_hashes(...) to clarify integer conversion
(cherry picked from commit bitcoin/bitcoin@9142dfea81)
2022-07-08 21:01:14 +00:00
Gregory Maxwell ee2f764630 Add an explanation of quickly hashing onto a non-power of two range.
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)
2022-07-08 21:01:14 +00:00
Pieter Wuille d0a12fdbde Allow non-power-of-2 signature cache sizes
(cherry picked from commit bitcoin/bitcoin@7482781347)
2022-07-08 21:01:14 +00:00
Jeremy Rubin 090ea700ac Add unit tests for the CuckooCache
SQUASHME: Update Tests for other SQUASHMEs

(cherry picked from commit bitcoin/bitcoin@67dac4e193)
2022-07-08 21:01:14 +00:00
Jeremy Rubin cebf89c7a7 Add CuckooCache implementation and replace the sigcache map_type with it
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)
2022-07-08 21:01:11 +00:00