Commit Graph

1436 Commits

Author SHA1 Message Date
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
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 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
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
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
Cory Fields a423c2af8c time: add runtime sanity check
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)
2022-07-07 14:00:03 -06:00
Kris Nuttycombe e03b964abf
Merge pull request #6043 from nuttycom/backport/14555-move_util_files_to_dir
scripted-diff: Move util files to separate directory.
2022-07-06 12:00:14 -06:00
Kris Nuttycombe 71b6a59ec3 scripted-diff: Move utiltest to src/util
-BEGIN VERIFY SCRIPT-
git mv src/utiltest.h src/util/test.h
git mv src/utiltest.cpp src/util/test.cpp
sed -i -e 's/"utiltest\.h"/"util\/test\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i -e 's/ZCASH_UTILTEST_H/ZCASH_UTIL_TEST_H/g' src/util/test.h
sed -i -e 's/utiltest\.\(h\|cpp\)/util\/test\.\1/g' src/Makefile.am
-END VERIFY SCRIPT-
2022-07-06 10:25:28 -06:00
Jack Grigg 90f13641b9 Use batch validation for Sapling proofs and signatures 2022-07-05 18:21:51 +00:00
Jim Posen 9a7e2c153d scripted-diff: Move util files to separate directory.
-BEGIN VERIFY SCRIPT-
mkdir -p src/util
git mv src/util.h src/util/system.h
git mv src/util.cpp src/util/system.cpp
git mv src/utilmoneystr.h src/util/moneystr.h
git mv src/utilmoneystr.cpp src/util/moneystr.cpp
git mv src/utilstrencodings.h src/util/strencodings.h
git mv src/utilstrencodings.cpp src/util/strencodings.cpp
git mv src/utiltime.h src/util/time.h
git mv src/utiltime.cpp src/util/time.cpp

sed -i -e 's/"util\.h"/"util\/system\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp')
git checkout HEAD -- src/secp256k1 # exclude secp256k1, which has its own "util.h"
sed -i -e 's/"utilmoneystr\.h"/"util\/moneystr\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i -e 's/"utilstrencodings\.h"/"util\/strencodings\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i -e 's/<utilstrencodings\.h>/<util\/strencodings\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i -e 's/"utiltime\.h"/"util\/time\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp')

sed -i -e 's/BITCOIN_UTIL_H/BITCOIN_UTIL_SYSTEM_H/g' src/util/system.h
sed -i -e 's/BITCOIN_UTILMONEYSTR_H/BITCOIN_UTIL_MONEYSTR_H/g' src/util/moneystr.h
sed -i -e 's/BITCOIN_UTILSTRENCODINGS_H/BITCOIN_UTIL_STRENCODINGS_H/g' src/util/strencodings.h
sed -i -e 's/BITCOIN_UTILTIME_H/BITCOIN_UTIL_TIME_H/g' src/util/time.h

sed -i -e 's/ util\.\(h\|cpp\)/ util\/system\.\1/g' src/Makefile.am
sed -i -e 's/utilmoneystr\.\(h\|cpp\)/util\/moneystr\.\1/g' src/Makefile.am
sed -i -e 's/utilstrencodings\.\(h\|cpp\)/util\/strencodings\.\1/g' src/Makefile.am
sed -i -e 's/utiltime\.\(h\|cpp\)/util\/time\.\1/g' src/Makefile.am

sed -i -e 's/src\/util\.cpp/src\/util\/system\.cpp/g' test/lint/lint-locale-dependence.sh
sed -i -e 's/src\/utilmoneystr\.cpp/src\/util\/moneystr\.cpp/g' test/lint/lint-locale-dependence.sh
sed -i -e 's/src\/utilstrencodings\.\(h\|cpp\)/src\/util\/strencodings\.\1/g' test/lint/lint-locale-dependence.sh
-END VERIFY SCRIPT-
2022-07-01 17:50:09 -06:00
Kris Nuttycombe 733289afa3 Revert "Merge pull request #6037 from nuttycom/feature/clock_capability"
This reverts commit 93ae72c17e, reversing
changes made to f3f1f81302.
2022-07-01 10:15:41 -06:00
Kris Nuttycombe 88401bc25e 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-01 13:51:22 +01:00
Jack Grigg eb9dd95f69 test: Load the proof verification keys in Boost tests
The change to use Orchard batch validation now requires the Orchard
verifying key to be available even if there are no items in the batch.
For simplicity, we now load all verifying keys in the Boost tests.
2022-07-01 01:24:15 +00:00
Jack Grigg df08281f25 Migrate BLAKE2b Rust FFI to `cxx` 2022-05-27 20:15:05 +00:00
Jack Grigg 54aeb2c408 Migrate Equihash Rust FFI to `cxx`
This integrates `cxxbridge` into the build system, adding its generated
source files to `libzcash`. We currently need to manually specify each
Rust file containing a bridge description.
2022-05-27 20:15:05 +00:00
Russell Yanofsky fcd0b28616 scripted-diff: Small locking rename
Call sync.h primitives "locks" and "mutexes" instead of "blocks" and "waitable
critical sections" to match current coding conventions and c++11 standard
names.

