Go to file
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
.github Remove timeout on test job 2020-11-24 22:14:37 -05:00
book RFC: Contextual Difficulty (#1246) 2020-11-26 11:45:01 +10:00
design Update data-flow.md 2020-08-04 22:44:39 -07:00
docker Compile tests without running as container layer 2020-11-24 11:04:30 -05:00
tower-batch build(deps): bump tracing from 0.1.21 to 0.1.22 2020-11-24 10:55:53 -05:00
tower-fallback deps: move to tokio 0.3, tower 0.4 2020-11-20 10:08:16 -08:00
zebra-chain Inbound `FindBlocks` and `FindHeaders` (#1347) 2020-12-01 07:30:37 +10:00
zebra-client clippy: remove generated tests in empty crates 2020-10-29 09:58:56 -07:00
zebra-consensus Decrease the UTXO request timeout (#1407) 2020-12-01 10:12:25 +10:00
zebra-network Inbound `FindBlocks` and `FindHeaders` (#1347) 2020-12-01 07:30:37 +10:00
zebra-rpc clippy: remove generated tests in empty crates 2020-10-29 09:58:56 -07:00
zebra-script remove references to sled from service.rs 2020-11-18 15:09:43 -05:00
zebra-state Inbound `FindBlocks` and `FindHeaders` (#1347) 2020-12-01 07:30:37 +10:00
zebra-test rename test fn 2020-11-24 11:04:30 -05:00
zebra-utils build(deps): bump color-eyre from 0.5.7 to 0.5.8 2020-11-24 09:59:22 -05:00
zebrad zebrad: add a use_color option to the tracing config. 2020-11-30 15:25:50 -08:00
.firebaserc Try building internal docs. 2020-02-10 18:12:43 -08:00
.gitignore Add block test vectors for each network upgrade (#1096) 2020-09-28 12:42:06 +10:00
CONTRIBUTING.md Add issue and PR templates, document RFC process 2020-08-31 00:58:50 -04:00
Cargo.lock Implement AdjustedDifficulty creation 2020-12-01 07:27:30 +10:00
Cargo.toml deps: bump tower to pick up auto-resize in Hedge 2020-11-20 10:08:16 -08:00
LICENSE-APACHE Add copyright marks on each license 2019-11-14 11:50:49 -08:00
LICENSE-MIT Add copyright marks on each license 2019-11-14 11:50:49 -08:00
README.md Format 'under construction' better in markdown 2020-10-07 11:35:39 -04:00
clippy.toml Apply clippy fixes 2020-02-05 12:42:32 -08:00
cloudbuild.yaml Split up big test job into its own workflow 2020-11-19 16:20:36 -05:00
codecov.yml Disable CodeCov annotations via GitHub Checks 2020-09-10 14:52:01 -04:00
firebase.json Configure redirect for firebase hosting 2020-01-16 18:38:16 -05:00
katex-header.html Add KaTeX to rendered docs. (#832) 2020-08-05 17:34:30 -07:00
prometheus.yaml Tell Prometheus to scrape more aggressively 2020-02-14 20:14:05 -05:00

README.md

Zebra logotype


codecov License

🚧 UNDER CONSTRUCTION 🚧

Zebra is the Zcash Foundation's independent, consensus-compatible implementation of the Zcash protocol, currently under development. Please join us on Discord if you'd like to find out more or get involved!

Unlike zcashd, which originated as a Bitcoin Core fork and inherited its monolithic architecture, Zebra has a modular, library-first design, with the intent that each component can be independently reused outside of the zebrad fullnode. For instance, the zebra-network crate containing the network stack can also be used to implement anonymous transaction relay, network crawlers, or other functionality, without requiring a full node.

Our first goal is to be able to participate in the network and replicate the Zcash chain state, and we intend to ship an alpha before the end of 2020 with this functionality. In 2021, we intend to add RPC support and wallet integration. This phased approach allows us to test the independent implementation of the consensus rules before asking users to entrust it with their funds.

At a high level, the fullnode functionality required by zebrad is factored into several components:

  • zebra-chain, providing definitions of core data structures for Zcash, such as blocks, transactions, addresses, etc., and related functionality. It also contains the implementation of the consensus-critical serialization formats used in Zcash. The data structures in zebra-chain are defined to enforce structural validity by making invalid states unrepresentable. For instance, the Transaction enum has variants for each transaction version, and it's impossible to construct a transaction with, e.g., spend or output descriptions but no binding signature, or, e.g., a version 2 (Sprout) transaction with Sapling proofs. Currently, zebra-chain is oriented towards verifying transactions, but will be extended to support creating them in the future.

  • zebra-network, providing an asynchronous, multithreaded implementation of the Zcash network protocol inherited from Bitcoin. In contrast to zcashd, each peer connection has a separate state machine, and the crate translates the external network protocol into a stateless, request/response-oriented protocol for internal use. The crate provides two interfaces: an auto-managed connection pool that load-balances requests over available peers, and a connect_isolated method that produces a peer connection completely isolated from all other node state. This can be used, for instance, to safely relay data over Tor, without revealing distinguishing information.

  • zebra-script provides script validation. Currently, this is implemented by linking to the C++ script verification code from zcashd, but in the future we may implement a pure-Rust script implementation.

  • zebra-consensus performs semantic validation of blocks and transactions: all consensus rules that can be checked independently of the chain state, such as verification of signatures, proofs, and scripts. Internally, the library uses tower-batch to perform automatic, transparent batch processing of contemporaneous verification requests.

  • zebra-state is responsible for storing, updating, and querying the chain state. The state service is responsible for contextual verification: all consensus rules that check whether a new block is a valid extension of an existing chain, such as updating the nullifier set or checking that transaction inputs remain unspent.

  • zebrad contains the full node, which connects these components together and implements logic to handle inbound requests from peers and the chain sync process.

  • zebra-rpc and zebra-client will eventually contain the RPC and wallet functionality, but as mentioned above, our goal is to implement replication of chain state first before asking users to entrust Zebra with their funds.

All of these components can be reused as independent libraries, and all communication between stateful components is handled internally by internal asynchronous RPC abstraction ("microservices in one process").

The Zebra website contains user documentation, such as how to run or configure Zebra, set up metrics integrations, etc., as well as developer documentation, such as design documents. We also render API documentation for the external API of our crates, as well as internal documentation for private APIs.

License

Zebra is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT.