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)
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
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
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
This removes a "race" between Interrupt() and Run(), though it
should not effect any of our supported platforms.
zcash: cherry picked from commit 7b2d96b634f9fd283480caf3bece56138d0587e3
zcash: https://github.com/bitcoin/bitcoin/pull/9679
This makes sure that cs_filter is never held while taking cs_main
or CNode::cs_vSend.
zcash: cherry picked from commit 144ed76ea0b38b7c21b224501964f8a2c65c4bb6
zcash: https://github.com/bitcoin/bitcoin/pull/8606
Delete spare mainnet Founders' Reward addresses that will never be used
These addresses were originally intended as fallbacks if an FR address was compromised.
There is no need to retain them in the code given that the FR has ended.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
native_rust: don't install Rust docs
This speeds up builds, especially native builds on macOS. fixes#5042
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
When -blocksonly is set to 1, it interacts with the -walletbroadcast
parameter and sets it to 0 if it has not been set already.This behavior
is not captured by the current documentation, which claims that -blocksonly
does not impact any wallet transactions.
(cherry picked from commit 621e86ee8d0102e2bf41f7656a368083b89b2f83)
Zcash: Excludes max-peer doc changes, since we don't have
block-relay-only peers yet.
Add metrics collection and a Prometheus exporter
This adds an FFI wrapper around the `metrics` crate, and exposes CPP macros for collecting metrics in the C++ codebase. With this, we can collect metrics from both C++ and Rust.
The following metrics are included in this PR:
- Chain metrics:
- (counter) `zcash.chain.verified.block.total`
- (gauge) `zcash.chain.verified.block.height`
- (histogram) `zcash.chain.verified.block.seconds`
- Value pool metrics:
- (gauge) `zcash.pool.notes.created[name]`
- (gauge) `zcash.pool.notes.spent[name]` (currently not measured)
- (gauge) `zcash.pool.notes.unspent[name]` (currently not measured)
- (gauge) `zcash.pool.value.zatoshis[name]`
- P2P network metrics:
- (gauge) `zcash.net.peers`
- (counter) `zcash.net.in.bytes.total`
- (counter) `zcash.net.in.bytes[command]`
- (counter) `zcash.net.in.messages[command]`
- (counter) `zcash.net.out.bytes.total`
- (counter) `zcash.net.out.bytes[command]`
- (counter) `zcash.net.out.messages[command]`
- Node metrics:
- (gauge) `zcash.mempool.size.transactions`
- (gauge) `zcash.mempool.size.bytes`
- (gauge) `zcash.mempool.usage.bytes`
- (informational) `zcashd.build.info`
Collection of metrics is conditional on enabling an exporter. This PR adds a Prometheus exporter that can be enabled with `-prometheusport=<port>`. Metrics names have `.` replaced by `_` for compatibility with Prometheus.
By default, metrics are only exposed to localhost. This can be expanded with `-metricsallowip=<ip>`.
RewindBlockIndex calls DisconnectTip in a way that can potentially cause
a Sprout tree to not exist (the rewind_index RPC test reliably triggers
this). We only need to access the tree during disconnection for metrics
purposes, and we will never encounter this rewind situation on either
mainnet or testnet, so if we can't access the Sprout tree we default to
zero.
notes.created and notes.spent can be collected for the transparent pool
as well as the shielded pools. notes.unspent can only be collected for
the transparent pool, by design.
- zcash.sync.block.downloaded.total is redundant, and can be replaced by
zcash.net.in.messages[command=block].
- zcash.sync.block.verified.total and zcash.chain.verified.block.total
are identical for us, because we verify blocks synchronously.
- Add zcash. prefix to common metrics.
- Use .total suffix for accumulating counters instead of .count.
- Group names where possible.
- Shorten names where possible (and still clear).
hyper 0.14.3 added an unstable C API, but the changes to enable it
require us to configure cargo with a linker for cross-compilation.
We'll need to figure this out eventually, but for now let's just
pin hyper to a version that doesn't require it.