This PR does not rename the "CCriticalSection" class (though this could be done
as a followup) because it is used everywhere and would swamp the other changes
in this PR. Plain mutexes should mostly be preferred instead of recursive
mutexes in new code anyway.

-BEGIN VERIFY SCRIPT-
set -x
set -e
ren() { git grep -l $1 | xargs sed -i s/$1/$2/; }
ren CCriticalBlock           UniqueLock
ren CWaitableCriticalSection Mutex
ren CConditionVariable       std::condition_variable
ren cs_GenesisWait           g_genesis_wait_mutex
ren condvar_GenesisWait      g_genesis_wait_cv
perl -0777 -pi -e 's/.*typedef.*condition_variable.*\n\n?//g' src/sync.h
-END VERIFY SCRIPT-

(cherry picked from commit bitcoin/bitcoin@190bf62be1)
2022-05-14 01:25:08 +00:00
Russell Yanofsky 28adc47fcd Make LOCK, LOCK2, TRY_LOCK work with CWaitableCriticalSection
They should also work with any other mutex type which std::unique_lock
supports.

There is no change in behavior for current code that calls these macros with
CCriticalSection mutexes.

(cherry picked from commit bitcoin/bitcoin@1382913e61)
2022-05-14 01:25:08 +00:00
Russell Yanofsky 9ff8ae6419 Add unit test for DEBUG_LOCKORDER code
(cherry picked from commit bitcoin/bitcoin@41b88e9337)
2022-05-14 01:25:08 +00:00
practicalswift 85fdbf3af8 Remove unused code
Zcash: Excludes code that is still in use for us.

(cherry picked from commit bitcoin/bitcoin@8dc957ae06)
2022-05-14 01:25:08 +00:00
Pieter Wuille 084906c845 Use a signal to continue init after genesis activation
Zcash: We set the Sprout tree root on the genesis block's index file in
InitBlockIndex because we were implicitly relying on this occurring via
ActivateBestChain previously.

(cherry picked from commit bitcoin/bitcoin@0fd2a33648)
2022-05-14 01:25:08 +00:00
Kris Nuttycombe c545f64356 scripted-diff: Add 2021-2022 copyright headers for files added/modified in 2021
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM a960e896dd4c0b6d96db3d5ebbb1caa6c92a9f39..dfefab2f5587b873b02c4ed22ee3441d63f8a111 -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2021-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:34:50 -06:00
Kris Nuttycombe 15d1bb6ce9 scripted-diff: Add 2020-2022 copyright headers for files added/modified in 2020
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM 6a08c225674df23f1c7f214bcb94732dba688d39..a960e896dd4c0b6d96db3d5ebbb1caa6c92a9f39 -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2020-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:32:39 -06:00
Kris Nuttycombe 940dd0d426 scripted-diff: Add 2019-2022 copyright headers for files added/modified in 2019
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM 8df7a073ce13ec057b94b5a813bb5534cdfa6809..6a08c225674df23f1c7f214bcb94732dba688d39 -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2019-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:29:59 -06:00
Kris Nuttycombe 73fcef8035 scripted-diff: Add 2018-2022 copyright headers for files added/modified in 2018
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM b2a114a8c99947b66d1fbdc70278f13e7a415d2a..8df7a073ce13ec057b94b5a813bb5534cdfa6809 -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2018-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:28:03 -06:00
Kris Nuttycombe d9aeefc54a scripted-diff: Add 2017-2022 copyright headers for files added/modified in 2017
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM 94f427a211bb337200c29a1e19be0f5ad2f171b0..b2a114a8c99947b66d1fbdc70278f13e7a415d2a -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2017-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:25:51 -06:00
Kris Nuttycombe 28040f9ce4 scripted-diff: Add 2016-2022 copyright headers for files added/modified in 2016
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM bitcoin-v0.11.2..94f427a211bb337200c29a1e19be0f5ad2f171b0 -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2016-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:23:09 -06:00
Kris Nuttycombe 5ae1772d2b scripted-diff: Update Zcash copyrights to 2022
-BEGIN VERIFY SCRIPT-
git grep "// Copyright (c) .* The Zcash developers" \
  | awk -F ':' '{print $1}' \
  | xargs -I {} sed -i"" -e "s#// Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? The Zcash developers#// Copyright (c) \1-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 16:47:12 -06:00
Taylor Hornby f81054e86e
Merge pull request #5664 from superbaud/btests-to-gtests
Port all multithreaded tests from btest to gtest
2022-04-27 13:23:05 -06:00
sasha bd05733e6d Port anchors_test to gtest suite CoinsTests 2022-04-26 15:35:22 -07:00
sasha c055777839 Port anchors_flush_test to gtest suite CoinsTests 2022-04-26 15:35:22 -07:00
sasha b558046cd3 Port nullifiers_test to gtest suite CoinsTests 2022-04-26 15:35:22 -07:00
sasha 7a3dcff444 Port anchor_regression_test to gtest suite CoinsTests 2022-04-26 15:35:22 -07:00
sasha 8fa95217f6 Port anchor_pop_regression_test to gtest suite CoinsTests 2022-04-26 15:26:16 -07:00
sasha 6cd441accf Port nullifier_regression_test to gtest suite CoinsTests 2022-04-26 15:26:10 -07:00
sasha fbd6564152 Downgrade btest suite coins_test to BasicTestingSetup 2022-04-26 15:25:00 -07:00
sasha 84197d858f Port btest test_basic_joinsplit_verification to gtest suite Joinsplit
Also, we downgrade transaction_tests to BasicTestingSetup since there's
no proofs here any more
2022-04-26 15:24:20 -07:00
sasha a1e91a56ea btest parallelization work: tag #if'd out test suites 2022-04-26 07:35:01 -06:00
sasha 15e6e53738 Remove proof parameter loading from btests 2022-04-20 21:19:03 -07:00
sasha 04f1b299c6 remove JoinSplitTestingSetup from sighash_tests -- it doesn't need it 2022-04-20 21:18:25 -07:00
sasha cf4de9d03d
Merge pull request #5741 from zcash/nu5-consensus
NU5 consensus changes; merge requested by @nuttycom
2022-04-13 18:09:21 -07:00
Alfredo Garcia aef9f2b2ac
remove final dot from error msg 2022-04-09 11:54:21 -03:00
Alfredo Garcia 6e054687c2
fix grammar in message
Co-authored-by: Kris Nuttycombe <kris.nuttycombe@gmail.com>
2022-04-08 19:17:28 -03:00
Alfredo Garcia a4f563f2ab change error message 2022-04-08 13:24:11 -03:00
Jack Grigg f1cda64602 Apply `HaveShieldedRequirements` to coinbase transactions
Both transparent and shielded inputs have contextual checks that need to
be enforced in the consensus rules. For shielded inputs, these are that
the anchors in transactions correspond to real commitment tree states
(to ensure that the spent notes existed), and that their nullifiers are
not being double-spent.

When Sprout was first added to the codebase, we added input checks in
the same places that transparent inputs were checked; namely anywhere
`CCoinsViewCache::HaveInputs` is called. These all happened to be gated
on `!tx.IsCoinBase()`, which was fine because we did not allow Sprout
JoinSplits in coinbase transactions (enforced with a non-contextual
check).

When we added Sapling we also allowed coinbase outputs to Sapling
addresses (shielded coinbase). We updated `HaveShieldedRequirements` to
check Sapling anchors and nullifiers, but didn't change the consensus
code to call it on coinbase. This was fine because Sapling Spends and
Outputs are separate, and we did not allow Sapling Spends in coinbase
transactions (meaning that there were no anchors or nullifiers to
enforce the input rules on).

Orchard falls into an interesting middle-ground:
- We allowed coinbase outputs to Orchard addresses, to enable Sapling
  shielded coinbase users to migrate to Orchard.
