Commit Graph

15017 Commits

Author SHA1 Message Date
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
Anthony Towns 1dd379a6eb doc: clarify CRollingBloomFilter size estimate
(cherry picked from commit d9141a0002bb508b2e94e206a1bd28ef8f97ffde)
2021-04-02 16:06:43 +13:00
Sebastian Falbesoner 3e0ef7ffbb net: remove is{Empty,Full} flags from CBloomFilter, clarify CVE fix
(cherry picked from commit 1ad8ea2b73134bdd8d6b50704a019d47ad2191d8)

Zcash: Excluding change to src/test/fuzz/bloom_filter.cpp which we
don't have (we haven't backported upstream's fuzzing framework).
2021-04-02 16:06:41 +13:00
Sebastian Falbesoner 48fe1baf00 refactor: Remove unused methods CBloomFilter::reset()/clear()
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
(cherry picked from commit 69ffddc83e0f3e265bf6cf7ae31489ae629fe6be)

Zcash: Excluding change to src/test/fuzz/bloom_filter.cpp which we
don't have (we haven't backported upstream's fuzzing framework).
2021-04-02 16:04:55 +13:00
João Barbosa 07a5716458 refactor: Improve CRollingBloomFilter::reset by using std::fill
(cherry picked from commit df9e15f092c18a8047f09307576c2b77b9c8d01c)
2021-04-02 16:04:55 +13:00
João Barbosa 4dfc6384e9 bench: Add benchmark for CRollingBloomFilter::reset
(cherry picked from commit d2dbc7da26e1ca40200521c05a0b1ca75578acd2)
2021-04-02 16:04:55 +13:00
251 6eb04fefb7 Removes unsed `CBloomFilter` constructor.
This commit removes the `CBloomFilter::CBloomFilter(const unsigned int, const double, const unsigned int)` constructor, which became obsolete with 086ee67.

(cherry picked from commit 265bd50884ac1984c08f0e5916256d5f12e655f5)
2021-04-02 16:04:55 +13:00
Martin Ankerl 1571d65455 replace modulus with FastMod
Replaces the slow modulo operation with a much faster 32bit multiplication & shift. This works
because the hash should be uniformly distributed between 0 and 2^32-1. This speeds up the benchmark
by a factor of about 1.3:

RollingBloom, 5, 1500000, 3.73733, 4.97569e-07, 4.99002e-07, 4.98372e-07 # before
RollingBloom, 5, 1500000, 2.86842, 3.81630e-07, 3.83730e-07, 3.82473e-07 # FastMod

Be aware that this changes the position of the bits that are toggled, so this should probably
not be used for CBloomFilter which is serialized.

(cherry picked from commit 9aac9f90d5e56752cc6cbfac48063ad29a01143c)
2021-04-02 16:04:55 +13:00
ロハン ダル 36603f25a9 param variables made const
(cherry picked from commit 64aa36e20368fa16d4ff757d56dc2690ed0f48ba)
2021-04-02 16:04:55 +13:00
kobake 8b1fe83120 Fix msvc compiler error C4146 (unary minus operator applied to unsigned type)
On msvc14, int literal '-2147483648' is invalid, because '2147483648' is unsigned type and cant't apply minus operator to unsigned type.
To define the int literal correctly, use '-2147483647 - 1' formula that is also used to define INT_MIN in limits.h.

(cherry picked from commit 8e0720bdb9141b00b4c00893b8139904c67ddacf)
2021-04-02 16:04:55 +13:00
kobake 012dd8e740 Fix msvc compiler error C4146 (minus operator applied to unsigned type)
On msvc14, the compiler error C4146 (unary minus operator applied to unsigned type, result still unsigned) had been occured.
Use '0 - x' styled formula instead of '-x' so as to fix the error.

(cherry picked from commit 292112f87ef1780fee6164063a60af9ee7bf3f86)
2021-04-02 16:04:55 +13:00
Karl-Johan Alm 5d6fa863b3 Refactor: Remove using namespace <xxx> from src/*.cpp.
(cherry picked from commit b7b48c8bbdf7a90861610b035d8b0a247ef78c45)

Zcash: Excluding changes to code we haven't backported yet that cause
too many conflicts.
2021-04-02 16:04:55 +13:00
S. Matthew English c6591f2cd2 unification of Bloom filter representation
Output instances of "BloomFilter" changed to "Bloom filter", in accordance with Wikipedia standard notation:

https://en.wikipedia.org/wiki/Bloom_filter

also to sync with the majority of cases in the self-same file

(cherry picked from commit b7aa2902fd3c29487f585c264d8845899f4c1846)
2021-04-02 16:04:55 +13:00
Robert McLaughlin 5e81239e3e trivial: fix bloom filter init to isEmpty = true
Fixes newly initialized bloom filters being
constructed with isEmpty(false), which still
works but loses the possible speedup when
checking for key membership in an empty filter.

(cherry picked from commit cccf73db0483cc3945bf8389ce197df35e931e16)
2021-04-02 16:04:55 +13:00
Pavel Janík 48be374f68 Do not shadow variables
(cherry picked from commit 4731cab8fbff51a8178c85d572e2482040278616)

Zcash: Excluding changes to code we haven't backported.
2021-04-02 16:04:55 +13:00
Pieter Wuille 7d488feb12 More efficient bitsliced rolling Bloom filter
This patch changes the implementation from one that stores 16 2-bit integers
in one uint32_t's, to one that stores the first bit of 64 2-bit integers in
one uint64_t and the second bit in another. This allows for 450x faster
refreshing and 2.2x faster average speed.

(cherry picked from commit 1953c40aa9589a03035fd294f3ba3549374a4826)
2021-04-02 16:04:55 +13:00
Pieter Wuille 5064a933a0 Fix formatting of NOPs for generated script tests
(cherry picked from commit d03e46625ac95954bb9ecbc2cf73ffd8de6b8a13)
2021-04-02 16:04:55 +13:00
Pieter Wuille 9494acdb60 Switch to a more efficient rolling Bloom filter
For each 'bit' in the filter we really maintain 2 bits, which store either:
0: not set
1-3: set in generation N

After (nElements / 2) insertions, we switch to a new generation, and wipe
entries which already had the new generation number, effectively switching
from the last 1.5 * nElements set to the last 1.0 * nElements set.

This is 25% more space efficient than the previous implementation, and can
(at peak) store 1.5 times the requested amount of history (though only
1.0 times the requested history is guaranteed).

The existing unit tests should be sufficient.

(cherry picked from commit 086ee67d839b33bf475177f680fcc848a0625266)
2021-04-02 16:04:55 +13: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