2020-10-16 15:53:22 -07:00
|
|
|
//! Implementation of Zcash consensus checks.
|
2020-06-07 21:27:38 -07:00
|
|
|
//!
|
2020-10-16 15:53:22 -07:00
|
|
|
//! More specifically, this crate implements *semantic* validity checks,
|
|
|
|
//! as defined below.
|
2020-06-07 21:27:38 -07:00
|
|
|
//!
|
2020-10-16 15:53:22 -07:00
|
|
|
//! ## Verification levels.
|
2020-06-07 21:27:38 -07:00
|
|
|
//!
|
2020-10-16 15:53:22 -07:00
|
|
|
//! 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.
|
2020-06-07 21:27:38 -07:00
|
|
|
|
2020-07-17 16:45:29 -07:00
|
|
|
#![doc(html_favicon_url = "https://www.zfnd.org/images/zebra-favicon-128.png")]
|
2020-02-26 21:10:08 -08:00
|
|
|
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
|
|
|
|
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_consensus")]
|
2020-09-09 20:16:11 -07:00
|
|
|
// Re-enable this after cleaning the API surface.
|
|
|
|
//#![deny(missing_docs)]
|
2020-07-08 04:22:36 -07:00
|
|
|
#![allow(clippy::try_err)]
|
2020-11-30 18:20:57 -08:00
|
|
|
// Disable some broken or unwanted clippy nightly lints
|
2021-01-17 20:31:01 -08:00
|
|
|
// Build without warnings on nightly 2021-01-17 and later and stable 1.51 and later
|
|
|
|
#![allow(unknown_lints)]
|
|
|
|
// Disable old lint warnings on nightly until 1.51 is stable
|
|
|
|
#![allow(renamed_and_removed_lints)]
|
|
|
|
// Use the old lint name to build without warnings on stable until 1.51 is stable
|
2020-11-30 18:20:57 -08:00
|
|
|
#![allow(clippy::unknown_clippy_lints)]
|
2021-01-17 20:31:01 -08:00
|
|
|
// The actual lints we want to disable
|
2020-11-30 18:20:57 -08:00
|
|
|
#![allow(clippy::unnecessary_wraps)]
|
2020-02-26 21:10:08 -08:00
|
|
|
|
2020-10-16 16:44:30 -07:00
|
|
|
mod block;
|
|
|
|
mod checkpoint;
|
|
|
|
mod config;
|
2020-10-19 23:07:38 -07:00
|
|
|
#[allow(dead_code)]
|
2020-10-16 16:44:30 -07:00
|
|
|
mod parameters;
|
2020-08-04 14:01:55 -07:00
|
|
|
mod primitives;
|
2020-10-16 16:44:30 -07:00
|
|
|
mod script;
|
2020-07-09 23:51:01 -07:00
|
|
|
mod transaction;
|
2020-08-19 19:25:46 -07:00
|
|
|
|
2020-10-16 16:44:30 -07:00
|
|
|
pub mod chain;
|
|
|
|
pub mod error;
|
|
|
|
|
2021-01-13 01:10:48 -08:00
|
|
|
pub use checkpoint::MAX_CHECKPOINT_BYTE_COUNT;
|
2020-10-16 16:44:30 -07:00
|
|
|
pub use checkpoint::MAX_CHECKPOINT_HEIGHT_GAP;
|
|
|
|
pub use config::Config;
|
2020-09-09 18:53:40 -07:00
|
|
|
|
|
|
|
/// A boxed [`std::error::Error`].
|
|
|
|
pub type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;
|