diff --git a/zero/src/bin/leader/client.rs b/zero/src/bin/leader/client.rs index 191becdc0..a51d17a0d 100644 --- a/zero/src/bin/leader/client.rs +++ b/zero/src/bin/leader/client.rs @@ -11,7 +11,6 @@ use zero::pre_checks::check_previous_proof_and_checkpoint; use zero::proof_types::GeneratedBlockProof; use zero::prover::{self, BlockProverInput, ProverConfig}; use zero::rpc; -use zero::rpc::{retry::build_http_retry_provider, RpcType}; use crate::ProofRuntime; diff --git a/zero/src/block_interval.rs b/zero/src/block_interval.rs index 16527bceb..dcc0c67a0 100644 --- a/zero/src/block_interval.rs +++ b/zero/src/block_interval.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use alloy::rpc::types::eth::BlockId; use alloy::rpc::types::BlockTransactionsKind; -use alloy::{hex, providers::Provider, transports::Transport}; +use alloy::{providers::Provider, transports::Transport}; use anyhow::{anyhow, Result}; use async_stream::try_stream; use futures::Stream; @@ -36,6 +36,9 @@ impl BlockInterval { /// If end_block is None, the interval is unbounded and will follow from /// start_block. If start_block == end_block, the interval is a single /// block. Otherwise the interval is a range from start_block to end_block. + /// + /// end_block is treated as inclusive because it may have been specified + /// as a block hash. pub async fn new( cached_provider: Arc>, start_block: BlockId, @@ -91,12 +94,12 @@ impl BlockInterval { } } + /// Returns the start block number of the interval. pub fn get_start_block(&self) -> Result { match self { BlockInterval::SingleBlockId(num) => Ok(*num), BlockInterval::Range(range) => Ok(range.start), BlockInterval::FollowFrom { start_block, .. } => Ok(*start_block), - _ => Err(anyhow!("Unknown BlockInterval variant")), // Handle unknown variants } } @@ -137,6 +140,7 @@ impl BlockInterval { } } + /// Converts a [`BlockId`] into a block number by querying the provider. pub async fn block_to_num( cached_provider: Arc>, block: BlockId, @@ -146,9 +150,12 @@ impl BlockInterval { TransportT: Transport + Clone, { let block_num = match block { + // Number already provided BlockId::Number(num) => num .as_number() .ok_or_else(|| anyhow!("invalid block number '{num}'"))?, + + // Hash provided, query the provider for the block number. BlockId::Hash(hash) => { let block = cached_provider .get_provider()