Commit Graph

14958 Commits

Author SHA1 Message Date
João Barbosa 5b2f7a6ea7 [wallet] Make CWallet::ListCoins atomic
zcash: Not an actual locking fix; just eliminates unnecessary recursive
zcash: locking (which is a long-term goal).
zcash: cherry picked from commit 1beea7af92994dca83facb11bbef82b24b538400
zcash: https://github.com/bitcoin/bitcoin/pull/12333
2021-04-12 17:15:23 -06:00
Matt Corallo 829e801fd9 Add braces to meet code style on line-after-the-one-changed.
zcash: cherry picked from commit 02fc8863630a20e75230f8bc3ba1051c480ae560
zcash: https://github.com/bitcoin/bitcoin/pull/12368
2021-04-12 17:15:23 -06:00
Matt Corallo a4730c8a0e Hold mempool.cs for the duration of ATMP.
This resolves an issue where getrawmempool() can race mempool
notification signals. Intuitively we use mempool.cs as a "read
lock" on the mempool with cs_main being the write lock, so holding
the read lock intermittently while doing write operations is
somewhat strange.
This also avoids the introduction of cs_main in getrawmempool()
which reviewers objected to in the previous fix in #12273

zcash: cherry picked from commit 85aa8398f5d13c659299b81cdae377462b4f8316
zcash: https://github.com/bitcoin/bitcoin/pull/12368
2021-04-12 17:15:23 -06:00
Wladimir J. van der Laan cbd11135ff http: Remove numThreads and ThreadCounter
The HTTP worker thread counter, as well as the RAII object that was used
to maintain it, is unused now, so can be removed.

Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>

zcash: cherry picked from commit 11e01515fe0fbc7823d4111ad6e016a02c485a78
zcash: https://github.com/bitcoin/bitcoin/pull/12366
2021-04-12 17:15:23 -06:00
Wladimir J. van der Laan c733ded07d http: Remove WaitExit from WorkQueue
This function, which waits for all threads to exit, is no longer needed
now that threads are joined instead.

Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>

zcash: cherry picked from commit f94665466ed50e868c98b1a1c708ad5767727bb6
zcash: https://github.com/bitcoin/bitcoin/pull/12366
2021-04-12 17:15:22 -06:00
Wladimir J. van der Laan 0dcbfc9147 http: Join worker threads before deleting work queue
This prevents a potential race condition if control flow ends up in
`ShutdownHTTPServer` before the thread gets to `queue->Run()`,
deleting the work queue while workers are still going to use it.

Meant to fix #12362.

Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>

zcash: cherry picked from commit b1c2370dde9ade180c638e5d9a4797f085322b5b
zcash: https://github.com/bitcoin/bitcoin/pull/12366
2021-04-12 17:15:22 -06:00
João Barbosa 25b8cdce25 [rpc] Reduce scope of cs_main and cs_wallet locks in listtransactions
zcash: cherry picked from commit c409b1adac59329b78b8c48f131f8ca032988412
zcash: https://github.com/bitcoin/bitcoin/pull/12330
2021-04-12 17:15:22 -06:00
João Barbosa 3d29bb2132 wallet: Remove unnecessary mempool lock in ReacceptWalletTransactions
zcash: cherry picked from commit 5b252934362c2971e521df56c26ced56f07deb72
zcash: https://github.com/bitcoin/bitcoin/pull/11870
2021-04-12 17:15:22 -06:00
Matt Corallo 3145dce2d8 Remove redundant pwallet nullptr check
zcash: cherry picked from commit 89f03120a02690cff8399d77c979169355bf9cae
zcash: https://github.com/bitcoin/bitcoin/pull/10286
2021-04-12 17:15:22 -06:00
Matt Corallo 756a33ace4 Add ability to assert a lock is not held in DEBUG_LOCKORDER
zcash: cherry picked from commit 2b4b34503ff0ed44365d83a68ffed2736ea9cc51
zcash: https://github.com/bitcoin/bitcoin/pull/10286
2021-04-12 17:15:22 -06:00
practicalswift d8926263b7 Add missing cs_main locks when calling blockToJSON/blockheaderToJSON
zcash: cherry picked from commit a9b6ba0b7cd27a64307987afaab7f60bf9b4a15b
zcash: https://github.com/bitcoin/bitcoin/pull/11618
2021-04-12 17:15:22 -06:00
practicalswift 29eb55cc28 addrman: Add missing lock in Clear() (CAddrMan)
The variable vRandom is guarded by the mutex cs.