- Orchard uses Actions, which are a hybrid of Sprout JoinSplits and
  Sapling Spends/Outputs. That is, an Orchard Action comprises a single
  spend and a single output.

To maintain the "no shielded spends in coinbase" rule, we added an
`enableSpends` flag to the Orchard circuit. We force it to be set to
`false` for coinbase, ensuring that all Orchard spends in a coinbase use
dummy (zero-valued) notes. However, this is insufficient: the coinbase
transaction will still contain an Orchard anchor and nullifiers, and
these need to be correctly constrained.

In particular, not constraining the Orchard nullifiers in a coinbase
transaction enables a Faerie Gold attack. We explicitly require that
Orchard nullifiers are unique, so that there is a unique input to the
nullifier derivation. Without the coinbase check, the following attack
is possible:
- An adversary creates an Orchard Action sending some amount of ZEC to a
  victim address, with a dummy spent note. The entire transaction can be
  fully-shielded by placing the real spent note in a separate Action.
- The adversary uses the exact same dummy note in a coinbase
  transaction, creating the exact same output note (same victim address
  and amount).
- The victim now has two notes with the same ZEC amount, but can only
  spend one of them because they have the same nullifier.

This commit fixes the consensus bug by calling `HaveShieldedRequirements`
outside of `!tx.IsCoinBase()` gates. To simplify its usage, there is now
a `Consensus::CheckTxShieldedInputs` function that handles the logging
and validation state updates. We also move shielded input checks from
`ContextualCheckInputs` to `ContextualCheckShieldedInputs`; these now
mirror each other in that they check contextual rules on transparent and
shielded inputs respectively, followed by checking signatures.
2022-04-04 16:57:55 +00:00
Jack Grigg 8b68d73802 test: Print all logged errors to stdout during gtests
This makes it easier to figure out test failures caused by errors on the
Rust side, for which we generally log the error and then return a simple
failure condition (`false` or `nullptr`) which obscures the error on the
C++ side.

We add similar logic to the Boost test framework, but commented out by
default because it results in very verbose test output.
2022-03-29 00:26:22 +00:00
Jack Grigg 9e9f58b26f Merge branch 'master' into unify-nu5-consensus-changes 2022-03-23 02:57:16 +00:00
Jack Grigg 77a971fbc1 Migrate to latest `zcash/librustzcash` revision
This includes:
- `orchard =0.1.0-beta.3` which includes the final circuit changes.
- The new NU5 consensus branch ID.
- Updated ZIP 244 test vectors (which use the NU5 consensus branch ID).
2022-03-23 02:05:06 +00:00
Kris Nuttycombe 80324bc653 Merge remote-tracking branch 'upstream/master' into feature/wallet_orchard-merge_master 2022-03-17 16:52:49 -06:00
Kris Nuttycombe 0c38ad9200 Return std::optional<CExtKey> from CExtKey::Master
Master key generation is fallible, but the type of master
key generation did not previously reflect that the generated
key might be invalid.
2022-03-11 18:47:01 -07:00
Jack Grigg 6a7213b5d5 Add Orchard spend support to the transaction builder
Closes zcash/zcash#5570.
2022-03-11 03:30:55 +00:00
therealyingtong 26b8ec5562 coins_tests: Update tests to include Orchard case.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2022-03-09 22:52:39 +08:00
therealyingtong 663f8d434a coins_tests.cpp: Add Orchard nullifier to TxWithNullifiers().
Closes zcash/zcash#5240

