Commit Graph

40 Commits

Author SHA1 Message Date
Kris Nuttycombe 1b2d994a39 zcashd release v5.3.3
Notable changes
 ===============
 
 This hotfix remediates memory exhaustion vulnerabilities that zcashd inherited
 as a fork of bitcoind. These bugs could allow an attacker to use peer-to-peer
 messages to fill the memory of a node, resulting in a crash.
 -----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEEX8Nd8pnYcf0pobEL9FXpuSAjoYsFAmP1CD8ACgkQ9FXpuSAj
 oYvGXQwAqaa1l5qC3VY/60jkH4xmWoSUEzeCOPUG7lYJrIEyzgXj8Ko0Cjr308jm
 ISXDDTOxKb2hfnCbeqbZqRyFbzGzG5L6AkjHAvmQMiZwx2JlbH2k+jd5fggOZSMv
 shL5KbxWN2YRftc8r+fDraJMbGULbKBWQooKaFyQmupT+bVsRf1Nh+lFIVG4FUwA
 oWZot36wB6Y99Y57wlyN2m22+j1glyk5mKv2ttXYbdwSRTFB5W5L1US6Z8uxXQPb
 Qa7sVO90QtzkHr+GPtMiTn513VuLFr+KArGn+qidU/PvblJI/vXuBf54g7JZw4Ot
 gkKziatgaN3pO30I4rTij78LCgKJZ/WImLE7nwTl/bG2Ki1WfyolNLjS+1pXpcPL
 xlXso5ioKlSIGhnlPouXwoxlaqTpDwRKLp0azNJl5hG/tXEHupToK2M61woi9LlP
 4RB+a75OptFi9NMp/Sx0T8zNRn7OB8iP+3BgRP0+mzcLC1AHfjJk/IRo9CQh5jRZ
 MMe98OrC
 =6QYn
 -----END PGP SIGNATURE-----

Merge tag 'v5.3.3' into hotfix-v5.4.2

zcashd release v5.3.3

Notable changes
===============

This hotfix remediates memory exhaustion vulnerabilities that zcashd inherited
as a fork of bitcoind. These bugs could allow an attacker to use peer-to-peer
messages to fill the memory of a node, resulting in a crash.
2023-03-13 06:18:00 -06:00
Greg Pfeil 2c48eddfa5
Remove `ResetRequestCount`
There is no longer any `mapRequestCount` to reset.

This also removes the `BlockFound` signal, as its only purpose was to call
`ResetRequestCount`.
2023-02-17 15:45:29 -07:00
Matt Corallo aa88e23f6b
Remove useless mapRequest tracking that just effects Qt display.
I thought we had removed this a long time ago, TBH, its really
confusing feedback to users that we display whether a tx was
broadcast to immediate neighbor nodes, given that has little
indication of whether the tx propagated very far.
2023-02-17 14:04:37 -07:00
Kris Nuttycombe 887b2688df Remove unused DEFAULT_BATCHSCANNERMEMLIMIT constant. 2023-01-26 12:33:55 -07:00
Kris Nuttycombe aab58d308f Bound wallet batch scanner size to 1000 blocks instead of 100 MiB
1000 blocks was selected as a balance between limiting the likely
maximum memory usage of the batch scanner, and avoiding
artificially restricting scanning throughput of small/fast blocks
due to the second-boundary lock synchronization point.

This also removes the `zcashd.wallet.batchscanner.usage.bytes` gague
value that was previously made available when `-prometheusport` was
specified.

Co-authored-by: Jack Grigg <jack@z.cash>
2023-01-26 12:26:31 -07:00
Kris Nuttycombe 3cec519ce4 scripted-diff: Update Zcash copyrights to 2023
-BEGIN VERIFY SCRIPT-
for party in "The Zcash developers" "The Bitcoin Core developers" "Bitcoin Developers"; do
  sed -i"" -e "s#Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? $party#Copyright (c) \1-2023 $party#" COPYING
  sed -i"" -e "s#\(.*\)\([0-9]\{4\}\)\(-[0-9]\{4\}\)\, $party#\1\2-2023, $party#" contrib/debian/copyright
done

