Commit Graph

339 Commits

Author SHA1 Message Date
teor a91006afa7
Actually use `VerifyCheckpointError::CommitFinalized` (#1706)
Also:
* use `ServiceExt::oneshot` in the checkpoint verifier
* make some error messages more specific
* clean up the `std::future`/`futures` imports
2021-02-09 07:16:36 +10:00
teor 132c7fe4a5 Add a comment about a mempool request bug
Transaction verifier mempool requests should take the next block height,
because some consensus rules depend on the exact height.

See #1683.
2021-02-05 16:40:34 -05:00
Jane Lusby 0ac259430a Implement Async Batch verification API for groth16
This PR is the first step in getting a groth16 proving system fully
integrated with the rest of zebra. This PR implements the initial async
API, but none of the actual batching logic necessary for our eventual
verifier design.

Once the batch verification API from bellman has been implemented we
will need to swap out the "Batch" type defined in this crate with the
new `batch::Verifier` defined in bellman.
2021-02-05 14:52:48 -05:00
dependabot[bot] b3a3b8f7c7 build(deps): bump tracing from 0.1.22 to 0.1.23
Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.22 to 0.1.23.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.22...tracing-0.1.23)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-05 12:26:52 -05:00
teor bd03a51482
Remove an outdated comment in the script verifier (#1680) 2021-02-04 09:48:00 +10:00
teor 919dc0307f Rewrite the comment to be more explicit 2021-02-03 17:56:21 -05:00
teor 99fe588896 Document the impact of the redjubjub channel bound 2021-02-03 17:56:21 -05:00
Alfredo Garcia d7c40af2a8
Fix shutdown panics (#1637)
* add a shutdown flag in zebra_chain::shutdown
* fix network panic on shutdown
* fix checkpoint panic on shutdown
2021-02-03 19:03:28 +10:00
dependabot[bot] c52310ef91 build(deps): bump jubjub from 0.5.1 to 0.6.0
Bumps [jubjub](https://github.com/zkcrypto/jubjub) from 0.5.1 to 0.6.0.
- [Release notes](https://github.com/zkcrypto/jubjub/releases)
- [Changelog](https://github.com/zkcrypto/jubjub/blob/main/RELEASES.md)
- [Commits](https://github.com/zkcrypto/jubjub/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-30 01:54:06 -05:00
Deirdre Connolly 1b09538277
Bump versions for zebrad 1.0.0-alpha.1 (#1646)
* Bump versions where appropriate

Tested with cargo install --locked --path etc

* Remove fixed panics from 'Known Issues'

* Change to alpha release series in the README

Co-authored-by: teor <teor@riseup.net>
2021-01-27 20:31:39 -05:00
teor 494a5130c1 Fix clippy "unnecessary Vec::push" lints 2021-01-22 11:51:30 -08:00
teor 00c3ad5d8e Fix clippy "unnecessary Ok" lints 2021-01-22 11:51:30 -08:00
teor 258789ed9b Use the rustc unknown lints attribute
The clippy unknown lints attribute was deprecated in
nightly in rust-lang/rust#80524. The old lint name now produces a
warning.

Since we're using `allow(unknown_lints)` to suppress warnings, we need to
add the canonical name, so we can continue to build without warnings on
nightly.

But we also need to keep the old name, so we can continue to build
without warnings on stable.

And therefore, we also need to disable the "removed lints" warning,
otherwise we'll get warnings about the old name on nightly.

We'll need to keep this transitional clippy config until rustc 1.51 is
stable.
2021-01-19 11:02:20 -05:00
dependabot[bot] 75b510a9f6 build(deps): bump futures from 0.3.11 to 0.3.12
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.11 to 0.3.12.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.11...0.3.12)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-17 15:42:13 -05:00
dependabot[bot] 68e2942f83 build(deps): bump futures from 0.3.9 to 0.3.11
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.9 to 0.3.11.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.9...0.3.11)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-15 08:46:33 -05:00
teor 3699bbdae6 Add some additional sync correctness constraints
And adjust the sync restart delay as a consequence.
2021-01-13 20:46:25 -05:00
teor 730910cd99 Upgrade to tokio 0.3.6 from crates.io
And remove the tokio git dependency patch
2021-01-12 15:37:27 -05:00
dependabot[bot] 21e92f6392 build(deps): bump futures from 0.3.8 to 0.3.9
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.8 to 0.3.9.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.8...0.3.9)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-12 02:13:02 -05:00
Jane Lusby 15698245e1
Deduplicate metrics dependencies (#1561)
## Motivation

This PR is motivated by the regression identified in https://github.com/ZcashFoundation/zebra/issues/1349. That PR notes that the metrics stopped working for most of the crates other than `zebrad`.

## Solution

This PR resolves the regression by deduplicating the `metrics` crate dependency. During a recent change we upgraded the metrics version in `zebrad` and a couple other of our crates, but we never updated the dependencies in `zebra-state`, `zebra-consensus`, or `zebra-network`. This caused the metrics macros to attempt to retrieve the current metrics exporter through the wrong function. We would install the metrics exporter in `0.13`, but then attempt to look it up through the `0.12` crate, which contains a different instance of the metrics exporter static variable which is unset. Doing this causes the metrics macros to return `None` for the current exporter after which they just silently give up.

## Related Issues

closes https://github.com/ZcashFoundation/zebra/issues/1349

## Follow Up Work

I noticed we have quite a few duplicate dependencies in our tree. We might be able to save some compilation time by auditing those and deduplicating them as much as possible.

- https://github.com/ZcashFoundation/zebra/issues/1582
Co-authored-by: teor <teor@riseup.net>
2021-01-12 12:28:56 +10:00
dependabot[bot] f2a21ac67c build(deps): bump thiserror from 1.0.22 to 1.0.23
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.22 to 1.0.23.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.22...1.0.23)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-28 16:17:00 -05:00
Jane Lusby cfc339e8ea
export new precompute api in zebra-script (#1493)
* export new precompute api in zebra-script
* remove old API in favor of precompute API
* add multi use test cases and bump version
* update implementation to actually match henry's design
* Add safety comment for zebra-script

Co-authored-by: teor <teor@riseup.net>
2020-12-18 13:18:28 +10:00
Alfredo Garcia d725eeb4d6
Add documentation to zebra-utils and checkpoint generation (#1491)
* create readme for utils and checkpoints
* add link to checkpoint usage to book

Co-authored-by: Deirdre Connolly <durumcrustulum@gmail.com>
Co-authored-by: teor <teor@riseup.net>
2020-12-14 11:34:22 +10:00
Henry de Valence 0842eb2dab
zebra: move to 1.x-based versioning. (#1476)
Previously we set the crate versions to 3.x, so that the major version was
aligned with the NU version.  But we want to be able to make API changes
independently of the NU schedule.
2020-12-08 08:53:07 +10:00
teor 5b687f878a Remove unused dependencies found using cargo-udeps 2020-12-05 14:53:28 -05:00
teor b4a50fd99f
Downgrade tokio to 0.3.4 to avoid a time wheel panic (#1453)
See tokio-rs/tokio#2789 for details. We were seeing this panic during
normal operation, not just at shutdown.
2020-12-04 13:52:37 +10:00
dependabot[bot] 8c052cc39a build(deps): bump color-eyre from 0.5.9 to 0.5.10
Bumps [color-eyre](https://github.com/yaahc/color-eyre) from 0.5.9 to 0.5.10.
- [Release notes](https://github.com/yaahc/color-eyre/releases)
- [Changelog](https://github.com/yaahc/color-eyre/blob/v0.5.10/CHANGELOG.md)
- [Commits](https://github.com/yaahc/color-eyre/compare/v0.5.9...v0.5.10)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-03 10:55:16 -05:00
Jane Lusby d7bef1c155
bump color-eyre version to avoid a panic when printing spantraces (#1438) 2020-12-02 14:16:18 -08:00
teor 4109534c9b
Run `cargo fmt --all` (#1427) 2020-12-02 14:43:33 +10:00
teor 92eb92d1dd
Disable the nightly clippy unnecessary_wraps lint (#1403)
It seems to be a bit broken - some of our functions return `Result` for
consistency with similar functions. But the lint picks them up anyway.
2020-12-01 12:20:57 +10:00
Henry de Valence 4fd9203785 consensus: check Merkle root immediately after difficulty 2020-12-01 10:14:44 +10:00
Henry de Valence 4906a191f9 consensus: check for duplicate transactions in blocks
Change the Merkle root validation logic to also check that a block does not
contain duplicate transactions.  This check is redundant with later
double-spend checks, but is a useful defense-in-depth.
2020-12-01 10:14:44 +10:00
Henry de Valence 706f1fff81 consensus: tidy merkle validation in checkpointer
This moves it in with the existing `check_block` method and expands that
method's contract to cover general block validation checks.
2020-12-01 10:14:44 +10:00
Henry de Valence 7c08c0c315 consensus: check Merkle roots
As a side effect of computing Merkle roots, we build a list of
transaction hashes.  Instead of discarding these, add them to
PreparedBlock and FinalizedBlock so that they can be reused rather than
recomputed.

This commit adds Merkle root validation to:

1. the block verifier;
2. the checkpoint verifier.

In the first case, Bitcoin Merkle tree malleability has no effect,
because only a single Merkle tree in each malleablity set is valid (the
others have duplicate transactions).

In the second case, we need to check that the Merkle tree does not contain any
duplicate transactions.

Closes #1385
Closes #906
2020-12-01 10:14:44 +10:00
teor 440e183d32
Decrease the UTXO request timeout (#1407)
UTXO requests during transaction input verification can time out because:

1. The block that creates the UTXO is queued for download or verify, but
   it hasn't been committed yet. The creating block might spend UTXOs
   that come from other recent blocks, so UTXO verification can depend on
   a (non-contiguous) sequence of block verifications.

   In this case, Zebra should wait for additional block download and
   verify tasks to complete.

2. The block that creates the UTXO isn't queued for download. This can
   happen because the block is gossiped block that's much higher than the
   current tip, or because a peer sent the syncer a bad list of block
   hashes.

   In this case, Zebra should discard the timed out block, and restart
   the sync.

We need to choose a timeout that balances these two cases, so we time
out after 180 seconds.

Assuming Zebra can download at least 1 MB per second, 180 seconds is
enough time to download a few hundred blocks. So Zebra should be able to
download and verify the next block before the UTXOs that it creates time
out. (Since Zebra has already verified all the blocks before the next
block, its UTXO requests should return immediately.)

Even if some peers time out downloads, a block can only be pending
download for 80 seconds (4 retries * 20 second timeout) before the
download fails. So the UTXO timeout doesn't need to be much larger than
this overall download timeout - because the download timeout will happen
first on slow networks.

Alternately, if the download for the creating block was never queued,
Zebra should timeout as soon as possible - so it can restart the sync
and download the creating block.

As a side-effect, a lower UTXO timeout also makes it slightly easier to
debug UTXO issues, because unsatisfiable queries fail faster.
2020-12-01 10:12:25 +10:00
Henry de Valence 5e48acf3a4
consensus: add timeout to UTXO queries (#1391)
The state service API says explicitly that AwaitUTXO requests should be coupled
with a timeout layer. I didn't add this when I was testing and fixing the UTXO
lookup code (#1348, #1358) because causing zebrad to hang on a failed
dependency was useful for identifying cases where the code wasn't useful (and
then inspecting execution traces).

As a side effect, this ticket resolves most of the hangs in #1389, because
far-future gossiped blocks will have their UTXO lookups time out, though we
may wish to do other work as part of debugging the combined sync+gossip logic.
2020-11-27 09:55:37 +10:00
Deirdre Connolly 2a21c86b91 I before E except after C (or uh, not-english) 2020-11-24 22:23:57 -05:00
Henry de Valence b9347e01e4 consensus: ignore sighash-derived checks until #1377 2020-11-24 16:28:22 -08:00
Henry de Valence f798aef843 consensus: increase buffer for batch redjubjub results 2020-11-25 08:53:07 +10:00
Henry de Valence 61b3286085 consensus: add NU plumbing to block,tx,script verifiers
Closes #1367 by propagating the network upgrade through the service
requests.
2020-11-25 08:53:07 +10:00
dependabot[bot] e832f70c2c build(deps): bump tracing from 0.1.21 to 0.1.22
Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.21 to 0.1.22.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.21...tracing-0.1.22)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-24 10:55:53 -05:00
teor 133ebd078a Remove a post-Canopy panic in funding stream block subsidy validation
Funding stream block subsidy validation will be implemented as part of
block subsidy validation in #801.
2020-11-24 10:01:24 -05:00
Henry de Valence f1155297a3
consensus: temporarily skip scripts on big transactions (#1360)
Temporary workaround for #1350 until that issue is properly fixed.
2020-11-24 19:31:03 +10:00
teor 2d60c00fb0
Avoid a panic when downcasting to redjubjub::Error fails (#1363)
Instead, format the original error as a string, to provide better
diagnostics.

Temporary fix for #1357, the permanent fix ticket is #1186.
2020-11-24 16:46:02 +10:00
Henry de Valence 342eb166ff state: track UTXO provenance
This commit changes the state system and database format to track the
provenance of UTXOs, in addition to the outputs themselves.
Specifically, it tracks the following additional metadata:

- the height at which the UTXO was created;
- whether or not the UTXO was created from a coinbase transaction or
  not.

This metadata will allow us to:

- check the coinbase maturity consensus rule;
- check the coinbase inputs => no transparent outputs rule;
- implement lookup of transactions by utxo (using the height to find the
  block and then scanning the block) for a future RPC mechanism.

Closes #1342
2020-11-23 22:18:43 -08:00
Henry de Valence e0817d1747 state: introduce PreparedBlock, FinalizedBlock
This change introduces two new types:

- `PreparedBlock`, representing a block which has undergone semantic
  validation and has been prepared for contextual validation;
- `FinalizedBlock`, representing a block which is ready to be finalized
  immediately;

and changes the `Request::CommitBlock`,`Request::CommitFinalizedBlock`
variants to use these types instead of their previous fields.

This change solves the problem of passing data between semantic
validation and contextual validation, and cleans up the state code by
allowing it to pass around a bundle of data.  Previously, the state code
just passed around an `Arc<Block>`, which forced it to needlessly
recompute block hashes and other data, and was incompatible with the
already-known but not-yet-implemented data transfer requirements, namely
passing in the Sprout and Sapling anchors computed during contextual
validation.

This commit propagates the `PreparedBlock` and `FinalizedBlock` types
through the state code but only uses their data opportunistically, e.g.,
changing .hash() computations to use the precomputed hash.  In the
future, these structures can be extended to pass data through the
verification pipeline for reuse as appropriate.  For instance, these
changes allow the sprout and sapling anchors to be propagated through
the state.
2020-11-23 14:16:39 +10:00
Henry de Valence e4f38582fd consensus: add remaining checks trace counter to tx verifier 2020-11-23 14:16:39 +10:00
Henry de Valence a2a70e1fc1 consensus: fix same-block utxo lookups
The UTXO query system assumes that a transaction will only request
information about UTXOs created in prior blocks.  But transactions are
allowed to spend UTXOs created by prior transactions in the same block.

This doesn't fit with the existing query model, so instead of trying to
change it, allow the script verifier to take an additional set of known
UTXOs, and propagate this set from the block.
2020-11-23 14:16:39 +10:00
Henry de Valence f0810b028d state,consensus,sync: shorten span lengths
These changes help reduce the size of the resulting spans, making the
output more compact.  Together they save about 30-40 characters.
2020-11-23 14:16:39 +10:00
Henry de Valence aa45bf2b58 consensus: add traces to block verifier 2020-11-23 14:16:39 +10:00
teor 196dc6369c Delete outdated transaction comments 2020-11-22 23:11:00 -05:00
Henry de Valence 2eceff421f consensus: remove incorrect check
This consensus rule is supposed to apply to transactions whose
transparent inputs are the *outputs* of previous coinbase
transactions, not to transactions with coinbase inputs.  Because that
logic is different enough from this logic, and requires different data
flow, it's cleaner to just remove this check for now.
2020-11-21 14:09:15 -05:00
Henry de Valence ace1103462 consensus: fix bug in tx input/output presence check
Making this check's match statement exhaustive revealed a bug similar to
the previous commit.  The logic in the spec is written in terms of
numbers, but our data is internally represented in terms of enums
(ADTs).  This kind of cross-representation rule translation is a bug
surface, which we can avoid by converting to counts and summing up.  (We
should use one style at a time).
2020-11-21 14:09:15 -05:00
Henry de Valence 96ee32e5d2 consensus: fix bug in coinbase joinsplit/spend check
This function caused spurious "WrongVersion" errors, because the match
pattern in the first arm was non-exhaustive, but the fallthrough match
arm was present and assumed it would only be reached if the version was
incorrect.

This commit cleans up the implemenation, splits out the error variants,
and renames the check to be more precise.

To avoid this kind of bug in the future, two guidelines are useful:

1. Avoid fallthrough cases that circumvent non-exhaustive match checks;
2. Avoid nested conditionals, preferring a "straight-line" sequence of
   match arm => result pairs rather than nested matches or matches with
   conditionals inside.
2020-11-21 14:09:15 -05:00
Henry de Valence b116cfcd76 consensus: add debug event on wrong version check
Adding this check reveals that the WrongVersion errors aren't coming
from the correct WrongVersion check.
2020-11-21 14:09:15 -05:00
Henry de Valence d1ee7f263a consensus: add debug span to TransactionVerifier 2020-11-21 14:09:15 -05:00
Henry de Valence 2e4f4d8e87 consensus: fix span handling in BlockVerifier
The BlockVerifier constructed a tracing span and manually entered it
inside of an async block.  Manually entering spans inside async blocks
can cause problems where the span might not be entered and exited
correctly as the resulting future is polled.  Instead, using the
.instrument creates a wrapper future that handles the bookkeeping.

I changed the span name and contents to be consistent with the spans in
the checkpoint verifier.
2020-11-21 14:09:15 -05:00
Deirdre Connolly 558661a531 Remove test attributes and allow(dead_code) for test code that tests currently unimplemented functionality 2020-11-21 05:40:25 -05:00
Henry de Valence 04acc9da6c consensus: instrument script verification 2020-11-20 17:38:21 -05:00
Henry de Valence add94c1c45 deps: move to tokio 0.3, tower 0.4
This change is mostly mechanical, with the exception of the changes to the
`tower-batch` middleware.  This middleware was adapted from `tower::buffer`,
and the `tower::buffer` code was changed to implement its own bounded queue,
because Tokio 0.3 removed the `mpsc::Sender::poll_send` method.  See

ddc64e8d4d

for more context on the Tower changes.  To match Tower as closely as possible
in order to be able to upstream `tower-batch`, those changes are copied from
`tower::Buffer` to `tower-batch`.
2020-11-20 10:08:16 -08:00
Henry de Valence aa8d95bd23 consensus: improve checkpoint request replacement diagnostics 2020-11-17 14:56:27 -08:00
Henry de Valence a3ab589d89 consensus,state: document cancellation contracts for services
This change explicitly documents cancellation contracts for our Tower services,
and tries to correct a bug in the implementation of the CheckpointVerifier,
which duplicates information from the state service but did not ensure that it
would be kept in sync.
2020-11-17 14:56:27 -08:00
Henry de Valence d5d17a9a71 consensus: remove incorrect comment
The ZcashDeserialize implementation for Block doesn't check that blocks
have a coinbase height.
2020-11-17 14:56:27 -08:00
dependabot[bot] 8c5f6d0177 build(deps): bump once_cell from 1.5.1 to 1.5.2
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.5.1 to 1.5.2.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.5.1...v1.5.2)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-13 14:48:11 -05:00
teor af4797130b
Replace Target<block::Height> with TargetHeight (#1289)
We don't use this generic, so let's just remove it.
2020-11-12 16:11:25 -08:00
teor 96b7572bb5 Make the checkpoint metrics more accurate 2020-11-13 09:41:14 +10:00
teor 76a9f5b8c4 Refactor block target spacing into NetworkUpgrade methods
And add a method for the minimum difficulty time gap threshold.
2020-11-12 12:30:54 +10:00
teor 405c0644f9 Add a comment explaining the issues in ZIPs 205 and 208
And add the network to the difficulty filter error.
2020-11-12 12:30:54 +10:00
Alfredo Garcia 128643d81e
Call `zebra_test::init` where needed. (#1227)
* Add missing `zebra_test::init()` to zebra-chain
* Add missing `zebra_test::init()` to zebra-consensus
* Add missing `zebra_test::init()` to zebra-network
* Add missing `zebra_test::init()` to zebra-state
* Add missing `zebra_test::init()` to zebra-test
* Add missing `zebra_test::init()` to zebrad
2020-11-10 10:29:25 +10:00
teor f90a749910
Clarify CheckpointVerifier errors (#1260)
And make an unreachable error into a panic.
2020-11-06 11:07:30 -08:00
dependabot[bot] 1e3cf6dc5c build(deps): bump tracing-subscriber from 0.2.14 to 0.2.15
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.2.14 to 0.2.15.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.2.14...tracing-subscriber-0.2.15)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-04 20:37:40 -05:00
dependabot[bot] e87340594a build(deps): bump thiserror from 1.0.21 to 1.0.22
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.21 to 1.0.22.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.21...1.0.22)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-04 19:28:42 -05:00
teor 1c31225aac
Implement Expanded to Compact Difficulty Conversion (#1196)
* Implement Expanded to Compact Difficulty
* Implement Arbitrary for CompactDifficulty
Remove the derive, and generate values from random block
hashes.
* Implement Arbitrary for ExpandedDifficulty and Work
* Use Arbitrary for CompactDifficulty in Arbitrary for Block
* Test difficulty on all block test vectors
And cleanup some duplicate test code
* Round-trip tests for compact test cases
* Round-trip tests for compact difficulty in block test vectors
* Make Add for Work return PartialCumulativeWork
Remove AddAssign for Work
Rewrite a proptest using Sub for PartialCumulativeWork
Use Arbitrary for Work
* Add roundtrip work sum tests
* Add roundtrip comparison difficulty tests
* Add failing proptest cases due to test bugs
* Use Some(_) rather than _.into()
* Reduce visibility of difficulty type inner values
* Split work and other difficulty proptests
This change makes sure that rejected work values don't disable property
tests on other types.
2020-10-30 11:36:59 +10:00
Deirdre Connolly 0cb8010ae7 Remove allow(dead_code) on transaction module] 2020-10-28 21:44:13 -04:00
Deirdre Connolly 8cac287aa2 Tidy TransactionError 2020-10-28 21:44:13 -04:00
Deirdre Connolly b2df84fc59 Dedupe VerifyTransactionError into TransactionError 2020-10-28 21:44:13 -04:00
Deirdre Connolly 1d646e6a27 Make Clippy happy 2020-10-28 21:44:13 -04:00
Deirdre Connolly 1ce2eea35f Add coinbase shielded descriptions check 2020-10-28 21:44:13 -04:00
Deirdre Connolly 1653aca570 Add shielded_balances_match check 2020-10-28 21:44:13 -04:00
Deirdre Connolly 612148fbdd consensus: add transaction::check module 2020-10-28 21:44:13 -04:00
teor 3748623d92 Remove a redundant block header test vector 2020-10-28 21:24:28 -04:00
Alfredo Garcia bcb027ebc5 change canopy.pdf to stable protocol.pdf 2020-10-28 11:34:53 -04:00
dependabot[bot] 83c844abb5 build(deps): bump futures from 0.3.6 to 0.3.7
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.6 to 0.3.7.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.6...0.3.7)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-27 02:28:48 -04:00
Henry de Valence 65e0c22fbe state: don't pre-buffer the service
There's no reason to return a pre-Buffer'd service (there's no need for
internal access to the state service, as in zebra-network), but wrapping
it internally removes control of the buffer size from the caller.
2020-10-26 12:05:35 -07:00
Henry de Valence a1a3e4db5a consensus: simplify block verify tracing output
The previous debug output printed a message that the chain verifier had
recieved a block.  But this provides no additional information compared
to printing no message in chain::Verifier and a message in whichever
verifier the block was sent to, since the resulting spans indicate where
the block was dispatched.

This commit also removes the "unexpected high block" detection; this was
an artefact of the original sync algorithm failing to handle block
advertisements, but we don't have that problem any more, so we can
simplify the code by eliminating that logic.
2020-10-26 12:05:35 -07:00
teor a141c336ab Actually fix whitespace 2020-10-26 13:49:48 -04:00
teor bbe4aa47ea Fix whitespace for rustfmt 2020-10-26 13:49:48 -04:00
teor 2fa3d8a8f4 Add a comment explaining why block metrics follow validation 2020-10-26 13:49:48 -04:00
teor f5a53d9dae Update block metrics after async transaction verification 2020-10-26 13:49:48 -04:00
teor 60322c3d48 Test that the checkpoint list gap is correct
If we change the gap, but don't rebuild the lists, `zebrad` hangs with
weird errors.
2020-10-26 20:59:40 +10:00
teor f9dc481934 Rebuild the checkpoint lists with smaller checkpoints 2020-10-26 20:59:40 +10:00
teor 20dfd04463 Reduce maximum checkpoint size in the Zebra code
The new limits are 400 blocks and 32 MB.
2020-10-26 20:59:40 +10:00
dependabot[bot] ff51c2e0c0 build(deps): bump tracing-subscriber from 0.2.13 to 0.2.14
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.2.13 to 0.2.14.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.2.13...tracing-subscriber-0.2.14)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-23 15:02:02 -04:00
teor 6dc95b1d6d
Revise the checkpoint verifier metrics (#1195)
* update continuous and processing.next metrics correctly
* remove duplicate metrics
* rename ambiguous metrics
2020-10-21 20:06:26 -07:00
Alfredo Garcia 21ad6ffc47
Reverse displayed endianness of transaction and block hashes (#1171)
* Reverse displayed endianness of transaction and block hashes
* fix zebra-checkpoints utility for new hash order
* Stop using "zebrad revhex" in zebrad-hash-lookup
* Rebuild checkpoint lists in new hash order
This change also adds additional checkpoints to the end of each list.

* Replace TransactionHash with transaction::Hash
This change should have been made in #905, but we missed Debug impls
and some docs.

Co-authored-by: Ramana Venkata <vramana@users.noreply.github.com>
Co-authored-by: teor <teor@riseup.net>
2020-10-22 07:54:02 +10:00
Deirdre Connolly 9549e180c0 Allow dead_code on parameters for now 2020-10-20 11:16:22 -04:00
Deirdre Connolly a7ef6f6a40 Allow dead_code for checkpoint::Verifier for now 2020-10-20 11:16:22 -04:00
Deirdre Connolly e796132057 Allow dead_code for the transaction::Request for now (mempool) 2020-10-20 11:16:22 -04:00
Henry de Valence eb43893de0 consensus: minimize API, clean docs
This reduces the API surface to the minimum required for functionality,
and cleans up module documentation.  The stub mempool module is deleted
entirely, since it will need to be redone later anyways.
2020-10-20 11:16:22 -04:00
Henry de Valence d4ce3eb054 consensus: improve docs
- remove no longer accurate documentation about transaction verifier;
- add description of the role of the crate.
2020-10-20 11:16:22 -04:00
Jane Lusby c0aa1b477e consensus: add #[source] attributes to chain errors 2020-10-20 11:16:22 -04:00