Commit Graph

1768 Commits

Author SHA1 Message Date
Deirdre Connolly 6dab76bc36 Avoid disk naming collisions 2020-11-24 11:04:30 -05:00
Deirdre Connolly 4a67e0e7bb Enable stateful/long sync tests by features, mount rocksdb-based state at Sapling activation for sync_past_sapling_mainnet test 2020-11-24 11:04:30 -05:00
Deirdre Connolly b3908b4425 Compile tests without running as container layer 2020-11-24 11:04:30 -05:00
Deirdre Connolly d813603bac Remove defunct memory_cache_bytes from test config 2020-11-24 11:04:30 -05:00
Jane Lusby b96ca38d1c fix args issue 2020-11-24 11:04:30 -05:00
Jane Lusby c2a57d7e49 slight comment tweek 2020-11-24 11:04:30 -05:00
Jane Lusby 99c5acc94f rename test fn 2020-11-24 11:04:30 -05:00
Jane Lusby 602d8c4898 document tests 2020-11-24 11:04:30 -05:00
Jane Lusby 583ec8738b change ci to not blanket enable all ignored tests 2020-11-24 11:04:30 -05:00
Jane Lusby 17fdbe941b fix stdout issue with test framework for cached data tests 2020-11-24 11:04:30 -05:00
Jane Lusby 0f51891359 revert unnecessary change in sync_until 2020-11-24 11:04:30 -05:00
Jane Lusby 9fd38f29b4 further make use statement consistent 2020-11-24 11:04:30 -05:00
Jane Lusby a21ddfeefc fix use cfg 2020-11-24 11:04:30 -05:00
Jane Lusby 4bfe747f34 update acceptance tests 2020-11-24 11:04:30 -05:00
Jane Lusby d093b4e528 Add network integration test for quick post sapling sync testing 2020-11-24 11:04:30 -05:00
teor 15d26e3c47 Downgrade a per-block log to debug level 2020-11-24 10:56:57 -05: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
dependabot[bot] a4af90c2b0 build(deps): bump color-eyre from 0.5.7 to 0.5.8
Bumps [color-eyre](https://github.com/yaahc/color-eyre) from 0.5.7 to 0.5.8.
- [Release notes](https://github.com/yaahc/color-eyre/releases)
- [Changelog](https://github.com/yaahc/color-eyre/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yaahc/color-eyre/compare/v0.5.7...v0.5.8)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-24 09:59:22 -05:00
teor 8d6ac8eece Placate clippy 2020-11-24 20:03:21 +10:00
Henry de Valence d90e709ce1 network: tidy peer set implementation
- rename functions more descriptively
- create a common `take_ready_service` function
- organize poll_ functions separately
2020-11-24 20:03:21 +10:00
Henry de Valence f36a4800b2 network: fix invariant violation in peer set
Closes #1183.

The peer set maintains a preselected ready service that it can use to
perform power-of-two-choices (p2c) routing of requests.  Ready services
are stored by key (socket address) in an `IndexMap`, and the preselected
service is represented by an `Option<usize>` indexing that map.  This
means that whenever the set of ready services changes (e.g., a service
is removed from the peer set, or a service is taken to be used to
process a request), the preselected index is invalidated.  The original
P2C-only implementation maintained this invariant but did not document
it.

The change to inventory-based routing introduced a bug by failing to
maintain this invariant and appropriately invalidate the preselected
index.  However, this was only noticeable approximately 1/N of the time
on the next request after an inventory-directed request, so the bug
occurred infrequently.  Luckily, the use of `.expect` caused the bug to
be an immediate panic, making it possible to identify by inspecting all
uses of the ready service map.
2020-11-24 20:03:21 +10: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 6387dfe1d0 Fix individual crate compilation failures
Some Zebra crates don't compile individually due to missing features in
their dependencies. Add those features to each crate's dependency list.
2020-11-23 23:56:28 -08: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 6202cb45b1 ci: remove nightly clippy
Closes #1212
2020-11-23 22:18:43 -08:00
Henry de Valence 040e50b183 state: service::utxo -> service::pending_utxos 2020-11-23 22:18:43 -08: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
teor d2173cae7e
Basic documentation for zebra-checkpoints (#1361) 2020-11-24 10:49:41 +10:00
teor 00c52d28cd Appease rustfmt 2020-11-23 14:16:39 +10:00
teor acf6096103 Appease clippy stable 2020-11-23 14:16:39 +10:00
Henry de Valence 2a4a89c002 state,zebrad: tidy span levels for good INFO output
This provides useful and not too noisy output at INFO level.  We do an
info-level message on every block commit instead of trying to do one
message every N blocks, because this is useful both for initial block
sync as well as continuous state updates on new blocks.
2020-11-23 14:16:39 +10: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 3f78476693 state: check queued blocks for known UTXOs
The behavior of a request for a UTXO from a previous block depends on
whether that block has already been submitted to the state, or not:

* if it has, the state should be able to find it and answer immediately.
* if it has not, the state should see it in a later request.

However, the previous code only checked committed blocks, not queued
blocks, so if the block containing the UTXO had already arrived but had
not been committed, it would never be scanned.

This patch fixes the problem but is a bad solution, duplicating
computation between the block verifier and the state.  A better fix
follows in the next commit.
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 719a48ad9e state: shorten tracing messages
Make tracing messages more concise by omitting information already
contained in a parent span and by shortening messages.  This makes them
easier to read.
2020-11-23 14:16:39 +10:00
Henry de Valence 3192a5008d state: add additional traces to block commit logic 2020-11-23 14:16:39 +10:00
Henry de Valence 36cd76d590 state: tidy process_queued tracing
Previously, this function was instrumented with a span containing the
parent hash that was the entry to the function.  But it doesn't make
sense to consider the work done by the function as happening in the
context of the supplied parent hash (as distinct from the context of the
hash of the newly arrived block, which is already contained in an outer
span), so this adds noise without conveying extra context.

Instead, use events that occur within the context of the existing spans.
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 77b60f3a30 state: add traces for utxo scanning 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
Deirdre Connolly a877da2157 Enable RUST_BACKTRACE=full for test and build/deploy images 2020-11-22 23:10:20 -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 25fd52be51 chain: tidy Debug for Amount
This avoids printing a bunch of PhantomData.
2020-11-21 14:09:15 -05:00
Henry de Valence b5515123eb chain: add custom Debug for CoinbaseData
The derived Debug impl just shows u8s as numbers, which isn't what we
want.  There are basically two reasonable options here:

1. Hex-encoded bytes
2. Escaped ASCII

I picked (2) because a lot of coinbase data has ascii text in it.
2020-11-21 14:09:15 -05:00