Commit Graph

15242 Commits

Author SHA1 Message Date
Daira Hopwood 465c2492e7
More precise terminology: "lock free" -> "unlocked" 2021-08-05 14:19:51 +01:00
Pieter Wuille ad8abd68a1 Change mapRelay to store CTransactions
(cherry picked from commit 38c310299cfef419d42744362b90c1700b598953)
2021-08-04 17:12:36 +01:00
Suhas Daftuar 44787c0179 Use txid as key in mapAlreadyAskedFor
Previously we used the CInv that would be sent to the peer announcing the
transaction as the key, but using the txid instead allows us to decouple the
p2p layer from the application logic (which relies on this map to avoid
duplicate tx requests).

(cherry picked from commit 7e91f632c70ff1848a152f24ee67a06796803943)
2021-08-04 17:12:36 +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
Jonas Schnelli ae9768c8b7 fix locking issue with new mempool limiting
Current master crashes on OSX with an exception: "boost: mutex lock failed in pthread_mutex_lock: Invalid argument"

(cherry picked from commit 0d699fc821048ab9316b0004e6552c8f1dc5e5f4)

Zcash: Also adds the `clear` call that this was fixing. Upstream added it
in https://github.com/bitcoin/bitcoin/pull/6722 which we never backported
(instead implementing our own mempool limiting logic).
2021-08-04 17:12:25 +01:00
Homu 2c90f7ea9d Auto merge of #5247 - nuttycom:consensus/action_flag_consistency, r=str4d
Add check for consistency between nActionsOrchard and Orchard flags.

Fixes #5245
2021-08-04 10:48:33 +00:00
Homu b67ffbb958 Auto merge of #5262 - str4d:bump-deps-4.5.0, r=str4d
Update dependencies

We now build with Rust 1.54 and Clang / libc++ 12.
2021-07-31 01:15:52 +00:00
str4d bdaf3e1ab2 depends: Greatly simplify the Clang 12 patch
We can avoid the "%s" optimization with "%s%s" :D

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-30 19:53:18 +01:00
Jack Grigg 5bb339824d cargo fmt 2021-07-30 19:08:18 +01:00
Jack Grigg 73a33efa43 CI: Use Rust 1.54 for lints 2021-07-30 18:36:42 +01:00
Jack Grigg 5ace59b38f rust: metrics 0.17 2021-07-30 18:22:05 +01:00
Jack Grigg 6e2a5b3f92 rust: cargo update 2021-07-30 18:22:05 +01:00
Jack Grigg 18e39ff9f0 depends: Fix issue cross-compiling BDB to Windows with Clang 12 2021-07-30 18:22:05 +01:00
Jack Grigg d9bcc2d303 depends: Update utfcpp to 3.2.1 2021-07-30 18:22:05 +01:00
Jack Grigg 374f60b326 depends: Update Clang / libcxx to LLVM 12
This is the second release in a row where LLVM has cut a X.0.1 for
everything except Darwin, so I've adjusted its URLs and paths on the
assumption this will continue.
2021-07-30 18:22:05 +01:00
Jack Grigg 0a5e69ab67 depends: Update Rust to 1.54.0 2021-07-30 18:22:05 +01:00
Kris Nuttycombe 660686d412 Fix error strings to correctly reflect context. 2021-07-30 11:16:22 -06:00
Kris Nuttycombe 8a904c0a8b
Use DOS level 100 for noncontextual checks.
Co-authored-by: str4d <jack@electriccoin.co>
2021-07-30 11:14:28 -06:00
Jack Grigg 1eb848ada2 Postpone dependency updates we aren't doing in this release 2021-07-30 16:04:31 +01:00
Homu 82a50f6c53 Auto merge of #5252 - str4d:ua-encoding, r=str4d
Unified Address encoding and decoding

Closes zcash/zcash#5133.
2021-07-30 00:40:08 +00:00
str4d 037bfa32f3 Track lengths when copying receiver data from C++ to Rust
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-30 01:38:38 +01:00
Jack Grigg 635151bf75 Add constants for UA typecodes 2021-07-30 01:25:14 +01:00
Kris Nuttycombe f4fe590eea Make Sapling Spend and Ouput count, and Orchard Action count checks be noncontextual.
Sapling spend and output max element counts may be safely made
noncontextual because the existing transaction size limit checks
would be violated by transactions containing more than 2^16 such
elements.
2021-07-29 08:32:46 -06:00
Homu 81da4f92ab Auto merge of #5241 - nuttycom:consensus/check_orchard_root_bottom, r=daira
Consensus: Add check to ensure that the Orchard commitment tree is not overfull after AppendBundle.

