zebra/zebra-consensus/src/lib.rs

60 lines
2.2 KiB
Rust
Raw Normal View History

//! Implementation of Zcash consensus checks.
//!
//! More specifically, this crate implements *semantic* validity checks,
//! as defined below.
//!
//! ## Verification levels.
//!
//! Zebra's implementation of the Zcash consensus rules is oriented
//! around three telescoping notions of validity:
//!
//! 1. *Structural Validity*, or whether the format and structure of the
//! object are valid. For instance, Sprout-on-BCTV14 proofs are not
//! allowed in version 4 transactions, and a transaction with a spend
//! or output description must include a binding signature.
//!
//! 2. *Semantic Validity*, or whether the object could potentially be
//! valid, depending on the chain state. For instance, a transaction
//! that spends a UTXO must supply a valid unlock script; a shielded
//! transaction must have valid proofs, etc.
//!
//! 3. *Contextual Validity*, or whether a semantically valid
//! transaction is actually valid in the context of a particular
//! chain state. For instance, a transaction that spends a
//! UTXO is only valid if the UTXO remains unspent; a
//! shielded transaction spending some note must reveal a nullifier
//! not already in the nullifier set, etc.
//!
//! *Structural validity* is enforced by the definitions of data
//! structures in `zebra-chain`. *Semantic validity* is enforced by the
//! code in this crate. *Contextual validity* is enforced in
//! `zebra-state` when objects are committed to the chain state.
#![doc(html_favicon_url = "https://zfnd.org/wp-content/uploads/2022/03/zebra-favicon-128.png")]
#![doc(html_logo_url = "https://zfnd.org/wp-content/uploads/2022/03/zebra-icon.png")]
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_consensus")]
mod block;
mod checkpoint;
mod config;
2020-10-19 23:07:38 -07:00
#[allow(dead_code)]
mod parameters;
mod primitives;
mod script;
pub mod transaction;
pub mod chain;
#[allow(missing_docs)]
pub mod error;
pub use block::VerifyBlockError;
fix(test): make full sync test more accurate (#3555) * feat(log): log current height when logging sync progress * fix(test): log the specific error when full sync tests fail * doc(start): remove an obsolete TODO We can't decrease this log level, because the tests rely on it. * fix(test): wait until mempool activates in full sync tests Changes the log message and log test so that the test only finishes when the mempool has activated. There is still a race condition here, between the log timer and mempool activation. But it should be very rare, because the mempool is activated immediately when `is_close_to_tip()` becomes true. * fix(test): warn when Zebra stalls below the maximum checkpoint height This also improves the full sync tests, because the warning is checked before logging a successful sync. * feat(log): warn when sync stalls downloading the genesis block * fix(test): warn when the state hasn't committed a block for a long time This also improves the full sync tests, because the warning is checked before logging a successful sync. * doc(test): update some sync acceptance test comments * fix(log): use Display formatting to log chrono::Duration Debug formatting is complicated and hard to read. * fix(log): stop saying that we've activated the mempool without checking it We're not checking if the mempool is active, so we can't say that. * fix(log): minor tidying and TODOs * fix(doc): fix a typo in the tests * fix(log): explain the post-checkpoint blocks in progress warning calculations * fix(doc): explain what could happen if we don't wait for extra blocks * fix(log): add a percent symbol to a percent log Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com> Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-02-17 18:00:24 -08:00
pub use checkpoint::{
CheckpointList, VerifyCheckpointError, MAX_CHECKPOINT_BYTE_COUNT, MAX_CHECKPOINT_HEIGHT_GAP,
};
pub use config::Config;
pub use error::BlockError;
Download Zcash Sapling parameters and load them from cached files (#3057) * Replace Zcash parameters crates with pre-downloaded local parameter files * Download Zcash parameters using the `zcashd` script in CI and Docker * Add a zcash_proofs dependency to zebra-consensus * Download Sapling parameters using zcash_proofs, rather than fetch-params.sh * Add a new `zebrad download` subcommand This command isn't required for nomrmal usage. But it's useful when testing, or launching multiple Zebra instances. * Use `zebrad download` in CI to pre-download parameters * Log a helpful hint if downloading fails * Allow some duplicate dependencies currently hidden by orchard * Spawn a separate task to download Groth16 parameters * Run the parameter download with code coverage This avoids re-compining Zebra with and without coverage. * Update Cargo.lock after rebase * Try to pass `download` as an argument to `zebrad` in coverage CI * Fix copy and paste comment typos * Add path and download examples, like zcash_proofs * Download params in CI just like zcash_proofs does * Delete a redundant build step * Implement graceful shutdown for zebrad start * Send coverage summary to /dev/null when getting the params path * Use the correct parameters path and download commands in CI * Explain pre-downloads * Avoid calling params_folder twice * Rename parameter types and methods for consistency ```sh fastmod SaplingParams SaplingParameters zebra* fastmod Groth16Params Groth16Parameters zebra* fastmod PARAMS GROTH16_PARAMETERS zebra* fastmod params_folder directory zebra* ``` And a manual variable name tweak. * rustfmt * Remove a redundant coverage step Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
2021-11-19 15:02:56 -08:00
pub use primitives::groth16;
/// A boxed [`std::error::Error`].
pub type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;