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
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
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
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
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
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
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
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
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)
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
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>
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.
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
(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).
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).
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)
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)
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)
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)
(cherry picked from commit b7b48c8bbdf7a90861610b035d8b0a247ef78c45)
Zcash: Excluding changes to code we haven't backported yet that cause
too many conflicts.
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)
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)
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)