Part of #5197.
2021-07-29 13:20:34 +00:00
Daira Hopwood ec4e9ae509
Improve error message when a block would overfill the Orchard commitment tree.
Co-authored-by: str4d <jack@electriccoin.co>
2021-07-29 14:17:35 +01:00
Jack Grigg 8e6927f901 Document why a nested call to ExtractMinerAddress is not recursive 2021-07-19 12:48:11 +01:00
str4d 5675a4eed4
Fix typo in method documentation
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-19 12:44:05 +01:00
Homu 5802be3427 Auto merge of #5254 - zcash:ci-lints, r=str4d
CI: Add workflow that runs lints
2021-07-16 21:29:23 +00:00
Jack Grigg 4026386cac CI: Add Rust lints 2021-07-14 23:11:02 +01:00
Jack Grigg b54b416d68 CI: Check scripted diffs 2021-07-14 22:58:05 +01:00
Jack Grigg 29280b9821 CI: Add workflow that runs general lints 2021-07-14 22:19:40 +01:00
Jack Grigg 612f250814 Pass network type through to UA address handling logic 2021-07-13 13:40:13 +01:00
Jack Grigg 776e9c5a4b Add support for decoding and encoding Unified Addresses 2021-07-13 03:22:47 +01:00
Jack Grigg 990bc46b2b Use a visitor for handling -mineraddress config option
This makes it easier to add UA support.
2021-07-13 03:21:54 +01:00
Jack Grigg 22ffee8da6 Use `libzcash::RawAddress` in `CWallet::GetFilteredNotes`
`getBalanceZaddr` is modified to take an optional `RawAddress` instead of
a string. This limits it to showing the balance of a single protocol
address, which is fine: `z_getbalance` is the only user of this function,
and we are deprecating that RPC method (replacing it with RPC methods that
can show more detailed information for UAs).

`CWallet::GetNullifiersForAddresses` and `CWallet::IsNote*Change` now use
`RawAddress` because they are generally fed the same addresses as
`GetFilteredNotes`, and in the context of specific notes we need to work
with protocol addresses.
2021-07-13 03:21:54 +01:00
Jack Grigg 6f1a54cd16 Introduce libzcash::RawAddress type
Currently, `libzcash::PaymentAddress` serves two purposes: it represents
the result of parsing a string encoding provided by a user, and it holds
the possible shielded protocol addresses that can be used in transaction
outputs. In order to add support for Unified Addresses, we split these
purposes across two separate types.

We also add two new visitors to enable converting between these types:

- `RecipientForPaymentAddress` returns the "preferred protocol address"
  that should be used in transaction outputs, or `std::nullopt` if the
  payment address encoding was invalid.

- `GetRawAddresses` returns all protocol addresses contained within the
  given payment address, or an empty set if the payment address encoding
  was invalid.

For the existing address encodings, the implementations of these are
trivial.
2021-07-13 03:21:54 +01:00
Homu 15041a34fa Auto merge of #5246 - nuttycom:consensus/total_orchard_merklecrh, r=nuttycom
Update Orchard commitment tree hashes to use total MerkleCRH^Orchard.

See zcash/zips#530
2021-07-09 16:49:07 +00:00
Kris Nuttycombe a4847132fa Apply suggestions from code review 2021-07-09 10:44:59 -06:00
Kris Nuttycombe e588d1d790 Update Orchard commitment tree hashes to use total MerkleCRH^Orchard. 2021-07-09 10:40:49 -06:00
Kris Nuttycombe dcbbf43d8b Ensure that the Orchard note commitment tree does not exceed its maximum size. 2021-07-06 10:57:30 -06:00
Kris Nuttycombe 76aafa0f5f Add check for consistency between nActionsOrchard and Orchard flags.
Fixes #5245
2021-07-06 10:40:47 -06:00
Homu c34162d6dd Auto merge of #5225 - LarryRuane:2021-06-v5-transaction, r=str4d
Implement v5 transaction consensus rules

Part of zcash/zcash#5196.
2021-07-01 12:37:17 +00:00
Jack Grigg e18da34468 miner: Set coinbase expiry height to block height from NU5 activation 2021-07-01 13:34:56 +01:00
Jack Grigg 0a78f4c6ec test: Fix OverwinterExpiryHeight test after ZIP 203 contextual changes 2021-07-01 13:17:08 +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 7a2be88768 ZIP 213: Add checks to support Orchard shielded coinbase outputs. 2021-07-01 12:42:37 +01:00
Jack Grigg 6bbe0906a8 ZIP 203: Enforce coinbase nExpiryHeight consensus rule from NU5 2021-07-01 12:42:37 +01:00
Kris Nuttycombe 6145cb8ae1 Prevent undefined behaviour in `CTransaction::GetValueOut()`
If `valueBalanceSapling` were `INT64_MIN`, the negation would be undefined
behaviour. Also, if `valueBalanceSapling` were a large-magnitude value
then `nValueOut += -valueBalanceSapling;` could overflow, which would be
undefined behaviour.

In practice neither of these cases can happen because `GetValueOut()` is
only called on non-contextually valid transactions, for which
`valueBalanceSapling` will have been checked to be in range.

`GetShieldedValueIn()` is similarly cleaned up for consistency.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-07-01 12:42:37 +01:00
Kris Nuttycombe b0b797b4e9 Add check that v5 transactions have empty Sprout joinsplits. 2021-07-01 12:41:25 +01:00
Kris Nuttycombe d882c68274 Retract partial Orchard test support.
Testing for Orchard transaction construction will be introduced
separately.
2021-07-01 12:41:25 +01:00