feature: Implement CheckpointVerifier (#524)
* Return Poll::Ready(Err(_)) when verification has finished * Turn checkpoint::init() into CheckpointVerifier::new() * Accept IntoIterator<...> for CheckpointVerifier::new() * Add a CheckpointList type * Replace the state service with oneshot channels. * Reject redundant checkpoint blocks * impl Drop for CheckpointVerifier * Add fields for caching blocks, and managing verify chains. * Add current checkpoint functions * Use a checkpoint range * Get full backtraces with Err::Try * Add enums for verification progress and target block heights. * Replace install_tracing() with zebra_test::init() * Add a test that mixes good and bad blocks * Add timeouts to the checkpoint test futures
This commit is contained in:
parent
c8cbb08ae3
commit
f2052b398b
|
|
@ -2367,6 +2367,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"chrono",
|
||||
"color-eyre",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"spandoc",
|
||||
"tokio",
|
||||
|
|
|
|||
|
|
@ -10,16 +10,20 @@ edition = "2018"
|
|||
[dependencies]
|
||||
zebra-chain = { path = "../zebra-chain" }
|
||||
zebra-state = { path = "../zebra-state" }
|
||||
|
||||
chrono = "0.4.13"
|
||||
futures-util = "0.3.5"
|
||||
tokio = { version = "0.2", features = ["sync"] }
|
||||
tower = "0.3.1"
|
||||
|
||||
[dev-dependencies]
|
||||
zebra-test = { path = "../zebra-test/" }
|
||||
|
||||
color-eyre = "0.5"
|
||||
futures = "0.3.5"
|
||||
spandoc = "0.1"
|
||||
tokio = { version = "0.2.21", features = ["full"] }
|
||||
tokio = { version = "0.2", features = ["macros", "time"] }
|
||||
tracing = "0.1.15"
|
||||
tracing-error = "0.1.2"
|
||||
tracing-futures = "0.2"
|
||||
tracing-subscriber = "0.2.7"
|
||||
color-eyre = "0.5"
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -12,36 +12,8 @@
|
|||
#![doc(html_logo_url = "https://www.zfnd.org/images/zebra-icon.png")]
|
||||
#![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_consensus")]
|
||||
#![deny(missing_docs)]
|
||||
#![allow(clippy::try_err)]
|
||||
|
||||
pub mod checkpoint;
|
||||
pub mod mempool;
|
||||
pub mod verify;
|
||||
|
||||
/// Test utility functions
|
||||
///
|
||||
/// Submodules have their own specific tests.
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Once;
|
||||
use tracing_error::ErrorLayer;
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tracing_subscriber::{fmt, EnvFilter};
|
||||
|
||||
static LOGGER_INIT: Once = Once::new();
|
||||
|
||||
// TODO(jlusby): Refactor into the zebra-test crate (#515)
|
||||
pub(crate) fn install_tracing() {
|
||||
LOGGER_INIT.call_once(|| {
|
||||
let fmt_layer = fmt::layer().with_target(false);
|
||||
let filter_layer = EnvFilter::try_from_default_env()
|
||||
.or_else(|_| EnvFilter::try_new("info"))
|
||||
.unwrap();
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(filter_layer)
|
||||
.with(fmt_layer)
|
||||
.with(ErrorLayer::default())
|
||||
.init();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,6 @@ where
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::tests::install_tracing;
|
||||
|
||||
use chrono::offset::{LocalResult, TimeZone};
|
||||
use chrono::{Duration, Utc};
|
||||
|
|
@ -294,7 +293,7 @@ mod tests {
|
|||
#[tokio::test]
|
||||
#[spandoc::spandoc]
|
||||
async fn verify() -> Result<(), Report> {
|
||||
install_tracing();
|
||||
zebra_test::init();
|
||||
|
||||
let block =
|
||||
Arc::<Block>::zcash_deserialize(&zebra_test::vectors::BLOCK_MAINNET_415000_BYTES[..])?;
|
||||
|
|
@ -319,7 +318,7 @@ mod tests {
|
|||
#[tokio::test]
|
||||
#[spandoc::spandoc]
|
||||
async fn round_trip() -> Result<(), Report> {
|
||||
install_tracing();
|
||||
zebra_test::init();
|
||||
|
||||
let block =
|
||||
Arc::<Block>::zcash_deserialize(&zebra_test::vectors::BLOCK_MAINNET_415000_BYTES[..])?;
|
||||
|
|
@ -361,7 +360,7 @@ mod tests {
|
|||
#[tokio::test]
|
||||
#[spandoc::spandoc]
|
||||
async fn verify_fail_add_block() -> Result<(), Report> {
|
||||
install_tracing();
|
||||
zebra_test::init();
|
||||
|
||||
let block =
|
||||
Arc::<Block>::zcash_deserialize(&zebra_test::vectors::BLOCK_MAINNET_415000_BYTES[..])?;
|
||||
|
|
@ -430,7 +429,7 @@ mod tests {
|
|||
#[tokio::test]
|
||||
#[spandoc::spandoc]
|
||||
async fn verify_fail_future_time() -> Result<(), Report> {
|
||||
install_tracing();
|
||||
zebra_test::init();
|
||||
|
||||
let mut block =
|
||||
<Block>::zcash_deserialize(&zebra_test::vectors::BLOCK_MAINNET_415000_BYTES[..])?;
|
||||
|
|
|
|||
Loading…
Reference in New Issue