Co-authored-by: Jack Grigg <jack@electriccoin.co>
2022-03-09 22:20:46 +08:00
Jack Grigg 96d6ee0b8f Update ZIP 244 implementation
This brings in the changes that align the transparent parts of ZIP 244
with BIP 341.
2022-02-16 03:29:42 +00:00
Jack Grigg 067b3b3032 Update ZIP 244 test vectors
Source: c7f9463713/test-vectors/zcash/zip_0244.json
2022-02-15 02:42:14 +00:00
Jack Grigg 80f478e67e Make `PrecomputedTransactionData` a required argument of `SignatureHash`
The ZIP 244 changes mean that we're going to need to alter every
callsite to pass through all of the transparent `CTxOut`s being spent.
Given that we need to pass it over to Rust, it makes more sense to just
have `PrecomputedTransactionData` be the vehicle for conveying this data
across.
2022-02-15 02:42:14 +00:00
Jack Grigg 3acf7941d6 Move shielded signature checks out of `ContextualCheckTransaction`
The ZIP 244 changes mean that shielded signatures will now require
access to any transparent inputs of the transaction, so we need to
validate the shielded signatures around the same point during block
connection or `AcceptToMemoryPool` as when we validate transparent
signatures.
2022-02-15 02:40:15 +00:00
Kris Nuttycombe 67e871a40c Add test vectors for UFVK derivation
Also update test vectors for unified addresses.
2022-02-12 15:07:05 -07:00
Jack Grigg 8617622e0d wallet: Implement `z_getaddressforaccount`
Closes zcash/zcash#5180.
2022-01-18 19:43:27 +00:00
Kris Nuttycombe cc392c70a6 Merge branch 'master' into feature/wallet_unified_addresses 2022-01-12 16:54:12 -07:00
Kris Nuttycombe b305ad2892 Remove the `InvalidEncoding` type from key & address variants.
The presence of this variant results in a situation where more
of the code than necessary needs to be aware of and handle
decoding failures. This change moves all handling of decoding
failures to the point of decoding.
2022-01-06 13:44:45 -07:00
Kris Nuttycombe fe777c5624 Fix encoding order of unified addresses. 2022-01-05 18:30:06 -07:00
str4d 3acc68548e
Merge pull request #5300 from LarryRuane/feature/wallet_orchard
Feature/wallet orchard UA RPCs
2021-12-20 20:31:10 +00:00
Larry Ruane f139cdc4fe Add new and modify existing Orchard RPCs, non-functional
The new RPCs aren't functional, only have argument parsing and sample
outputs, guarded by experimental -orchardwallet flag.

These changes used the tickets linked from
https://github.com/zcash/zcash/issues/5056 as a guide.
2021-12-15 16:40:23 -07:00
Larry Ruane d0b85b69f3 add ParseArbitraryInt() for diversifier index 2021-12-14 14:42:08 -07:00
Kris Nuttycombe 8ae8ddd7d1 Add tests for ufvk roundtrip serialization. 2021-12-13 18:53:27 -07:00
Kris Nuttycombe 9202b127d0 Merge remote-tracking branch 'upstream/master' into feature/wallet_orchard 2021-11-23 18:38:07 -07:00
Kris Nuttycombe f49f4c73d8 Rename OrchardMerkleTree -> OrchardMerkleFrontier
Remove IncrementalSinsemillaTree; this will be replaced by
a more full-featured OrchardWallet type which embeds the
incremental merkle tree used in wallet operations.
2021-11-23 07:27:34 -07:00
Dimitris Apostolou e05c1ddf8a
Fix typos 2021-11-14 16:27:09 +02:00
Kris Nuttycombe a67fb00d0a Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-11-07 10:16:22 -07:00
Kris Nuttycombe b67e62d977 Address comments from code review. 2021-10-29 13:38:36 -06:00
Kris Nuttycombe 2885ae7643 Derive transparent keys from mnemonic seed. 2021-10-19 17:51:14 -06:00
Kris Nuttycombe 666d135e2e Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-10-19 11:48:02 -06:00
Kris Nuttycombe 290b2e4e39 Use the default UA-based Sapling address for the saplingmigration tool. 2021-10-19 11:48:02 -06:00
Kris Nuttycombe 83dee7e886 Adds basic unified spending key derivation.
Also, begin pruning Sapling key derivation down to the
minimal amount required to support the legacy Sapling
key derivation process.
2021-10-19 11:48:02 -06:00
Larry Ruane 92d36b5a43 Disable IBD for all boost tests
Disable IBD for all the boost unit tests, because that's the more common
(default) mode of operation. The full boost test suite passes with this
commit, both when run all together or run separately. Any future tests
that need IBD to be active can always call TestSetIBD(true).
2021-10-03 16:16:57 -06:00
Jack Grigg 6e90c84be7 Fix bugs in testnet Orchard circuit
The consensus branch ID is updated (as the NU5 consensus rules are
altered). The testnet NU5 activation height is also reset.
2021-09-28 22:56:37 +01:00
Jack Grigg 2aa9f766b2 Migrate to latest revisions of orchard and the zcash_* crates 2021-09-17 03:56:32 +01:00
Jack Grigg 91bcb3dfa5 lint: Add missing include guards 2021-08-24 16:06:53 +01:00
Homu 4e93c62368 Auto merge of #5266 - daira:zip339, r=daira
ZIP 339 support