sed -i"" -e "s/define(_COPYRIGHT_YEAR, [0-9]\{4\})/define(_COPYRIGHT_YEAR, 2023)/" configure.ac
sed -i"" -e "s/#define COPYRIGHT_YEAR [0-9]\{4\}/#define COPYRIGHT_YEAR 2023/" src/clientversion.h

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-2023 The Zcash developers#" {}
-END VERIFY SCRIPT-
2023-01-23 11:31:54 -07:00
Jack Grigg 0072ea2447 wallet: Set a memory limit of 100 MiB for batch scanning 2022-09-21 01:27:42 +00:00
Jack Grigg e88ea11055 wallet: Add dynamic memory usage tracking to `BatchScanner` 2022-09-21 01:27:42 +00:00
Daira Hopwood ee4a427519 Apply doc suggestions from code review 2022-07-22 19:34:50 +01:00
Jack Grigg 1caf6f70df wallet: Domain-separate batched txids with a "block tag"
Previously when a transaction was queried for batch trial decryption, we
identified it by its txid. This is sufficient to uniquely identify the
transaction within the wallet, but was _not_ sufficient to uniquely
identify it within a `ThreadNotifyWallets` loop. In particular, when a
reorg occurs, and the same transaction is present in blocks on both
sides of the reorg (or is reorged into the mempool and then conflicted
out):

- The first occurrence would batch the transaction's outputs and store a
  result receiver.
- The second occurrence would overwrite the first occurrence's result
  receiver with its own.
- The first occurrence would read the second's result receiver (which
  has identical results to the first batch), removing it from the
  `pending_results` map.
- The second occurrence would not find any receiver in the map, and
  would mark the transaction as having no decrypted results.

We fix this by annotating each batched transaction with the hash of the
block that triggered it being trial-decrypted: either the block being
disconnected, the block being connected, or the null hash to indicate
a new transaction in the mempool. This is sufficient to domain-separate
all possible sources of duplicate txids:

- If a transaction is moved to the mempool via a block disconnection, or
  from the mempool (either mined or conflicted) via a block connection,
  its txid will appear twice: once with the block in question's hash,
  and once with the null hash.
- If a transaction is present in both a disconnected and a connected
  block (mined on both sides of the fork), its txid will appear twice:
  once each with the two block's txids.

Both of the above rely on the assumption that block hashes are collision
resistant, which in turn relies on SHA-256 being collision resistant.
2022-07-22 15:54:25 +00:00
Jack Grigg 576d1b7134 wallet: Add `BatchScanner` interface to `CValidationInterface`
`CValidationInterface` listeners can either listen directly to
`CValidationInterface::SyncTransaction` as they currently do, or they
can listen to `CValidationInterface::InitBatchScanner` and then process
transactions via `BatchScanner::SyncTransaction`. The latter approach
allows listeners to perform trial decryption via whatever strategy is
most optimal for them.
2022-07-22 15:42:29 +00: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 6fbcba641d Fix a bug in initialization of the Orchard wallet after NU5 activation.
When initializing a new Orchard wallet after NU5 activation, it is
not valid to start from the empty note commitment tree; instead,
the note commitment tree needs to be initialized from the state of
the global Orchard Merkle frontier.