zcash: cherry picked from commit 3ab545d7f8e979e2cabeff6f5f6f1afe94a5c195
zcash: https://github.com/bitcoin/bitcoin/pull/11585
2021-04-12 17:15:22 -06:00
Cory Fields af7914242d rpc: further constrain the libevent workaround
The bug was introduced in 2.1.6-beta, versions before that don't need the
workaround.

zcash: currently, we build with libevent-2.1.12, so this fix is needed
zcash: cherry picked from commit 97932cd2689659addfbb58dc6148928b73af3bd0
zcash: https://github.com/bitcoin/bitcoin/pull/11593
2021-04-12 17:15:22 -06:00
Cory Fields 92d8f1d5cc rpc: work-around an upstream libevent bug
A rare race condition may trigger while awaiting the body of a message, see
upsteam commit 5ff8eb26371c4dc56f384b2de35bea2d87814779 for details.

This may fix some reported rpc hangs/crashes.

zcash: currently, we build with libevent-2.1.12, so this fix is needed
zcash: cherry picked from commit 6b58360f9b64eb0b680a662fdfd590e47f115f44
zcash: https://github.com/bitcoin/bitcoin/pull/11593
2021-04-12 17:15:22 -06:00
MeshCollider ea9bcc4774 Make fUseCrypto atomic
zcash: cherry picked from commit c626dcb50eed496462fd4ac3e05bf79164749ebe
zcash: https://github.com/bitcoin/bitcoin/pull/11107
2021-04-12 17:15:22 -06:00
Marko Bencun 2fd8809300 keystore GetKeys(): return result instead of writing to reference
Issue: #10905

By returning the result, a few useless lines can be removed.

Return-value-optimization means there should be no copy.

zcash: cherry picked from commit 5cb3da04b8882ca975b4e3d6c089c64bbaf67d0d
zcash: https://github.com/bitcoin/bitcoin/pull/10916
2021-04-12 17:15:22 -06:00
Russell Yanofsky e0a1266024 Acquire cs_main lock before cs_wallet during wallet initialization
CWallet::MarkConflicted may acquire the cs_main lock after
CWalletDB::LoadWallet acquires the cs_wallet lock during wallet initialization.
(CWalletDB::LoadWallet calls ReadKeyValue which calls CWallet::LoadToWallet
which calls CWallet::MarkConflicted). This is the opposite order that cs_main
and cs_wallet locks are acquired in the rest of the code, and so leads to
POTENTIAL DEADLOCK DETECTED errors if bitcoin is built with -DDEBUG_LOCKORDER.

This commit changes CWallet::LoadWallet (which calls CWalletDB::LoadWallet) to
acquire both locks in the standard order. It also fixes some tests that were
acquiring wallet and main locks out of order and failed with the new locking in
CWallet::LoadWallet.

Error was reported by Luke Dashjr <luke-jr@utopios.org> in
https://botbot.me/freenode/bitcoin-core-dev/msg/90244330/

zcash: cherry picked from commit de9a1db2ed14e0c75ffd82dc031f7ad30c56d195
zcash: https://github.com/bitcoin/bitcoin/pull/11126
2021-04-12 17:15:22 -06:00
Homu 3e53b40e25 Auto merge of #5055 - str4d:release-v4.4.0-rc1, r=str4d
Release v4.4.0-rc1
2021-04-09 06:43:08 +00:00
Jack Grigg 30f68da525 make-release.py: Updated release notes and changelog for 4.4.0-rc1. 2021-04-09 17:40:36 +12:00
Jack Grigg 253da68a2d make-release.py: Updated manpages for 4.4.0-rc1. 2021-04-09 17:40:36 +12:00
Jack Grigg f4d88aec20 make-release.py: Versioning changes for 4.4.0-rc1. 2021-04-09 17:32:49 +12:00
Homu 71f39c5013 Auto merge of #5047 - str4d:bump-dep-postpones, r=daira
Bump dependency postponements
2021-04-08 15:35:33 +00:00
Homu cbc475fd48 Auto merge of #4965 - str4d:secp256k1-update, r=daira
Update libsecp256k1 subtree

