change(deps): Remove unused zebra-utils dependencies (#5961)
* Remove unused zebra-utils dependencies * Cleanup zebra-checkpoints
This commit is contained in:
parent
7308dd5b73
commit
c2896cce4b
|
@ -5460,6 +5460,7 @@ dependencies = [
|
||||||
"tracing-subscriber 0.3.16",
|
"tracing-subscriber 0.3.16",
|
||||||
"zcash_proofs",
|
"zcash_proofs",
|
||||||
"zebra-chain",
|
"zebra-chain",
|
||||||
|
"zebra-node-services",
|
||||||
"zebra-script",
|
"zebra-script",
|
||||||
"zebra-state",
|
"zebra-state",
|
||||||
"zebra-test",
|
"zebra-test",
|
||||||
|
@ -5631,8 +5632,7 @@ dependencies = [
|
||||||
"tracing-error",
|
"tracing-error",
|
||||||
"tracing-subscriber 0.3.16",
|
"tracing-subscriber 0.3.16",
|
||||||
"zebra-chain",
|
"zebra-chain",
|
||||||
"zebra-consensus",
|
"zebra-node-services",
|
||||||
"zebra-state",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -7,10 +7,17 @@ edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
|
# Production features that activate extra dependencies, or extra features in dependencies
|
||||||
|
|
||||||
|
# Experimental mining RPC support
|
||||||
getblocktemplate-rpcs = [
|
getblocktemplate-rpcs = [
|
||||||
"zebra-state/getblocktemplate-rpcs",
|
"zebra-state/getblocktemplate-rpcs",
|
||||||
|
"zebra-node-services/getblocktemplate-rpcs",
|
||||||
"zebra-chain/getblocktemplate-rpcs",
|
"zebra-chain/getblocktemplate-rpcs",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Test-only features
|
||||||
proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl", "zebra-state/proptest-impl"]
|
proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl", "zebra-state/proptest-impl"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -45,10 +52,12 @@ zcash_proofs = { version = "0.9.0", features = ["local-prover", "multicore", "do
|
||||||
tower-fallback = { path = "../tower-fallback/" }
|
tower-fallback = { path = "../tower-fallback/" }
|
||||||
tower-batch = { path = "../tower-batch/" }
|
tower-batch = { path = "../tower-batch/" }
|
||||||
|
|
||||||
zebra-chain = { path = "../zebra-chain" }
|
|
||||||
zebra-state = { path = "../zebra-state" }
|
|
||||||
zebra-script = { path = "../zebra-script" }
|
zebra-script = { path = "../zebra-script" }
|
||||||
|
zebra-state = { path = "../zebra-state" }
|
||||||
|
zebra-node-services = { path = "../zebra-node-services" }
|
||||||
|
zebra-chain = { path = "../zebra-chain" }
|
||||||
|
|
||||||
|
# Test-only dependencies
|
||||||
proptest = { version = "0.10.1", optional = true }
|
proptest = { version = "0.10.1", optional = true }
|
||||||
proptest-derive = { version = "0.3.0", optional = true }
|
proptest-derive = { version = "0.3.0", optional = true }
|
||||||
|
|
||||||
|
@ -67,6 +76,6 @@ tokio = { version = "1.24.1", features = ["full", "tracing", "test-util"] }
|
||||||
tracing-error = "0.2.0"
|
tracing-error = "0.2.0"
|
||||||
tracing-subscriber = "0.3.16"
|
tracing-subscriber = "0.3.16"
|
||||||
|
|
||||||
zebra-chain = { path = "../zebra-chain", features = ["proptest-impl"] }
|
|
||||||
zebra-state = { path = "../zebra-state", features = ["proptest-impl"] }
|
zebra-state = { path = "../zebra-state", features = ["proptest-impl"] }
|
||||||
|
zebra-chain = { path = "../zebra-chain", features = ["proptest-impl"] }
|
||||||
zebra-test = { path = "../zebra-test/" }
|
zebra-test = { path = "../zebra-test/" }
|
||||||
|
|
|
@ -34,7 +34,16 @@ use zebra_chain::{
|
||||||
};
|
};
|
||||||
use zebra_state::{self as zs, FinalizedBlock};
|
use zebra_state::{self as zs, FinalizedBlock};
|
||||||
|
|
||||||
use crate::{block::VerifyBlockError, error::BlockError, BoxError};
|
use crate::{
|
||||||
|
block::VerifyBlockError,
|
||||||
|
checkpoint::types::{
|
||||||
|
Progress,
|
||||||
|
Progress::*,
|
||||||
|
TargetHeight::{self, *},
|
||||||
|
},
|
||||||
|
error::BlockError,
|
||||||
|
BoxError,
|
||||||
|
};
|
||||||
|
|
||||||
pub(crate) mod list;
|
pub(crate) mod list;
|
||||||
mod types;
|
mod types;
|
||||||
|
@ -42,9 +51,9 @@ mod types;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
|
pub use zebra_node_services::constants::{MAX_CHECKPOINT_BYTE_COUNT, MAX_CHECKPOINT_HEIGHT_GAP};
|
||||||
|
|
||||||
pub use list::CheckpointList;
|
pub use list::CheckpointList;
|
||||||
use types::{Progress, Progress::*};
|
|
||||||
use types::{TargetHeight, TargetHeight::*};
|
|
||||||
|
|
||||||
/// An unverified block, which is in the queue for checkpoint verification.
|
/// An unverified block, which is in the queue for checkpoint verification.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -84,25 +93,6 @@ type QueuedBlockList = Vec<QueuedBlock>;
|
||||||
/// usage by committing blocks to the disk state. (Or dropping invalid blocks.)
|
/// usage by committing blocks to the disk state. (Or dropping invalid blocks.)
|
||||||
pub const MAX_QUEUED_BLOCKS_PER_HEIGHT: usize = 4;
|
pub const MAX_QUEUED_BLOCKS_PER_HEIGHT: usize = 4;
|
||||||
|
|
||||||
/// We limit the maximum number of blocks in each checkpoint. Each block uses a
|
|
||||||
/// constant amount of memory for the supporting data structures and futures.
|
|
||||||
///
|
|
||||||
/// We choose a checkpoint gap that allows us to verify one checkpoint for
|
|
||||||
/// every `ObtainTips` or `ExtendTips` response.
|
|
||||||
///
|
|
||||||
/// `zcashd`'s maximum `FindBlocks` response size is 500 hashes. `zebrad` uses
|
|
||||||
/// 1 hash to verify the tip, and discards 1-2 hashes to work around `zcashd`
|
|
||||||
/// bugs. So the most efficient gap is slightly less than 500 blocks.
|
|
||||||
pub const MAX_CHECKPOINT_HEIGHT_GAP: usize = 400;
|
|
||||||
|
|
||||||
/// We limit the memory usage and download contention for each checkpoint,
|
|
||||||
/// based on the cumulative size of the serialized blocks in the chain.
|
|
||||||
///
|
|
||||||
/// Deserialized blocks (in memory) are slightly larger than serialized blocks
|
|
||||||
/// (on the network or disk). But they should be within a constant factor of the
|
|
||||||
/// serialized size.
|
|
||||||
pub const MAX_CHECKPOINT_BYTE_COUNT: u64 = 32 * 1024 * 1024;
|
|
||||||
|
|
||||||
/// Convert a tip into its hash and matching progress.
|
/// Convert a tip into its hash and matching progress.
|
||||||
fn progress_from_tip(
|
fn progress_from_tip(
|
||||||
checkpoint_list: &CheckpointList,
|
checkpoint_list: &CheckpointList,
|
||||||
|
|
|
@ -11,13 +11,9 @@ use tokio::time::timeout;
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
use tracing_futures::Instrument;
|
use tracing_futures::Instrument;
|
||||||
|
|
||||||
use zebra_chain::parameters::Network::*;
|
use zebra_chain::{parameters::Network::*, serialization::ZcashDeserialize};
|
||||||
use zebra_chain::serialization::ZcashDeserialize;
|
|
||||||
|
|
||||||
use super::{
|
use super::*;
|
||||||
types::{Progress::*, TargetHeight::*},
|
|
||||||
*,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// The timeout we apply to each verify future during testing.
|
/// The timeout we apply to each verify future during testing.
|
||||||
///
|
///
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
//! Constants shared by some Zebra node services.
|
||||||
|
|
||||||
|
/// We limit the maximum number of blocks in each checkpoint. Each block uses a
|
||||||
|
/// constant amount of memory for the supporting data structures and futures.
|
||||||
|
///
|
||||||
|
/// We choose a checkpoint gap that allows us to verify one checkpoint for
|
||||||
|
/// every `ObtainTips` or `ExtendTips` response.
|
||||||
|
///
|
||||||
|
/// `zcashd`'s maximum `FindBlocks` response size is 500 hashes. `zebrad` uses
|
||||||
|
/// 1 hash to verify the tip, and discards 1-2 hashes to work around `zcashd`
|
||||||
|
/// bugs. So the most efficient gap is slightly less than 500 blocks.
|
||||||
|
pub const MAX_CHECKPOINT_HEIGHT_GAP: usize = 400;
|
||||||
|
|
||||||
|
/// We limit the memory usage and download contention for each checkpoint,
|
||||||
|
/// based on the cumulative size of the serialized blocks in the chain.
|
||||||
|
///
|
||||||
|
/// Deserialized blocks (in memory) are slightly larger than serialized blocks
|
||||||
|
/// (on the network or disk). But they should be within a constant factor of the
|
||||||
|
/// serialized size.
|
||||||
|
pub const MAX_CHECKPOINT_BYTE_COUNT: u64 = 32 * 1024 * 1024;
|
|
@ -1,5 +1,6 @@
|
||||||
//! The interfaces of some Zebra node services.
|
//! The interfaces of some Zebra node services.
|
||||||
|
|
||||||
|
pub mod constants;
|
||||||
pub mod mempool;
|
pub mod mempool;
|
||||||
|
|
||||||
/// Error type alias to make working with tower traits easier.
|
/// Error type alias to make working with tower traits easier.
|
||||||
|
|
|
@ -19,6 +19,5 @@ serde_json = "1.0.91"
|
||||||
tracing-error = "0.2.0"
|
tracing-error = "0.2.0"
|
||||||
tracing-subscriber = "0.3.16"
|
tracing-subscriber = "0.3.16"
|
||||||
|
|
||||||
|
zebra-node-services = { path = "../zebra-node-services" }
|
||||||
zebra-chain = { path = "../zebra-chain" }
|
zebra-chain = { path = "../zebra-chain" }
|
||||||
zebra-consensus = { path = "../zebra-consensus" }
|
|
||||||
zebra-state = { path = "../zebra-state" }
|
|
||||||
|
|
|
@ -2,13 +2,10 @@
|
||||||
//!
|
//!
|
||||||
//! For usage please refer to the program help: `zebra-checkpoints --help`
|
//! For usage please refer to the program help: `zebra-checkpoints --help`
|
||||||
|
|
||||||
#![deny(missing_docs)]
|
|
||||||
#![allow(clippy::try_err)]
|
|
||||||
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
/// zebra-checkpoints arguments
|
/// zebra-checkpoints arguments
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Clone, Debug, Eq, PartialEq, StructOpt)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
/// Path to zcash-cli command
|
/// Path to zcash-cli command
|
||||||
#[structopt(default_value = "zcash-cli", short, long)]
|
#[structopt(default_value = "zcash-cli", short, long)]
|
||||||
|
|
|
@ -8,17 +8,19 @@
|
||||||
//! zebra-consensus accepts an ordered list of checkpoints, starting with the
|
//! zebra-consensus accepts an ordered list of checkpoints, starting with the
|
||||||
//! genesis block. Checkpoint heights can be chosen arbitrarily.
|
//! genesis block. Checkpoint heights can be chosen arbitrarily.
|
||||||
|
|
||||||
use color_eyre::eyre::{ensure, Result};
|
|
||||||
use serde_json::Value;
|
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
use zebra_chain::block;
|
|
||||||
use zebra_utils::init_tracing;
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::process::ExitStatusExt;
|
use std::os::unix::process::ExitStatusExt;
|
||||||
|
|
||||||
|
use color_eyre::eyre::{ensure, Result};
|
||||||
|
use serde_json::Value;
|
||||||
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
use zebra_chain::{block, transparent::MIN_TRANSPARENT_COINBASE_MATURITY};
|
||||||
|
use zebra_node_services::constants::{MAX_CHECKPOINT_BYTE_COUNT, MAX_CHECKPOINT_HEIGHT_GAP};
|
||||||
|
use zebra_utils::init_tracing;
|
||||||
|
|
||||||
mod args;
|
mod args;
|
||||||
|
|
||||||
/// Return a new `zcash-cli` command, including the `zebra-checkpoints`
|
/// Return a new `zcash-cli` command, including the `zebra-checkpoints`
|
||||||
|
@ -60,8 +62,8 @@ fn cmd_output(cmd: &mut std::process::Command) -> Result<String> {
|
||||||
|
|
||||||
#[allow(clippy::print_stdout)]
|
#[allow(clippy::print_stdout)]
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
|
// initialise
|
||||||
init_tracing();
|
init_tracing();
|
||||||
|
|
||||||
color_eyre::install()?;
|
color_eyre::install()?;
|
||||||
|
|
||||||
// get the current block count
|
// get the current block count
|
||||||
|
@ -74,7 +76,7 @@ fn main() -> Result<()> {
|
||||||
// Zcash reorg limit.
|
// Zcash reorg limit.
|
||||||
let height_limit = height_limit
|
let height_limit = height_limit
|
||||||
.0
|
.0
|
||||||
.checked_sub(zebra_state::MAX_BLOCK_REORG_HEIGHT)
|
.checked_sub(MIN_TRANSPARENT_COINBASE_MATURITY)
|
||||||
.map(block::Height)
|
.map(block::Height)
|
||||||
.expect("zcashd has some mature blocks: wait for zcashd to sync more blocks");
|
.expect("zcashd has some mature blocks: wait for zcashd to sync more blocks");
|
||||||
|
|
||||||
|
@ -120,8 +122,8 @@ fn main() -> Result<()> {
|
||||||
|
|
||||||
// check if checkpoint
|
// check if checkpoint
|
||||||
if height == block::Height(0)
|
if height == block::Height(0)
|
||||||
|| cumulative_bytes >= zebra_consensus::MAX_CHECKPOINT_BYTE_COUNT
|
|| cumulative_bytes >= MAX_CHECKPOINT_BYTE_COUNT
|
||||||
|| height_gap.0 >= zebra_consensus::MAX_CHECKPOINT_HEIGHT_GAP as u32
|
|| height_gap.0 >= MAX_CHECKPOINT_HEIGHT_GAP as u32
|
||||||
{
|
{
|
||||||
// print to output
|
// print to output
|
||||||
println!("{} {hash}", height.0);
|
println!("{} {hash}", height.0);
|
||||||
|
|
Loading…
Reference in New Issue