In addition, this change necessitates a change to how rewinds work,
such that in a rollback scenario with a newly initialized wallet
that does not have sufficient checkpoints to fully satisfy a requested
rewind, the rewind is allowed to proceed so long as it does not
invalidate any persisted witness data.
2022-04-04 13:05:42 -06:00
Kris Nuttycombe 4afc6a37c9 Refactor ChainTip to take a struct of Merkle trees instead of a pair.
This makes addition of the Orchard Merkle frontier easier in the future.
2022-04-04 12:04:34 -06:00
Jack Grigg 1c31a1c7d8 Use `std::optional` in `CValidationInterface::GetAddressForMining`
The initial value for the provided return value is now `std::nullopt`
instead of the default value of the `MinerAddress` variant. This makes
it easier to distinguish "no miner address was provided" from "invalid
miner address".
2022-03-03 15:57:40 +00:00
Jack Grigg d8d0918951 scripted-diff: Migrate from boost::optional to std::optional
-BEGIN VERIFY SCRIPT-
sed -i 's/boost::none/std::nullopt/g' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h* ./src/*/*/*.cpp ;
sed -i 's/boost::optional/std::optional/g' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h* ./src/*/*/*.cpp ;
sed -i 's/std::optional<\(.*\)&>/std::optional<std::reference_wrapper<\1>>/' ./src/*/*.h ./src/*/*.cpp ;
sed -i 's/is_initialized()/has_value()/' ./src/*.cpp ./src/*/*.cpp ;
sed -i ':a;N;$!ba;s/#include <boost\/optional.hpp>\n//' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
sed -i ':a;N;$!ba;s/#include "boost\/optional.hpp"\n//' ./src/*.h ;
-END VERIFY SCRIPT-
2020-12-16 22:59:35 +00:00
Jack Grigg 521eb81a95 Add <optional> header to files that will need it 2020-12-16 22:59:34 +00:00
Larry Ruane 81db0a2fc7 Flush witness data when consistent (part 2)
After CWallet::ChainTipAdded() updates the witness data, it
may flush it to disk (SetBestChain()); make sure the locator
part is consistent with the witnesses (height).
2020-09-05 07:21:11 -06:00
therealyingtong 1020254b6a Pass nHeight instead of pindex to AddToWalletIfInvolvingMe()
Co-authored by Jack Grigg (jack@electriccoin.co) and Sean Bowe (ewillbefull@gmail.com)
2020-07-08 12:53:03 +08:00
Homu 35bff6ac7c Auto merge of #4256 - str4d:zip-213-shielded-coinbase, r=daira
[NU3 Heartwood] Shielded Coinbase

Implements [ZIP 213](https://github.com/zcash/zips/pull/217).
2020-03-06 10:19:13 +00:00
Jack Grigg 99ec1ff971 Add support for Sapling addresses in -mineraddress 2020-02-28 13:59:53 +13:00
Sean Bowe faca79eb2f
Initialize ThreadNotifyWallets before additional blocks are imported.
Co-authored-by: Daira Hopwood <daira@electriccoin.co>
2020-02-26 11:20:12 -07:00
Jack Grigg 9771506acd
Move block-notifying logic into ThreadNotifyWallets 2019-12-18 15:06:54 -06:00
Jack Grigg a71a7341b9
Merge tree and boolean fields in ChainTip API
The trees were being unnecessarily fetched during DisconnectTip.
2019-12-18 15:06:54 -06:00
Jack Grigg 2c8dff00cc
ThreadNotifyRecentlyAdded -> ThreadNotifyWallets 2019-12-18 15:06:54 -06:00
Daira Hopwood bc909a7a7f Replace http with https: in links to the MIT license.
Also change MIT/X11 to just MIT, since no distinction was intended.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2019-07-18 15:26:01 +01:00
Jonas Schnelli 648d6bee65
miner: rename UpdateRequestCount signal to ResetRequestCount 2019-03-06 09:02:50 +13:00
Jonas Schnelli f4055fe158
add CReserveScript to allow modular script keeping/returning
- use one CReserveScript per mining thread
2019-03-06 09:02:50 +13:00
Jonas Schnelli b2993bc5d4
detach wallet from miner 2019-03-06 09:02:50 +13:00
Eirik Ogilvie-Wigley 4fc309f0f5 Rename Merkle Trees to include sprout or sapling 2018-08-01 10:31:09 -06:00
Eirik Ogilvie-Wigley f86ee1c252 Pass sapling merkle tree when incrementing witnesses 2018-07-25 20:47:41 -07:00
Jonas Schnelli 6a793d9c27
use CBlockIndex* insted of uint256 for UpdatedBlockTip signal
- removes mapBlockIndex find operation
- theoretically allows removing the cs_main lock during zqm notification while introducing a new file position lock
2017-02-08 22:10:42 +00:00
João Barbosa 7e6ec078fa
Add UpdatedBlockTip signal to CMainSignals and CValidationInterface 2017-02-08 22:10:42 +00:00
Jack Grigg de42390f90 Pass ZCIncrementalMerkleTree to wallet to prevent race conditions 2016-08-31 02:00:11 +12:00
Jack Grigg 769e031c1a Update cached incremental witnesses when the active block chain tip changes 2016-08-30 00:29:49 +12:00
Philip Kaufmann 0a7bcb7e55 fix IDE/compiler warning "extra ';'" in validationinterface.h 2015-05-14 01:02:00 -04:00
Wladimir J. van der Laan 446bb70fcd
Merge pull request #5940
0f5954c Regression test for ResendWalletTransactions (Gavin Andresen)
2015-03-30 14:28:09 +02:00
Michael Ford 63e4c9cd35 Fix clang compile warnings intriduced in #5681 2015-03-29 19:45:05 +08:00
Gavin Andresen 0f5954c434
Regression test for ResendWalletTransactions
Adds a regression test for the wallet's ResendWalletTransactions function, which uses a new, hidden RPC command "resendwallettransactions."

I refactored main's Broadcast signal so it is passed the best-block time, which let me remove a global variable shared between main.cpp and the wallet (nTimeBestReceived).

I also manually tested the "rebroadcast unconfirmed every half hour or so" functionality by:

1. Running bitcoind -connect=0.0.0.0:8333
2. Creating a couple of send-to-self transactions
3. Connect to a peer using -addnode
4. Waited a while, monitoring debug.log, until I see:
```2015-03-23 18:48:10 ResendWalletTransactions: rebroadcast 2 unconfirmed transactions```

One last change: don't bother putting ResendWalletTransactions messages in debug.log unless unconfirmed transactions were actually rebroadcast.
2015-03-24 15:29:20 -04:00
Jorge Timón 26c16d9de9 Includes: Refactor: Move CValidationInterface and CMainSignals out of main 2015-03-24 17:21:41 +01:00