diff --git a/Cargo.lock b/Cargo.lock index 38f1db1..9c73094 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4045,7 +4045,6 @@ version = "0.0.0" dependencies = [ "alloy", "alloy-rlp", - "anyhow", "async-trait", "eyre", "hashbrown 0.14.5", diff --git a/crates/kona-providers/Cargo.toml b/crates/kona-providers/Cargo.toml index 017925b..1677ae0 100644 --- a/crates/kona-providers/Cargo.toml +++ b/crates/kona-providers/Cargo.toml @@ -24,9 +24,6 @@ eyre.workspace = true url.workspace = true op-alloy-protocol.workspace = true -# Needed for compatibility with kona's ChainProvider trait -anyhow = { version = "1.0.86", default-features = false } - [features] default = ["online"] online = ["kona-derive/online"] diff --git a/crates/kona-providers/src/blob_provider.rs b/crates/kona-providers/src/blob_provider.rs index d1eab10..425947f 100644 --- a/crates/kona-providers/src/blob_provider.rs +++ b/crates/kona-providers/src/blob_provider.rs @@ -158,6 +158,8 @@ impl LayeredBlobProvider { #[async_trait] impl BlobProvider for LayeredBlobProvider { + type Error = BlobProviderError; + /// Fetches blobs for a given block ref and the blob hashes. async fn get_blobs( &mut self, diff --git a/crates/kona-providers/src/chain_provider.rs b/crates/kona-providers/src/chain_provider.rs index cacf5f4..fe847eb 100644 --- a/crates/kona-providers/src/chain_provider.rs +++ b/crates/kona-providers/src/chain_provider.rs @@ -1,7 +1,6 @@ //! Chain Provider use alloc::{collections::vec_deque::VecDeque, sync::Arc}; -use alloy_rlp::Decodable; use hashbrown::HashMap; use alloy::{ @@ -13,7 +12,9 @@ use alloy::{ primitives::B256, signers::Signature, }; +use alloy_rlp::Decodable; use async_trait::async_trait; +use eyre::eyre; use kona_derive::traits::ChainProvider; use op_alloy_protocol::BlockInfo; use parking_lot::RwLock; @@ -169,59 +170,56 @@ impl InMemoryChainProviderInner { #[async_trait] impl ChainProvider for InMemoryChainProvider { + type Error = eyre::Error; + /// Fetch the L1 [Header] for the given [B256] hash. - async fn header_by_hash(&mut self, hash: B256) -> anyhow::Result
{ + async fn header_by_hash(&mut self, hash: B256) -> eyre::Result
{ self.0 .read() .hash_to_header .get(&hash) .cloned() - .ok_or_else(|| anyhow::anyhow!("Header not found")) + .ok_or_else(|| eyre!("Header not found for hash: {}", hash)) } /// Returns the block at the given number, or an error if the block does not exist in the data /// source. - async fn block_info_by_number(&mut self, number: u64) -> anyhow::Result { + async fn block_info_by_number(&mut self, number: u64) -> eyre::Result { self.0 .read() .hash_to_block_info .values() .find(|bi| bi.number == number) .cloned() - .ok_or_else(|| anyhow::anyhow!("Block not found")) + .ok_or_else(|| eyre!("Block not found")) } /// Returns all receipts in the block with the given hash, or an error if the block does not /// exist in the data source. - async fn receipts_by_hash(&mut self, hash: B256) -> anyhow::Result> { + async fn receipts_by_hash(&mut self, hash: B256) -> eyre::Result> { self.0 .read() .hash_to_receipts .get(&hash) .cloned() - .ok_or_else(|| anyhow::anyhow!("Receipts not found")) + .ok_or_else(|| eyre!("Receipts not found")) } /// Returns block info and transactions for the given block hash. async fn block_info_and_transactions_by_hash( &mut self, hash: B256, - ) -> anyhow::Result<(BlockInfo, Vec)> { + ) -> eyre::Result<(BlockInfo, Vec)> { let block_info = self .0 .read() .hash_to_block_info .get(&hash) .cloned() - .ok_or_else(|| anyhow::anyhow!("Block not found"))?; + .ok_or_else(|| eyre!("Block not found"))?; - let txs = self - .0 - .read() - .hash_to_txs - .get(&hash) - .cloned() - .ok_or_else(|| anyhow::anyhow!("Tx not found"))?; + let txs = + self.0.read().hash_to_txs.get(&hash).cloned().ok_or_else(|| eyre!("Tx not found"))?; Ok((block_info, txs)) } diff --git a/crates/rollup/src/driver/mod.rs b/crates/rollup/src/driver/mod.rs index 1ffd4d7..82d4fa9 100644 --- a/crates/rollup/src/driver/mod.rs +++ b/crates/rollup/src/driver/mod.rs @@ -4,7 +4,7 @@ use std::{fmt::Debug, sync::Arc}; use eyre::{bail, eyre, Result}; use kona_derive::{ - errors::StageError, + errors::{PipelineError, PipelineErrorKind}, online::{AlloyChainProvider, AlloyL2ChainProvider, OnlineBlobProviderBuilder}, traits::{BlobProvider, ChainProvider, L2ChainProvider}, }; @@ -174,8 +174,11 @@ where StepResult::AdvancedOrigin => trace!("Advanced origin"), StepResult::OriginAdvanceErr(err) => warn!("Could not advance origin: {:?}", err), StepResult::StepFailed(err) => match err { - StageError::NotEnoughData => debug!("Not enough data to advance pipeline"), - _ => error!("Error stepping derivation pipeline: {:?}", err), + PipelineErrorKind::Temporary(tmp) => match tmp { + PipelineError::NotEnoughData => debug!("Not enough data to advance pipeline"), + _ => error!("Unexpected temporary error stepping pipeline: {:?}", tmp), + }, + other => error!("Error stepping derivation pipeline: {:?}", other), }, } @@ -225,14 +228,13 @@ where /// Fetch the new L2 tip and L1 origin block info for the given L2 block number. async fn fetch_new_tip(&mut self, l2_tip: u64) -> Result<(BlockInfo, L2BlockInfo)> { - let l2_block = - self.l2_chain_provider.l2_block_info_by_number(l2_tip).await.map_err(|e| eyre!(e))?; + let l2_block = self.l2_chain_provider.l2_block_info_by_number(l2_tip).await?; let l1_origin = self .l1_chain_provider .block_info_by_number(l2_block.l1_origin.number) .await - .map_err(|e| eyre!(e))?; + .map_err(|e| eyre!(e.to_string()))?; Ok((l1_origin, l2_block)) }