Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change(deps): Remove unused zebra-utils dependencies #5961

Merged
merged 2 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions zebra-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ edition = "2021"

[features]
default = []

# Production features that activate extra dependencies, or extra features in dependencies

# Experimental mining RPC support
getblocktemplate-rpcs = [
"zebra-state/getblocktemplate-rpcs",
"zebra-chain/getblocktemplate-rpcs",
"zebra-state/getblocktemplate-rpcs",
"zebra-node-services/getblocktemplate-rpcs",
"zebra-chain/getblocktemplate-rpcs",
]

# Test-only features
proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl", "zebra-state/proptest-impl"]

[dependencies]
Expand Down Expand Up @@ -45,10 +52,12 @@ zcash_proofs = { version = "0.9.0", features = ["local-prover", "multicore", "do
tower-fallback = { path = "../tower-fallback/" }
tower-batch = { path = "../tower-batch/" }

zebra-chain = { path = "../zebra-chain" }
zebra-state = { path = "../zebra-state" }
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-derive = { version = "0.3.0", optional = true }

Expand All @@ -67,6 +76,6 @@ tokio = { version = "1.24.1", features = ["full", "tracing", "test-util"] }
tracing-error = "0.2.0"
tracing-subscriber = "0.3.16"

zebra-chain = { path = "../zebra-chain", features = ["proptest-impl"] }
zebra-state = { path = "../zebra-state", features = ["proptest-impl"] }
zebra-chain = { path = "../zebra-chain", features = ["proptest-impl"] }
zebra-test = { path = "../zebra-test/" }
34 changes: 12 additions & 22 deletions zebra-consensus/src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,26 @@ use zebra_chain::{
};
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;
mod types;

#[cfg(test)]
mod tests;

pub use zebra_node_services::constants::{MAX_CHECKPOINT_BYTE_COUNT, MAX_CHECKPOINT_HEIGHT_GAP};

pub use list::CheckpointList;
use types::{Progress, Progress::*};
use types::{TargetHeight, TargetHeight::*};

/// An unverified block, which is in the queue for checkpoint verification.
#[derive(Debug)]
Expand Down Expand Up @@ -84,25 +93,6 @@ type QueuedBlockList = Vec<QueuedBlock>;
/// usage by committing blocks to the disk state. (Or dropping invalid blocks.)
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.
fn progress_from_tip(
checkpoint_list: &CheckpointList,
Expand Down
8 changes: 2 additions & 6 deletions zebra-consensus/src/checkpoint/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ use tokio::time::timeout;
use tower::{Service, ServiceExt};
use tracing_futures::Instrument;

use zebra_chain::parameters::Network::*;
use zebra_chain::serialization::ZcashDeserialize;
use zebra_chain::{parameters::Network::*, serialization::ZcashDeserialize};

use super::{
types::{Progress::*, TargetHeight::*},
*,
};
use super::*;

/// The timeout we apply to each verify future during testing.
///
Expand Down
20 changes: 20 additions & 0 deletions zebra-node-services/src/constants.rs
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions zebra-node-services/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! The interfaces of some Zebra node services.

pub mod constants;
pub mod mempool;

/// Error type alias to make working with tower traits easier.
Expand Down
3 changes: 1 addition & 2 deletions zebra-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ serde_json = "1.0.91"
tracing-error = "0.2.0"
tracing-subscriber = "0.3.16"

zebra-node-services = { path = "../zebra-node-services" }
zebra-chain = { path = "../zebra-chain" }
zebra-consensus = { path = "../zebra-consensus" }
zebra-state = { path = "../zebra-state" }
5 changes: 1 addition & 4 deletions zebra-utils/src/bin/zebra-checkpoints/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
//!
//! For usage please refer to the program help: `zebra-checkpoints --help`

#![deny(missing_docs)]
#![allow(clippy::try_err)]

use structopt::StructOpt;

/// zebra-checkpoints arguments
#[derive(Debug, StructOpt)]
#[derive(Clone, Debug, Eq, PartialEq, StructOpt)]
pub struct Args {
/// Path to zcash-cli command
#[structopt(default_value = "zcash-cli", short, long)]
Expand Down
20 changes: 11 additions & 9 deletions zebra-utils/src/bin/zebra-checkpoints/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
//! zebra-consensus accepts an ordered list of checkpoints, starting with the
//! genesis block. Checkpoint heights can be chosen arbitrarily.

use std::process::Stdio;

#[cfg(unix)]
use std::os::unix::process::ExitStatusExt;

use color_eyre::eyre::{ensure, Result};
use serde_json::Value;
use std::process::Stdio;
use structopt::StructOpt;

use zebra_chain::block;
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;

#[cfg(unix)]
use std::os::unix::process::ExitStatusExt;

mod args;

/// Return a new `zcash-cli` command, including the `zebra-checkpoints`
Expand Down Expand Up @@ -60,8 +62,8 @@ fn cmd_output(cmd: &mut std::process::Command) -> Result<String> {

#[allow(clippy::print_stdout)]
fn main() -> Result<()> {
// initialise
init_tracing();

color_eyre::install()?;

// get the current block count
Expand All @@ -74,7 +76,7 @@ fn main() -> Result<()> {
// Zcash reorg limit.
let height_limit = height_limit
.0
.checked_sub(zebra_state::MAX_BLOCK_REORG_HEIGHT)
.checked_sub(MIN_TRANSPARENT_COINBASE_MATURITY)
.map(block::Height)
.expect("zcashd has some mature blocks: wait for zcashd to sync more blocks");

Expand Down Expand Up @@ -120,8 +122,8 @@ fn main() -> Result<()> {

// check if checkpoint
if height == block::Height(0)
|| cumulative_bytes >= zebra_consensus::MAX_CHECKPOINT_BYTE_COUNT
|| height_gap.0 >= zebra_consensus::MAX_CHECKPOINT_HEIGHT_GAP as u32
|| cumulative_bytes >= MAX_CHECKPOINT_BYTE_COUNT
|| height_gap.0 >= MAX_CHECKPOINT_HEIGHT_GAP as u32
{
// print to output
println!("{} {hash}", height.0);
Expand Down