The first subtree merge brings us to the same commit as upstream (bitcoin/bitcoin#20257).

The second subtree merged brings us to current master, which includes most of our local changes.

After this, our remaining local changes are:
- 75f9f8f95b (the change to `secp256k1_scalar_get_b32`)
- e917cb614f (compile with C99)
2021-04-08 14:08:45 +00:00
Homu 76d3adc564 Auto merge of #5052 - daira:windows-ntdll-regression, r=daira
Link with ntdll library on Windows

This fixes a regression for builds targeting Windows introduced in #4947. It also includes a minor cleanup to fix a build warning.
closes #5051
2021-04-06 19:35:50 +00:00
Daira Hopwood 2a26a9726c Cleanup: get the definition of ENABLE_VIRTUAL_TERMINAL_PROCESSING from wincon.h.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-04-06 16:41:28 +01:00
Daira Hopwood f52260253c configure.ac: tidy up spacing.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-04-06 16:40:31 +01:00
Daira Hopwood 78ab48669d configure.ac: Add check for ntdll on Windows.
This fixes #5051, which is a regression caused by the dependency on the ntapi crate
(via mio, via tokio) added by #4947.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-04-06 16:39:45 +01:00
Jack Grigg da77a3db73 qa: Postpone Boost 1.75.0
https://github.com/zcash/zcash/issues/4945 remains unresolved.
2021-04-03 17:26:16 +13:00
Jack Grigg c0e146d3f4 qa: Postpone updates that require CMake in the build system
We still aren't committing to that dependency yet.
2021-04-03 17:26:16 +13:00
Jack Grigg d1c6647934 qa: Point univalue update checker at correct upstream
Bitcoin Core doesn't actually use tags for managing versions of their
forked dependencies, so we should separately rework this logic for all
of the subtree-managed dependencies. But this at least prevents false
positives.
2021-04-03 17:15:24 +13:00
Homu c96986452a Auto merge of #4988 - nuttycom:feature/3722-feature_flags, r=str4d
Add feature flagging infrastructure to consensus parameters.

Factors out feature flagging bits from #4480

Fixes #3722
2021-04-03 01:29:50 +00:00
Homu 49ffee3f20 Auto merge of #5012 - LarryRuane:upstream-locking-0.15, r=str4d
Bitcoin 0.15 locking PRs

These are locking changes from upstream (bitcoin core) release 0.15, oldest to newest (when merged to the master branch).

Each commit also includes a reference both to the PR and the upstream commit.

- bitcoin/bitcoin#9497
2021-04-02 23:59:56 +00:00
Kris Nuttycombe c4305fc6f3 CurrentTxVersionInfo should return SPROUT_MIN_CURRENT_VERSION pre-overwinter. 2021-04-02 17:04:02 -06:00
Jeremy Rubin a314cdba56 Add CheckQueue Tests
zcash: cherry picked from commit 96c7f2c3458950061b057fcd3daaf47b57e6bac7
zcash: https://github.com/bitcoin/bitcoin/pull/9497
2021-04-02 12:22:48 -06:00
Jeremy Rubin 8e67b36e86 Fix CCheckQueue IsIdle (potential) race condition and remove dangerous constructors.
zcash: cherry picked from commit e2073424fd5a185781750347fbfbb0c108ef66fd
zcash: https://github.com/bitcoin/bitcoin/pull/9497
2021-04-02 12:22:48 -06:00
Kris Nuttycombe a901b57d98 Address review comments. 2021-04-02 09:45:09 -06:00
Kris Nuttycombe 041d363232 Merge remote-tracking branch 'upstream/master' into feature/3722-feature_flags 2021-04-02 09:02:16 -06:00
Homu 80e66e7daa Auto merge of #5009 - LarryRuane:upstream-locking-0.14, r=str4d
Bitcoin 0.14 locking PRs

These are locking changes from upstream (bitcoin core) release 0.14, oldest to newest (when merged to the master branch).

Each commit also includes a reference both to the PR and the upstream commit.

- bitcoin/bitcoin#8472
- bitcoin/bitcoin#8606
  - Excludes a lock move because we don't have bitcoin/bitcoin#7840 which this move was partially-reverting.
- bitcoin/bitcoin#9230
  - Only first commit (we don't have `LogTimestampStr` anymore).
- bitcoin/bitcoin#9243
  - Only the sixth commit, excluding `IsArgSet` locking (we haven't pulled that function in yet).
- bitcoin/bitcoin#9626
  - The cherry-picked commit does not match the upstream at all, but the resulting lock is useful.
- bitcoin/bitcoin#9679
- bitcoin/bitcoin#9227
- bitcoin/bitcoin#9698
  - Excludes change to `CConnman::PushMessage` in second commit (which we don't have yet).
- bitcoin/bitcoin#9708
- bitcoin/bitcoin#9771
2021-04-02 01:03:27 +00:00
Russell Yanofsky 4fd7387cef Add missing cs_wallet lock that triggers new lock held assertion
A new AssertLockHeld(cs_wallet) call was added in commit a58370e
"Dedup nTimeFirstKey update logic" (part of PR #9108).

The lock held assertion will fail when loading prexisting wallets files from
before the #9108 merge that have watch-only keys.

zcash: cherry picked from commit 07afcd6379bb46ace5856f6a47a9188cf9aed2ea
zcash: https://github.com/bitcoin/bitcoin/pull/9771
2021-04-02 12:55:48 +13:00
Matt Corallo c9e2172eb6 Move CNode::addrLocal access behind locked accessors
zcash: cherry picked from commit db2dc7a58cb0a3df58188b748df8e0d04ba76f00
zcash: https://github.com/bitcoin/bitcoin/pull/9708
2021-04-02 12:55:48 +13:00
Matt Corallo 116deeec5b Move CNode::addrName accesses behind locked accessors
zcash: cherry picked from commit 036073bf87c07f8d69e39168dd93a52f1aafe85c
zcash: https://github.com/bitcoin/bitcoin/pull/9708
2021-04-02 12:55:48 +13:00
Matt Corallo e6eac19062 Make nTimeBestReceived atomic
zcash: cherry picked from commit d8f2b8a8c032b83a3bd90750e58abaeece7e34e7
zcash: https://github.com/bitcoin/bitcoin/pull/9708
2021-04-02 12:55:48 +13:00
Matt Corallo 78e0b89750 Move [clean|str]SubVer writes/copyStats into a lock
zcash: cherry picked from commit 22b4966a29501c4f3f2e970ac5008fbd91e665a9
zcash: https://github.com/bitcoin/bitcoin/pull/9708
2021-04-02 12:55:48 +13:00
Matt Corallo 676e7814f3 Make nServices atomic
zcash: cherry picked from commit 0f3187261519c7568ef4211ce12b9740a3c1200f
zcash: https://github.com/bitcoin/bitcoin/pull/9708
2021-04-02 12:55:48 +13:00
Matt Corallo 651c46a4b3 Make nStartingHeight atomic
zcash: cherry picked from commit 96f42d8a12871b8d5c4e31fd27d8135f97c6b3e0
zcash: https://github.com/bitcoin/bitcoin/pull/9708
2021-04-02 12:55:48 +13:00
Matt Corallo c2c43e39b2 Access fRelayTxes with cs_filter lock in copyStats
zcash: cherry picked from commit 512731bed0782f10092de35a960153b17ecc11eb
zcash: https://github.com/bitcoin/bitcoin/pull/9708
2021-04-02 12:55:48 +13:00
Matt Corallo 5d3586f707 Avoid copying CNodeStats to make helgrind OK with buggy std::string
zcash: cherry picked from commit ae683c1b1960b32134f5a5a29504691c91f39cf3
zcash: https://github.com/bitcoin/bitcoin/pull/9708
2021-04-01 14:29:40 -06:00
Matt Corallo 208a1a5867 Make nTimeConnected const in CNode
zcash: cherry picked from commit 644f1234e22626a7b5618a1dae60a8457a4063b1
zcash: https://github.com/bitcoin/bitcoin/pull/9708
2021-04-01 14:29:40 -06:00
Cory Fields 51fb0415c9 net: fix a few races. Credit @TheBlueMatt
These are (afaik) all long-standing races or concurrent accesses. Going
forward, we can clean these up so that they're not all individual atomic
accesses.

- Reintroduce cs_vRecv to guard receive-specific vars
- Lock vRecv/vSend for CNodeStats
- Make some vars atomic.
- Only set the connection time in CNode's constructor so that it doesn't change

zcash: cherry picked from commit 321d0fc6b6624c65508f8b9059418cb936f0bbbe
zcash: https://github.com/bitcoin/bitcoin/pull/9708
2021-04-01 14:29:40 -06:00
Cory Fields 9825103a10 net: add a lock around hSocket
zcash: cherry picked from commit 9a0b784deaab6b9fffcab227d928987b981d0572
zcash: https://github.com/bitcoin/bitcoin/pull/9698
2021-04-01 14:29:40 -06:00