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

fix: compile errs due to dep upgrades #97

Merged
merged 1 commit into from
Sep 22, 2024
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
1 change: 0 additions & 1 deletion Cargo.lock

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

3 changes: 0 additions & 3 deletions crates/kona-providers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 2 additions & 0 deletions crates/kona-providers/src/blob_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
30 changes: 14 additions & 16 deletions crates/kona-providers/src/chain_provider.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Chain Provider

use alloc::{collections::vec_deque::VecDeque, sync::Arc};
use alloy_rlp::Decodable;
use hashbrown::HashMap;

use alloy::{
Expand All @@ -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;
Expand Down Expand Up @@ -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<Header> {
async fn header_by_hash(&mut self, hash: B256) -> eyre::Result<Header> {
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<BlockInfo> {
async fn block_info_by_number(&mut self, number: u64) -> eyre::Result<BlockInfo> {
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<Vec<Receipt>> {
async fn receipts_by_hash(&mut self, hash: B256) -> eyre::Result<Vec<Receipt>> {
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<TxEnvelope>)> {
) -> eyre::Result<(BlockInfo, Vec<TxEnvelope>)> {
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))
}
Expand Down
14 changes: 8 additions & 6 deletions crates/rollup/src/driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -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),
},
}

Expand Down Expand Up @@ -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))
}
Expand Down