Depends on https://github.com/zcash/librustzcash/pull/424 .

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-08-23 20:41:11 +00:00
Daira Hopwood ac54e56665 Update unified address test data to take account of HRPs in padding (https://github.com/zcash/librustzcash/pull/419).
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-08-19 21:07:53 +01:00
Pieter Wuille d1f6072841 Get rid of CTxMempool::lookup() entirely
(cherry picked from commit bitcoin/bitcoin@288d85ddf2)
2021-08-13 15:42:04 +01:00
Alex Morcos bd2c35a93f Add a score index to the mempool.
The score index is meant to represent the order of priority for being included in a block for miners.  Initially this is set to the transactions modified (by any feeDelta) fee rate.  Index improvements and unit tests by sdaftuar.

(cherry picked from commit f3fe83673e84ef4d20b3026faa397cad17212ff8)

Zcash: Also includes some small refactors from bitcoin/bitcoin#6654 which
we have not backported.
2021-08-10 05:09:51 +01:00
Alex Morcos dde99ca891 Store the total sig op count of a tx.
Store sum of legacy and P2SH sig op counts.  This is calculated in AcceptToMemory pool and storing it saves redoing the expensive calculation in block template creation.

(cherry picked from commit c49d5bc9e6c97c47c0bd78604b2c393a7e4af097)
2021-08-10 05:09:51 +01:00
Suhas Daftuar fc752f2c67 Reverse the sort on the mempool's feerate index
(cherry picked from commit 78b82f4a16d8aad15ef397b1a1cd075b2efc8c16)
2021-08-10 05:09:51 +01:00
Pieter Wuille 13d8f294ac Replace trickle nodes with per-node/message Poisson delays
We used to have a trickle node, a node which was chosen in each iteration of
the send loop that was privileged and allowed to send out queued up non-time
critical messages. Since the removal of the fixed sleeps in the network code,
this resulted in fast and attackable treatment of such broadcasts.

This pull request changes the 3 remaining trickle use cases by random delays:
* Local address broadcast (while also removing the the wiping of the seen filter)
* Address relay
* Inv relay (for transactions; blocks are always relayed immediately)

The code is based on older commits by Patrick Strateman.

(cherry picked from commit 5400ef6bcb9d243b2b21697775aa6491115420f3)
2021-08-04 17:12:25 +01:00
Jack Grigg 776e9c5a4b Add support for decoding and encoding Unified Addresses 2021-07-13 03:22:47 +01:00
Jack Grigg 9a5951aab1 test: Check for updated empty-tx reject messages in transaction tests 2021-07-01 13:05:26 +01:00
Kris Nuttycombe fd91f099f4 Rename tx.valueBalance -> tx.valueBalanceSapling 2021-07-01 12:41:25 +01:00
Kris Nuttycombe 53828a38ba Make CTransaction::nConsensusBranchId a std::optional 2021-07-01 12:41:25 +01:00
Jack Grigg d72f722915 test: Update CCoinsViewTest with changes to CCoinsView interface
I just LOVE how C++ didn't complain that the changes to the virtual
method APIs didn't cause any compilation errors for the tests...
2021-06-29 03:34:08 +01:00
Kris Nuttycombe 8fbc84842b Document source of Orchard merkle tree test data. 2021-06-28 16:40:11 -06:00
Kris Nuttycombe 13fd4c9a1c Add Orchard merkle tree anchor tests. 2021-06-23 16:06:30 -06:00
Jack Grigg bd4c0a8515 ZIP 244 hashBlockCommitments implementation
We will start storing two new hashes in the block index from v4.5.0:
- hashAuthDataRoot
- hashFinalOrchardRoot
2021-06-18 01:05:04 +01:00
Jack Grigg 4da2347e96 Rename hashLightClientRoot to hashBlockCommitments in block header 2021-06-18 01:05:04 +01:00
Ethan Heilman 9fcb2f3936 Fix typo adddrman to addrman as requested in #8070
(cherry picked from commit 2a8b3589b5a6c0863012329ddb40e7d901decf0e)
2021-06-15 23:35:39 +01:00
EthanHeilman 3c54231da6 Remove non-determinism which is breaking net_tests #8069
(cherry picked from commit f4119c6c988ea24a5218aa6bc67e57e47e051547)
2021-06-15 23:35:31 +01:00