diff --git a/Cargo.lock b/Cargo.lock index 0c1168d4..910c81ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3356,6 +3356,7 @@ dependencies = [ "tracing-subscriber 0.2.14", "zebra-chain", "zebra-consensus", + "zebra-state", ] [[package]] diff --git a/zebra-state/src/lib.rs b/zebra-state/src/lib.rs index 88ac2dab..5e716772 100644 --- a/zebra-state/src/lib.rs +++ b/zebra-state/src/lib.rs @@ -23,6 +23,7 @@ use service::QueuedBlock; use sled_state::FinalizedState; pub use config::Config; +pub use constants::MAX_BLOCK_REORG_HEIGHT; pub use error::{BoxError, CloneError, CommitBlockError, ValidateContextError}; pub use request::{HashOrHeight, Request}; pub use response::Response; diff --git a/zebra-utils/Cargo.toml b/zebra-utils/Cargo.toml index ba2b2458..167a6429 100644 --- a/zebra-utils/Cargo.toml +++ b/zebra-utils/Cargo.toml @@ -17,3 +17,4 @@ tracing-subscriber = { version = "0.2.14", features = ["tracing-log"] } zebra-chain = { path = "../zebra-chain" } zebra-consensus = { path = "../zebra-consensus" } +zebra-state = { path = "../zebra-state" } diff --git a/zebra-utils/src/bin/zebra-checkpoints/main.rs b/zebra-utils/src/bin/zebra-checkpoints/main.rs index a269b5a1..90ba5e17 100644 --- a/zebra-utils/src/bin/zebra-checkpoints/main.rs +++ b/zebra-utils/src/bin/zebra-checkpoints/main.rs @@ -30,10 +30,6 @@ mod args; /// constant factor of the serialized size. const MAX_CHECKPOINT_BYTE_COUNT: u64 = 256 * 1024 * 1024; -/// Checkpoints must be on the main chain, so we skip blocks that are within the -/// zcashd reorg limit. -const BLOCK_REORG_LIMIT: block::Height = block::Height(100); - /// Initialise tracing using its defaults. fn init_tracing() { tracing_subscriber::Registry::default() @@ -89,9 +85,11 @@ fn main() -> Result<()> { // calculate the maximum height let height_limit: block::Height = cmd_output(&mut cmd)?.trim().parse()?; assert!(height_limit <= block::Height::MAX); + // Checkpoints must be on the main chain, so we skip blocks that are within the + // Zcash reorg limit. let height_limit = height_limit .0 - .checked_sub(BLOCK_REORG_LIMIT.0) + .checked_sub(zebra_state::MAX_BLOCK_REORG_HEIGHT.0) .map(block::Height) .expect("zcashd has some mature blocks: wait for zcashd to sync more blocks");