From f3ffba2becb47a1ad304b89ff7eccec4fe1134ea Mon Sep 17 00:00:00 2001 From: PinelliaC Date: Tue, 18 Feb 2025 14:24:07 +0800 Subject: [PATCH 1/2] fix: deposit_receipt_version should be None --- Cargo.lock | 32 +++++++++---------- bin/host/src/bin/host.rs | 1 - crates/derive/src/sources/eigen_da.rs | 2 -- .../derive/src/stages/channel/channel_bank.rs | 1 - .../src/stages/channel/channel_provider.rs | 1 - .../src/stages/channel/channel_reader.rs | 2 -- crates/executor/src/executor/env.rs | 4 +-- crates/executor/src/executor/mod.rs | 12 +++---- 8 files changed, 22 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dee2a80ed3..d664f92c68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1188,9 +1188,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.29" +version = "4.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acebd8ad879283633b343856142139f2da2317c96b05b4dd6181c61e2480184" +checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d" dependencies = [ "clap_builder", "clap_derive", @@ -1198,9 +1198,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.29" +version = "4.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ba32cbda51c7e1dfd49acc1457ba1a7dec5b64fe360e828acb13ca8dc9c2f9" +checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c" dependencies = [ "anstream", "anstyle", @@ -1692,9 +1692,9 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" @@ -3277,9 +3277,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.70" +version = "0.10.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61cfb4e166a8bb8c9b55c500bc2308550148ece889be90f609377e58140f42c6" +checksum = "5e14130c6a98cd258fdcb0fb6d744152343ff729cbfcb28c656a9d12b999fbcd" dependencies = [ "bitflags 2.8.0", "cfg-if", @@ -3309,9 +3309,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.105" +version = "0.9.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b22d5b84be05a8d6947c7cb71f7c849aa0f112acd4bf51c2a7c1c988ac0a9dc" +checksum = "8bb61ea9811cc39e3c2069f40b8b8e2e70d8569b361f879786cc7ed48b777cdd" dependencies = [ "cc", "libc", @@ -4508,9 +4508,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" dependencies = [ "serde", ] @@ -4730,9 +4730,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.16.0" +version = "3.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" +checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" dependencies = [ "cfg-if", "fastrand", @@ -5172,9 +5172,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced87ca4be083373936a67f8de945faa23b6b42384bd5b64434850802c6dccd0" +checksum = "8c1f41ffb7cf259f1ecc2876861a17e7142e63ead296f671f81f6ae85903e0d6" [[package]] name = "valuable" diff --git a/bin/host/src/bin/host.rs b/bin/host/src/bin/host.rs index 69a84c22c5..c10415b374 100644 --- a/bin/host/src/bin/host.rs +++ b/bin/host/src/bin/host.rs @@ -51,6 +51,5 @@ async fn main() -> Result<()> { } } - info!("Exiting host program."); Ok(()) } diff --git a/crates/derive/src/sources/eigen_da.rs b/crates/derive/src/sources/eigen_da.rs index 139f80cb24..b5fcf57063 100644 --- a/crates/derive/src/sources/eigen_da.rs +++ b/crates/derive/src/sources/eigen_da.rs @@ -106,7 +106,6 @@ where _ => continue, }; let Some(to) = tx_kind else { continue }; - if to != self.batcher_address { number += blob_hashes.map_or(0, |h| h.len() as u64); continue; @@ -150,7 +149,6 @@ where warn!(target: "eigen-da-source", "decoded frame ref contains no quorum IDs"); continue; } - info!(target: "eigen-da", "decoded frame contains frame ref"); let blob_data = self.eigen_da_provider .retrieve_blob_with_commitment( &frame_ref.commitment, frame_ref.blob_length) .await.map_err(|e|EigenDAProviderError::Status(e.to_string()))?; diff --git a/crates/derive/src/stages/channel/channel_bank.rs b/crates/derive/src/stages/channel/channel_bank.rs index 47abb13240..c294428343 100644 --- a/crates/derive/src/stages/channel/channel_bank.rs +++ b/crates/derive/src/stages/channel/channel_bank.rs @@ -189,7 +189,6 @@ where P: NextFrameProvider + OriginAdvancer + OriginProvider + SignalReceiver + Send + Debug, { async fn next_data(&mut self) -> PipelineResult> { - info!("channel_bank next_data"); match self.read() { Err(e) => { if !matches!(e, PipelineErrorKind::Temporary(PipelineError::Eof)) { diff --git a/crates/derive/src/stages/channel/channel_provider.rs b/crates/derive/src/stages/channel/channel_provider.rs index 7cb6cebeb6..f0e866c44b 100644 --- a/crates/derive/src/stages/channel/channel_provider.rs +++ b/crates/derive/src/stages/channel/channel_provider.rs @@ -124,7 +124,6 @@ where P: NextFrameProvider + OriginAdvancer + OriginProvider + SignalReceiver + Send + Debug, { async fn next_data(&mut self) -> PipelineResult> { - info!("channel provider next_data"); self.attempt_update()?; if let Some(channel_assembler) = self.channel_assembler.as_mut() { diff --git a/crates/derive/src/stages/channel/channel_reader.rs b/crates/derive/src/stages/channel/channel_reader.rs index 3e12e40bcf..36f15941ce 100644 --- a/crates/derive/src/stages/channel/channel_reader.rs +++ b/crates/derive/src/stages/channel/channel_reader.rs @@ -116,7 +116,6 @@ where } async fn next_batch(&mut self) -> PipelineResult { - info!("channel_reader next_batch"); if let Err(e) = self.set_batch_reader().await { debug!(target: "channel-reader", "Failed to set batch reader: {:?}", e); self.next_channel(); @@ -200,7 +199,6 @@ impl BatchReader { /// Pulls out the next batch from the reader. pub(crate) fn next_batch(&mut self, cfg: &RollupConfig) -> Option { - info!(target: "batch_reader", "next_batch"); if let Some(data) = self.data.take() { // Peek at the data to determine the compression type. diff --git a/crates/executor/src/executor/env.rs b/crates/executor/src/executor/env.rs index 744481e0f9..f53dca6e92 100644 --- a/crates/executor/src/executor/env.rs +++ b/crates/executor/src/executor/env.rs @@ -1,9 +1,9 @@ //! Environment preparation for the executor. -use super::{ StatelessL2BlockExecutor}; +use super::StatelessL2BlockExecutor; use crate::{constants::FEE_RECIPIENT, ExecutorError, ExecutorResult, TrieDBProvider}; use alloy_consensus::Header; -use alloy_eips::{eip1559::BaseFeeParams}; +use alloy_eips::eip1559::BaseFeeParams; use alloy_eips::eip7840::BlobParams; use alloy_primitives::{TxKind, U256}; use kona_mpt::TrieHinter; diff --git a/crates/executor/src/executor/mod.rs b/crates/executor/src/executor/mod.rs index 6513e32e33..66d8795406 100644 --- a/crates/executor/src/executor/mod.rs +++ b/crates/executor/src/executor/mod.rs @@ -27,7 +27,6 @@ pub use builder::{KonaHandleRegister, StatelessL2BlockExecutorBuilder}; mod env; - /// The [ExecutionArtifacts] holds the produced block header and receipts from the execution of a /// block. #[derive(Default, Debug, Clone, PartialEq, Eq)] @@ -151,8 +150,8 @@ where // The sum of the transaction’s gas limit, Tg, and the gas utilized in this block prior, // must be no greater than the block’s gasLimit. let block_available_gas = (gas_limit - cumulative_gas_used) as u128; - if (transaction.gas_limit() as u128) > block_available_gas && - (is_regolith || !transaction.is_system_transaction()) + if (transaction.gas_limit() as u128) > block_available_gas + && (is_regolith || !transaction.is_system_transaction()) { return Err(ExecutorError::BlockGasLimitExceeded); } @@ -209,12 +208,10 @@ where depositor .as_ref() .map(|depositor| depositor.account_info().unwrap_or_default().nonce), - depositor - .is_some() - .then_some(0) + None, ); // Ensure the receipt is not an EIP-7702 receipt. - if matches!(receipt, OpReceiptEnvelope::Eip7702(_)) { + if matches!(receipt, OpReceiptEnvelope::Eip7702(_)) { panic!( "EIP-7702 receipts are not supported by the fault proof program before Isthmus" ); @@ -328,7 +325,6 @@ where .storage_root } }; - let parent_header = self.trie_db.parent_block_header(); info!( From c5f077223185010927288e4c8780b82ea81aac9a Mon Sep 17 00:00:00 2001 From: PinelliaC Date: Tue, 18 Feb 2025 14:28:00 +0800 Subject: [PATCH 2/2] chore: cargo fmt --- bin/client/src/single.rs | 3 +- bin/host/src/kv/mod.rs | 1 - bin/host/src/single/cfg.rs | 52 ++++---- bin/host/src/single/handler.rs | 3 +- crates/derive/src/attributes/stateful.rs | 16 +-- crates/derive/src/da/da.rs | 8 +- crates/derive/src/da/mod.rs | 2 +- crates/derive/src/errors/da.rs | 3 +- crates/derive/src/errors/mod.rs | 2 +- crates/derive/src/lib.rs | 4 +- crates/derive/src/pipeline/builder.rs | 6 +- crates/derive/src/pipeline/core.rs | 4 +- crates/derive/src/pipeline/mod.rs | 1 - crates/derive/src/sources/eigen_da.rs | 112 ++++++++++-------- crates/derive/src/sources/ethereum.rs | 26 ++-- crates/derive/src/sources/mod.rs | 3 +- crates/derive/src/stages/attributes_queue.rs | 11 +- .../derive/src/stages/batch/batch_provider.rs | 12 +- crates/derive/src/stages/batch/batch_queue.rs | 20 +--- .../derive/src/stages/batch/batch_stream.rs | 12 +- crates/derive/src/stages/batch/mod.rs | 7 +- .../src/stages/channel/channel_assembler.rs | 8 +- .../derive/src/stages/channel/channel_bank.rs | 10 +- .../src/stages/channel/channel_provider.rs | 1 - .../src/stages/channel/channel_reader.rs | 19 +-- crates/derive/src/stages/frame_queue.rs | 29 ++--- crates/derive/src/stages/l1_retrieval.rs | 4 +- crates/derive/src/stages/l1_traversal.rs | 12 +- crates/derive/src/stages/mod.rs | 4 +- .../derive/src/test_utils/attributes_queue.rs | 2 +- .../derive/src/test_utils/batch_provider.rs | 1 - .../src/test_utils/eigen_da_provider.rs | 14 ++- crates/derive/src/test_utils/mod.rs | 2 +- crates/derive/src/traits/attributes.rs | 3 +- crates/derive/src/traits/data_sources.rs | 2 - crates/derive/src/traits/mod.rs | 2 +- crates/driver/src/core.rs | 5 +- crates/driver/src/executor.rs | 1 - crates/driver/src/pipeline.rs | 4 +- crates/eigen-da/src/codec.rs | 6 +- crates/eigen-da/src/config.rs | 4 +- crates/eigen-da/src/eigen_da_proxy.rs | 80 +++++++------ crates/eigen-da/src/grpc/disperser.rs | 2 +- crates/eigen-da/src/grpc/mod.rs | 1 - crates/eigen-da/src/grpc/rlp.rs | 102 ++++++++-------- crates/eigen-da/src/lib.rs | 3 - crates/executor/src/constants.rs | 2 +- crates/executor/src/db/mod.rs | 4 +- crates/executor/src/executor/mod.rs | 4 +- crates/executor/src/lib.rs | 5 +- crates/executor/src/syscalls/eip2935.rs | 2 +- crates/executor/src/syscalls/eip4788.rs | 2 +- crates/executor/src/syscalls/mod.rs | 1 - crates/proof-sdk/proof/src/executor.rs | 14 +-- .../proof/src/l1/eigen_da_provider.rs | 34 ++++-- crates/proof-sdk/proof/src/l1/mod.rs | 2 +- crates/proof-sdk/proof/src/l1/pipeline.rs | 12 +- .../proof-sdk/proof/src/l2/chain_provider.rs | 6 +- crates/proof-sdk/proof/src/sync.rs | 2 +- crates/providers-alloy/src/blobs.rs | 5 +- .../providers-alloy/src/eigen_da_provider.rs | 43 +++---- .../providers-alloy/src/l2_chain_provider.rs | 2 +- 62 files changed, 354 insertions(+), 415 deletions(-) diff --git a/bin/client/src/single.rs b/bin/client/src/single.rs index 45bd6aebe2..b884a406b5 100644 --- a/bin/client/src/single.rs +++ b/bin/client/src/single.rs @@ -7,6 +7,7 @@ use core::fmt::Debug; use kona_driver::{Driver, DriverError}; use kona_executor::{ExecutorError, KonaHandleRegister, TrieDBProvider}; use kona_preimage::{CommsClient, HintWriterClient, PreimageKey, PreimageOracleClient}; +use kona_proof::l1::OracleEigenDaProvider; use kona_proof::{ errors::OracleProviderError, executor::KonaExecutor, @@ -17,7 +18,6 @@ use kona_proof::{ }; use thiserror::Error; use tracing::{error, info}; -use kona_proof::l1::OracleEigenDaProvider; /// An error that can occur when running the fault proof program. #[derive(Error, Debug)] @@ -66,7 +66,6 @@ where let beacon = OracleBlobProvider::new(oracle.clone()); let eigen_da_provider = OracleEigenDaProvider::new(oracle.clone()); - // Fetch the safe head's block header. let safe_head = l2_provider .header_by_hash(safe_head_hash) diff --git a/bin/host/src/kv/mod.rs b/bin/host/src/kv/mod.rs index da35d0f4c7..65f41bce35 100644 --- a/bin/host/src/kv/mod.rs +++ b/bin/host/src/kv/mod.rs @@ -14,7 +14,6 @@ pub use disk::DiskKeyValueStore; mod split; pub use split::SplitKeyValueStore; - /// A type alias for a shared key-value store. pub type SharedKeyValueStore = Arc>; diff --git a/bin/host/src/single/cfg.rs b/bin/host/src/single/cfg.rs index dab6043b5e..59862fe417 100644 --- a/bin/host/src/single/cfg.rs +++ b/bin/host/src/single/cfg.rs @@ -11,6 +11,7 @@ use alloy_primitives::B256; use alloy_provider::RootProvider; use anyhow::{anyhow, Result}; use clap::Parser; +use eigen_da::{EigenDaConfig, EigenDaProxy}; use kona_preimage::{ BidirectionalChannel, Channel, HintReader, HintWriter, OracleReader, OracleServer, }; @@ -20,13 +21,12 @@ use kona_std_fpvm::{FileChannel, FileDescriptor}; use op_alloy_genesis::RollupConfig; use op_alloy_network::Optimism; use serde::Serialize; -use std::{path::PathBuf, sync::Arc}; use std::time::Duration; +use std::{path::PathBuf, sync::Arc}; use tokio::{ sync::RwLock, task::{self, JoinHandle}, }; -use eigen_da::{EigenDaConfig, EigenDaProxy}; /// The host binary CLI application arguments. #[derive(Default, Parser, Serialize, Clone, Debug)] @@ -110,12 +110,11 @@ pub struct SingleChainHost { )] pub rollup_config_path: Option, /// The url of Mantle da indexer. - #[clap(long, - alias = "da-indexer-url", - env)] + #[clap(long, alias = "da-indexer-url", env)] pub mantle_da_indexer_url: Option, /// The url of EigenDA Proxy service - #[clap(long, + #[clap( + long, alias = "proxy-url", conflicts_with = "mantle_da_indexer_url", required_unless_present = "mantle_da_indexer_url", @@ -124,11 +123,7 @@ pub struct SingleChainHost { pub proxy_url: Option, /// EigenDA Disperser RPC URL /// does not need to be configured in derive. - #[clap(long, - alias = "disperse-url", - conflicts_with = "mantle_da_indexer_url", - env - )] + #[clap(long, alias = "disperse-url", conflicts_with = "mantle_da_indexer_url", env)] pub disperse_url: Option, /// The total amount of time that the batcher will spend waiting for EigenDA to disperse a blob /// does not need to be configured in derive. @@ -152,7 +147,8 @@ pub struct SingleChainHost { } fn parse_duration(input: &str) -> Result { - input.parse::() + input + .parse::() .map(Duration::from_secs) .map_err(|e| format!("Failed to parse duration: {}", e)) } @@ -230,10 +226,10 @@ impl SingleChainHost { /// Returns `true` if the host is running in offline mode. pub const fn is_offline(&self) -> bool { - self.l1_node_address.is_none() && - self.l2_node_address.is_none() && - self.l1_beacon_address.is_none() && - self.data_dir.is_some() + self.l1_node_address.is_none() + && self.l2_node_address.is_none() + && self.l1_beacon_address.is_none() + && self.data_dir.is_some() } /// Reads the [RollupConfig] from the file system and returns it as a string. @@ -284,27 +280,25 @@ impl SingleChainHost { let mut eigen_da_config = EigenDaConfig::default(); let mut eigen_proxy_url = "".to_string(); - let mut da_indexer_url = "".to_string(); + let da_indexer_url = "".to_string(); let mantle_da_indexer = false; - // match self.read_rollup_config().ok() { - // Some(rollup_config) => { - // if rollup_config.mantle_da_switch { - // mantle_da_switch = true; - // // da_indexer_url = self.mantle_da_indexer_url.clone().ok_or(anyhow!("Mantle da indexer URL must be set"))?; - // } - // } - // None => {} - // } if da_indexer_url.is_empty() { - eigen_proxy_url = self.proxy_url.clone().ok_or(anyhow!("EigenDA Proxy URL must be set"))?; + eigen_proxy_url = + self.proxy_url.clone().ok_or(anyhow!("EigenDA Proxy URL must be set"))?; } eigen_da_config.proxy_url = eigen_proxy_url; eigen_da_config.retrieve_blob_timeout = self.retrieve_timeout; let eigen_da_provider = EigenDaProxy::new(eigen_da_config); - let mut eigen_da = OnlineEigenDaProvider::new(eigen_da_provider,da_indexer_url, mantle_da_indexer); + let eigen_da = + OnlineEigenDaProvider::new(eigen_da_provider, da_indexer_url, mantle_da_indexer); - Ok(SingleChainProviders { l1: l1_provider, blobs: blob_provider, l2: l2_provider, eigen_da }) + Ok(SingleChainProviders { + l1: l1_provider, + blobs: blob_provider, + l2: l2_provider, + eigen_da, + }) } } diff --git a/bin/host/src/single/handler.rs b/bin/host/src/single/handler.rs index efe6ee3cd9..531f4649a0 100644 --- a/bin/host/src/single/handler.rs +++ b/bin/host/src/single/handler.rs @@ -351,7 +351,6 @@ impl HintHandler for SingleChainHintHandler { HintType::EigenDa => { ensure!(hint.data.len() > 32, "Invalid hint data length"); - let commitment = hint.data.to_vec(); // Fetch the blob from the eigen da provider. let blob = providers @@ -361,7 +360,7 @@ impl HintHandler for SingleChainHintHandler { .map_err(|e| anyhow!("Failed to fetch blob: {e}"))?; let mut kv_lock = kv.write().await; kv_lock.set( - PreimageKey::new(*keccak256(commitment),PreimageKeyType::GlobalGeneric).into(), + PreimageKey::new(*keccak256(commitment), PreimageKeyType::GlobalGeneric).into(), blob.into(), )?; } diff --git a/crates/derive/src/attributes/stateful.rs b/crates/derive/src/attributes/stateful.rs index 3736a72205..bba03f247b 100644 --- a/crates/derive/src/attributes/stateful.rs +++ b/crates/derive/src/attributes/stateful.rs @@ -13,8 +13,8 @@ use alloy_rlp::Encodable; use alloy_rpc_types_engine::PayloadAttributes; use async_trait::async_trait; use op_alloy_genesis::RollupConfig; -use op_alloy_protocol::{decode_deposit, L1BlockInfoTx, DEPOSIT_EVENT_ABI_HASH}; use op_alloy_protocol::L2BlockInfo; +use op_alloy_protocol::{decode_deposit, L1BlockInfoTx, DEPOSIT_EVENT_ABI_HASH}; use op_alloy_rpc_types_engine::OpPayloadAttributes; /// The sequencer fee vault address. @@ -89,10 +89,7 @@ where .await .map_err(|e| PipelineError::BadEncoding(e).crit())?; sys_config - .update_with_receipts( - &receipts, - self.rollup_cfg.l1_system_config_address, - ) + .update_with_receipts(&receipts, self.rollup_cfg.l1_system_config_address) .map_err(|e| PipelineError::SystemConfigUpdate(e).crit())?; l1_header = header; deposit_transactions = deposits; @@ -127,7 +124,6 @@ where )); } - // Build and encode the L1 info transaction for the current payload. let (_, l1_info_tx_envelope) = L1BlockInfoTx::try_new_with_deposit_tx( &self.rollup_cfg, @@ -142,8 +138,7 @@ where let mut encoded_l1_info_tx = Vec::with_capacity(l1_info_tx_envelope.length()); l1_info_tx_envelope.encode_2718(&mut encoded_l1_info_tx); - let mut txs = - Vec::with_capacity(1 + deposit_transactions.len()); + let mut txs = Vec::with_capacity(1 + deposit_transactions.len()); txs.push(encoded_l1_info_tx.into()); txs.extend(deposit_transactions); @@ -210,8 +205,8 @@ mod tests { use alloy_consensus::Header; use alloy_primitives::{Log, LogData, B256, U256, U64}; use op_alloy_genesis::SystemConfig; - use op_alloy_protocol::{DepositError}; use op_alloy_protocol::BlockInfo; + use op_alloy_protocol::DepositError; use proptest::num::u128; fn generate_valid_log() -> Log { @@ -439,5 +434,4 @@ mod tests { assert_eq!(payload, expected); assert_eq!(payload.transactions.unwrap().len(), 1); } - -} \ No newline at end of file +} diff --git a/crates/derive/src/da/da.rs b/crates/derive/src/da/da.rs index 11b7576e19..2e62a335d1 100644 --- a/crates/derive/src/da/da.rs +++ b/crates/derive/src/da/da.rs @@ -1,11 +1,10 @@ +use alloc::boxed::Box; use alloc::vec::Vec; -use core::fmt::Display; use async_trait::async_trait; -use alloc::boxed::Box; +use core::fmt::Display; #[async_trait] pub trait IEigenDA { - /// The error type for the [IEigenDA]. type Error: Display; @@ -14,5 +13,4 @@ pub trait IEigenDA { &self, commitment: &[u8], ) -> Result, Self::Error>; - -} \ No newline at end of file +} diff --git a/crates/derive/src/da/mod.rs b/crates/derive/src/da/mod.rs index 68524e78d6..003e7e65d5 100644 --- a/crates/derive/src/da/mod.rs +++ b/crates/derive/src/da/mod.rs @@ -1,2 +1,2 @@ pub mod da; -pub use da::*; \ No newline at end of file +pub use da::*; diff --git a/crates/derive/src/errors/da.rs b/crates/derive/src/errors/da.rs index aad2873512..c0c8bf31ed 100644 --- a/crates/derive/src/errors/da.rs +++ b/crates/derive/src/errors/da.rs @@ -46,5 +46,4 @@ pub enum EigenDAProviderError { RLPDecodeError(String), #[error("Failed to decode proto buf, error: {0}")] ProtoDecodeError(String), - -} \ No newline at end of file +} diff --git a/crates/derive/src/errors/mod.rs b/crates/derive/src/errors/mod.rs index d7137ca121..2af527fb1b 100644 --- a/crates/derive/src/errors/mod.rs +++ b/crates/derive/src/errors/mod.rs @@ -13,4 +13,4 @@ mod sources; pub use sources::{BlobDecodingError, BlobProviderError}; mod da; -pub use da::{EigenDAProxyError, EigenDAProviderError}; \ No newline at end of file +pub use da::{EigenDAProviderError, EigenDAProxyError}; diff --git a/crates/derive/src/lib.rs b/crates/derive/src/lib.rs index d4d1fc1399..aad0cf6c90 100644 --- a/crates/derive/src/lib.rs +++ b/crates/derive/src/lib.rs @@ -27,7 +27,7 @@ pub mod stages; pub mod traits; pub mod types; +pub mod da; +mod proto; #[cfg(any(test, feature = "test-utils"))] pub mod test_utils; -mod proto; -pub mod da; diff --git a/crates/derive/src/pipeline/builder.rs b/crates/derive/src/pipeline/builder.rs index f529069648..44d2bada3d 100644 --- a/crates/derive/src/pipeline/builder.rs +++ b/crates/derive/src/pipeline/builder.rs @@ -135,10 +135,8 @@ where let frame_queue = FrameQueue::new(l1_retrieval, Arc::clone(&rollup_config)); let channel_provider = ChannelProvider::new(Arc::clone(&rollup_config), frame_queue); let channel_reader = ChannelReader::new(channel_provider, Arc::clone(&rollup_config)); - let batch_stream = - BatchStream::new(channel_reader); - let batch_provider = - BatchProvider::new(rollup_config.clone(), batch_stream); + let batch_stream = BatchStream::new(channel_reader); + let batch_provider = BatchProvider::new(rollup_config.clone(), batch_stream); let attributes = AttributesQueue::new(rollup_config.clone(), batch_provider, attributes_builder); diff --git a/crates/derive/src/pipeline/core.rs b/crates/derive/src/pipeline/core.rs index 8d3e0ef739..c794b8797f 100644 --- a/crates/derive/src/pipeline/core.rs +++ b/crates/derive/src/pipeline/core.rs @@ -91,8 +91,8 @@ where /// The `signal` is contains the signal variant with any necessary parameters. async fn signal(&mut self, signal: Signal) -> PipelineResult<()> { match signal { - mut s @ Signal::Reset(ResetSignal { l2_safe_head, .. }) | - mut s @ Signal::Activation(ActivationSignal { l2_safe_head, .. }) => { + mut s @ Signal::Reset(ResetSignal { l2_safe_head, .. }) + | mut s @ Signal::Activation(ActivationSignal { l2_safe_head, .. }) => { let system_config = self .l2_chain_provider .system_config_by_number( diff --git a/crates/derive/src/pipeline/mod.rs b/crates/derive/src/pipeline/mod.rs index 6cb3bf8465..c67436441a 100644 --- a/crates/derive/src/pipeline/mod.rs +++ b/crates/derive/src/pipeline/mod.rs @@ -1,6 +1,5 @@ //! Module containing the derivation pipeline. - mod builder; pub use builder::PipelineBuilder; diff --git a/crates/derive/src/sources/eigen_da.rs b/crates/derive/src/sources/eigen_da.rs index b5fcf57063..d5247114cb 100644 --- a/crates/derive/src/sources/eigen_da.rs +++ b/crates/derive/src/sources/eigen_da.rs @@ -1,28 +1,29 @@ +use crate::errors::{ + BlobDecodingError, BlobProviderError, EigenDAProviderError, EigenDAProxyError, PipelineError, +}; +use crate::prelude::ChainProvider; +use crate::proto::{calldata_frame, CalldataFrame}; +use crate::sources::BlobData; +use crate::traits::{BlobProvider, DataAvailabilityProvider, EigenDAProvider}; +use crate::types::PipelineResult; +use alloc::boxed::Box; use alloc::format; use alloc::string::ToString; use alloc::vec::Vec; -use core::ops::Deref; use alloy_consensus::{Transaction, TxEip4844Variant, TxEnvelope, TxType}; +use alloy_eips::eip4844::IndexedBlobHash; use alloy_primitives::{hex, Address, Bytes}; use alloy_rlp::Rlp; -use alloy_eips::eip4844::IndexedBlobHash; use async_trait::async_trait; +use core::ops::Deref; use op_alloy_protocol::BlockInfo; +use prost::Message; use rlp::{decode, Decodable, DecoderError}; use tracing::{error, info, warn}; -use crate::errors::{BlobDecodingError, BlobProviderError, EigenDAProviderError, EigenDAProxyError, PipelineError}; -use crate::types::PipelineResult; -use crate::prelude::ChainProvider; -use crate::proto::{calldata_frame, CalldataFrame}; -use crate::sources::{BlobData}; -use crate::traits::{DataAvailabilityProvider, BlobProvider, EigenDAProvider}; -use prost::Message; -use alloc::boxed::Box; /// Useful to dinstiguish between plain calldata and alt-da blob refs /// Support seamless migration of existing rollups using ETH DA -pub const DERIVATION_VERSION_EIGEN_DA:u8 = 0xed; - +pub const DERIVATION_VERSION_EIGEN_DA: u8 = 0xed; pub struct VecOfBytes(pub Vec>); @@ -33,7 +34,6 @@ impl Decodable for VecOfBytes { } } - /// A data iterator that reads from eigen da. #[derive(Debug, Clone)] pub struct EigenDaSource @@ -56,7 +56,6 @@ where pub data: Vec, /// Whether the source is open. pub open: bool, - } impl EigenDaSource @@ -84,8 +83,11 @@ where } } - async fn data_from_eigen_da(&mut self, txs: Vec) -> Result<(Vec, Vec), EigenDAProviderError> { - let mut out:Vec = Vec::new(); + async fn data_from_eigen_da( + &mut self, + txs: Vec, + ) -> Result<(Vec, Vec), EigenDAProviderError> { + let mut out: Vec = Vec::new(); let mut hashes = Vec::new(); let mut number: u64 = 0; @@ -116,7 +118,7 @@ where } if self.eigen_da_provider.da_indexer_enable() { error!("eigen_da_provider.da_indexer_enable() not implemented"); - break + break; } if calldata.len() == 0 { @@ -138,35 +140,37 @@ where if calldata[0] == DERIVATION_VERSION_EIGEN_DA { let blob_data = calldata.slice(1..); let calldata_frame: CalldataFrame = CalldataFrame::decode(blob_data) - .map_err(|e|EigenDAProviderError::ProtoDecodeError(e.to_string()))?; + .map_err(|e| EigenDAProviderError::ProtoDecodeError(e.to_string()))?; if let Some(value) = calldata_frame.value { match value { - calldata_frame::Value::Frame(frame) => { - out.push(Bytes::from(frame)) - } + calldata_frame::Value::Frame(frame) => out.push(Bytes::from(frame)), calldata_frame::Value::FrameRef(frame_ref) => { if frame_ref.quorum_ids.len() == 0 { warn!(target: "eigen-da-source", "decoded frame ref contains no quorum IDs"); continue; } - let blob_data = self.eigen_da_provider - .retrieve_blob_with_commitment( &frame_ref.commitment, frame_ref.blob_length) - .await.map_err(|e|EigenDAProviderError::Status(e.to_string()))?; + let blob_data = self + .eigen_da_provider + .retrieve_blob_with_commitment( + &frame_ref.commitment, + frame_ref.blob_length, + ) + .await + .map_err(|e| EigenDAProviderError::Status(e.to_string()))?; let blobs = &blob_data[..frame_ref.blob_length as usize]; - let blob_data:VecOfBytes = decode(blobs).map_err(|e|EigenDAProviderError::RLPDecodeError(e.to_string()))?; + let blob_data: VecOfBytes = decode(blobs) + .map_err(|e| EigenDAProviderError::RLPDecodeError(e.to_string()))?; for blob in blob_data.0 { out.push(Bytes::from(blob)); } } } - } } } - Ok((out,hashes)) + Ok((out, hashes)) } - async fn load_blobs(&mut self, block_ref: &BlockInfo) -> Result<(), EigenDAProviderError> { if self.open { return Ok(()); @@ -182,16 +186,21 @@ where let blobs = self.blob_provider.get_blobs(block_ref, &blob_hashes).await.map_err(|e| { warn!(target: "eigen-da-source", "Failed to fetch blobs: {e}"); - EigenDAProviderError::Backend(BlobProviderError::Backend(e.to_string()).to_string()) + EigenDAProviderError::Backend( + BlobProviderError::Backend(e.to_string()).to_string(), + ) })?; let mut whole_blob_data = Vec::new(); for blob in blobs { if blob.is_empty() { - return Err(EigenDAProviderError::RLPDecodeError(BlobDecodingError::MissingData.to_string())); + return Err(EigenDAProviderError::RLPDecodeError( + BlobDecodingError::MissingData.to_string(), + )); } whole_blob_data.extend(blob.to_vec().clone()); } - let rlp_blob:VecOfBytes = decode(&whole_blob_data).map_err(|e|EigenDAProviderError::RetrieveFramesFromDaIndexer(e.to_string()))?; + let rlp_blob: VecOfBytes = decode(&whole_blob_data) + .map_err(|e| EigenDAProviderError::RetrieveFramesFromDaIndexer(e.to_string()))?; for blob in rlp_blob.0 { blob_data.push(Bytes::from(blob)); } @@ -209,7 +218,6 @@ where Ok(self.data.remove(0)) } - } #[async_trait] @@ -229,9 +237,10 @@ where Err(e) => { return Err(PipelineError::Provider(format!( "Failed to load eigen_da blobs from stream: {}, err: {}", - block_ref.hash,e.to_string() + block_ref.hash, + e.to_string() )) - .temp()); + .temp()); } } @@ -240,8 +249,7 @@ where Err(e) => return e, }; - Ok(next_data) - + Ok(next_data) } fn clear(&mut self) { @@ -250,19 +258,16 @@ where } } - - - #[cfg(test)] pub(crate) mod tests { + use super::*; + use crate::test_utils::TestEigenDaProvider; use alloc::vec; use alloy_primitives::keccak256; use alloy_rlp::Decodable; - use crate::test_utils::TestEigenDaProvider; - use super::*; #[tokio::test] - async fn test_calldata_frame_decode() { + async fn test_calldata_frame_decode() { let txs = valid_eigen_da_txs(); let mut eigen_da_provider = TestEigenDaProvider::default(); for tx in txs { @@ -281,15 +286,13 @@ pub(crate) mod tests { }, _ => continue, }; - assert_eq!(calldata[0],DERIVATION_VERSION_EIGEN_DA); + assert_eq!(calldata[0], DERIVATION_VERSION_EIGEN_DA); let blob_data = calldata.slice(1..); let calldata_frame: CalldataFrame = CalldataFrame::decode(blob_data).unwrap(); if let Some(value) = calldata_frame.value { match value { - calldata_frame::Value::Frame(frame) => { - - } + calldata_frame::Value::Frame(frame) => {} calldata_frame::Value::FrameRef(frame_ref) => { if frame_ref.quorum_ids.len() == 0 { warn!(target: "eigen-da-source", "decoded frame ref contains no quorum IDs"); @@ -298,13 +301,20 @@ pub(crate) mod tests { let commitment = hex::encode(frame_ref.commitment.as_slice()).to_string(); assert_eq!(commitment, "010000f901d8f852f842a00dbbd22149b419a9a751c25065b58745f4216dc3ae4e9ad583306c395387b6a3a02673dfa25dd3095246eeffb639d3e11108a1ba75dd29b86c3a4200ed00210e4e820200cac480213701c401213710f90181830148ae81a5f873eba0c42bcd27bcd22ba55c4189a25d362343838cb75f57979baa0686ec5381a944c3820001826362832a79cba07263089b84cbb2963e4f50a930243c081ab14b01c0c92d57c3029590bd9dfc9200832a7a20a05419bc29ac025512311c14f23d9613e408448e47bb31f71614e1f82b6c63966cb9010074b13a3acaba35d3749063c19806c9a2f2004b318d55edd6cb5129d958807ea7ac09584a2c6ea029ed34c72f849862e4189928e90931e07093209016f5fc70a6c4a8c3237c25c4f236bb25c105fd7dbd6e4a00153c69c0757d8cbf02f966167ccae243412c20de1c3a38a50818dc7f9f3e02dcb3bc4e54800f2224b8c1eaa9955e41792fa0e401f2814ee209331126149c630c34e1b8e2f804955582022676e232d24d7784b496fc997d98db2849b1bfa8443b362723fc603da8de11704a1ef50414e11234496cfac67aebdd2faa24840ffe7f04506652b8a11a534b024a40bc7e99fee042336f425eb16e40e4267593415860204c9069723dbaca8cf2e596dc820001".to_string()); - let blob_data = eigen_da_provider.retrieve_blob_with_commitment(&frame_ref.commitment, frame_ref.blob_length) - .await.map_err(|e|EigenDAProviderError::Status(e.to_string())).unwrap(); + let blob_data = eigen_da_provider + .retrieve_blob_with_commitment( + &frame_ref.commitment, + frame_ref.blob_length, + ) + .await + .map_err(|e| EigenDAProviderError::Status(e.to_string())) + .unwrap(); let blobs = &blob_data[..frame_ref.blob_length as usize]; - let blob_data:VecOfBytes = decode(blobs).map_err(|e|EigenDAProviderError::RLPDecodeError(e.to_string())).unwrap(); + let blob_data: VecOfBytes = decode(blobs) + .map_err(|e| EigenDAProviderError::RLPDecodeError(e.to_string())) + .unwrap(); } } - } } } @@ -316,4 +326,4 @@ pub(crate) mod tests { let eoa = TxEnvelope::decode(&mut raw_tx.as_slice()).unwrap(); vec![eoa] } -} \ No newline at end of file +} diff --git a/crates/derive/src/sources/ethereum.rs b/crates/derive/src/sources/ethereum.rs index 83eb8be819..d72ed4b6b3 100644 --- a/crates/derive/src/sources/ethereum.rs +++ b/crates/derive/src/sources/ethereum.rs @@ -1,17 +1,17 @@ //! Contains the [EthereumDataSource], which is a concrete implementation of the //! [DataAvailabilityProvider] trait for the Ethereum protocol. +use crate::sources::eigen_da::EigenDaSource; use crate::{ - types::PipelineResult, sources::{BlobSource, CalldataSource}, - traits::{BlobProvider, ChainProvider, EigenDAProvider, DataAvailabilityProvider}, + traits::{BlobProvider, ChainProvider, DataAvailabilityProvider, EigenDAProvider}, + types::PipelineResult, }; use alloc::{boxed::Box, fmt::Debug}; use alloy_primitives::{Address, Bytes}; use async_trait::async_trait; use op_alloy_genesis::RollupConfig; use op_alloy_protocol::BlockInfo; -use crate::sources::eigen_da::EigenDaSource; /// A factory for creating an Ethereum data source provider. #[derive(Debug, Clone)] @@ -27,7 +27,6 @@ where pub eigen_da_source: EigenDaSource, /// Mantle da switch pub mantle_da_switch: bool, - } impl EthereumDataSource @@ -51,7 +50,13 @@ where cfg.genesis.system_config.as_ref().map(|sc| sc.batcher_address).unwrap_or_default(); Self { calldata_source: CalldataSource::new(provider.clone(), cfg.batch_inbox_address, signer), - eigen_da_source: EigenDaSource::new(provider,blobs,eigen_da_provider,cfg.batch_inbox_address,signer), + eigen_da_source: EigenDaSource::new( + provider, + blobs, + eigen_da_provider, + cfg.batch_inbox_address, + signer, + ), mantle_da_switch: cfg.mantle_da_switch, } } @@ -67,9 +72,8 @@ where type Item = Bytes; async fn next(&mut self, block_ref: &BlockInfo) -> PipelineResult { - if self.mantle_da_switch { - self.eigen_da_source.next(block_ref).await + self.eigen_da_source.next(block_ref).await } else { self.calldata_source.next(block_ref).await } @@ -84,6 +88,7 @@ where #[cfg(test)] mod tests { use super::*; + use crate::test_utils::TestEigenDaProvider; use crate::{ sources::BlobData, test_utils::{TestBlobProvider, TestChainProvider}, @@ -93,7 +98,6 @@ mod tests { use alloy_primitives::{address, Address}; use op_alloy_genesis::{RollupConfig, SystemConfig}; use op_alloy_protocol::BlockInfo; - use crate::test_utils::TestEigenDaProvider; fn default_test_blob_source() -> BlobSource { let chain_provider = TestChainProvider::default(); @@ -112,10 +116,10 @@ mod tests { let mut calldata = CalldataSource::new(chain.clone(), Address::ZERO, Address::ZERO); calldata.calldata.insert(0, Default::default()); calldata.open = true; - let mut eigen = EigenDaSource::new(chain,blob,eigen_da,Address::ZERO,Address::ZERO); + let mut eigen = EigenDaSource::new(chain, blob, eigen_da, Address::ZERO, Address::ZERO); eigen.data = vec![Default::default()]; eigen.open = true; - let mut data_source = EthereumDataSource::new( calldata, eigen, &cfg); + let mut data_source = EthereumDataSource::new(calldata, eigen, &cfg); data_source.clear(); assert!(data_source.eigen_da_source.data.is_empty()); @@ -124,7 +128,6 @@ mod tests { assert!(!data_source.calldata_source.open); } - #[tokio::test] async fn test_open_ethereum_calldata_source_pre_ecotone() { let mut chain = TestChainProvider::default(); @@ -148,4 +151,3 @@ mod tests { assert_eq!(calldata_batch.len(), 119823); } } - diff --git a/crates/derive/src/sources/mod.rs b/crates/derive/src/sources/mod.rs index 5d445f730a..377111a802 100644 --- a/crates/derive/src/sources/mod.rs +++ b/crates/derive/src/sources/mod.rs @@ -14,7 +14,7 @@ mod ethereum; pub use ethereum::EthereumDataSource; mod blobs; -pub use blobs::{BlobSource}; +pub use blobs::BlobSource; mod calldata; pub use calldata::CalldataSource; @@ -22,4 +22,3 @@ pub use calldata::CalldataSource; mod eigen_da; pub use eigen_da::EigenDaSource; - diff --git a/crates/derive/src/stages/attributes_queue.rs b/crates/derive/src/stages/attributes_queue.rs index ceb933fc42..ab7bac176c 100644 --- a/crates/derive/src/stages/attributes_queue.rs +++ b/crates/derive/src/stages/attributes_queue.rs @@ -12,8 +12,8 @@ use alloc::{boxed::Box, sync::Arc}; use async_trait::async_trait; use core::fmt::Debug; use op_alloy_genesis::RollupConfig; -use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use op_alloy_protocol::SingleBatch; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use op_alloy_rpc_types_engine::{OpAttributesWithParent, OpPayloadAttributes}; /// [AttributesQueue] accepts batches from the [BatchQueue] stage @@ -83,8 +83,7 @@ where return Err(e); } }; - let populated_attributes = - OpAttributesWithParent { attributes, parent }; + let populated_attributes = OpAttributesWithParent { attributes, parent }; // Clear out the local state once payload attributes are prepared. self.batch = None; @@ -372,10 +371,8 @@ mod tests { // It should also reset the last in span flag and clear the batch. let attributes = aq.next_attributes(L2BlockInfo::default()).await.unwrap(); pa.no_tx_pool = Some(true); - let populated_attributes = OpAttributesWithParent { - attributes: pa, - parent: L2BlockInfo::default(), - }; + let populated_attributes = + OpAttributesWithParent { attributes: pa, parent: L2BlockInfo::default() }; assert_eq!(attributes, populated_attributes); assert!(aq.batch.is_none()); } diff --git a/crates/derive/src/stages/batch/batch_provider.rs b/crates/derive/src/stages/batch/batch_provider.rs index b12968aea0..b851a07006 100644 --- a/crates/derive/src/stages/batch/batch_provider.rs +++ b/crates/derive/src/stages/batch/batch_provider.rs @@ -3,7 +3,7 @@ use super::NextBatchProvider; use crate::{ errors::PipelineError, - stages::{BatchQueue}, + stages::BatchQueue, traits::{AttributesProvider, L2ChainProvider, OriginAdvancer, OriginProvider, SignalReceiver}, types::{PipelineResult, Signal}, }; @@ -55,8 +55,7 @@ where if let Some(prev) = self.prev.take() { // On the first call to `attempt_update`, we need to determine the active stage to // initialize the mux with. - self.batch_queue = - Some(BatchQueue::new(self.cfg.clone(), prev)); + self.batch_queue = Some(BatchQueue::new(self.cfg.clone(), prev)); } Ok(()) } @@ -98,7 +97,7 @@ where async fn signal(&mut self, signal: Signal) -> PipelineResult<()> { self.attempt_update()?; - if let Some(batch_queue) = self.batch_queue.as_mut() { + if let Some(batch_queue) = self.batch_queue.as_mut() { batch_queue.signal(signal).await } else { Err(PipelineError::NotEnoughData.temp()) @@ -111,7 +110,6 @@ impl

AttributesProvider for BatchProvider

where P: NextBatchProvider + OriginAdvancer + OriginProvider + SignalReceiver + Debug + Send, { - async fn next_batch(&mut self, parent: L2BlockInfo) -> PipelineResult { self.attempt_update()?; @@ -139,7 +137,7 @@ mod test { fn test_batch_provider_validator_active() { let provider = TestNextBatchProvider::new(vec![]); let l2_provider = TestL2ChainProvider::default(); - let cfg = Arc::new(RollupConfig { ..Default::default() }); + let cfg = Arc::new(RollupConfig { ..Default::default() }); let mut batch_provider = BatchProvider::new(cfg, provider); assert!(batch_provider.attempt_update().is_ok()); @@ -190,7 +188,6 @@ mod test { batch_provider.attempt_update().unwrap(); - // Update the L1 origin to Holocene activation. if let Some(ref mut stage) = batch_provider.batch_queue { stage.prev.origin = Some(BlockInfo { number: 1, timestamp: 2, ..Default::default() }); @@ -237,6 +234,5 @@ mod test { // Reset the batch provider. batch_provider.signal(ResetSignal::default().signal()).await.unwrap(); - } } diff --git a/crates/derive/src/stages/batch/batch_queue.rs b/crates/derive/src/stages/batch/batch_queue.rs index 96ee2b6f0d..a6ca681fb4 100644 --- a/crates/derive/src/stages/batch/batch_queue.rs +++ b/crates/derive/src/stages/batch/batch_queue.rs @@ -57,16 +57,9 @@ where /// Creates a new [BatchQueue] stage. #[allow(clippy::missing_const_for_fn)] pub fn new(cfg: Arc, prev: P) -> Self { - Self { - cfg, - prev, - origin: None, - l1_blocks: Default::default(), - batches: Default::default(), - } + Self { cfg, prev, origin: None, l1_blocks: Default::default(), batches: Default::default() } } - /// Derives the next batch to apply on top of the current L2 safe head. /// Follows the validity rules imposed on consecutive batches. /// Based on currently available buffered batch and L1 origin information. @@ -109,8 +102,7 @@ where let mut remaining = Vec::new(); for i in 0..self.batches.len() { let batch = &self.batches[i]; - let validity = - batch.check_batch(&self.cfg, &self.l1_blocks, parent).await; + let validity = batch.check_batch(&self.cfg, &self.l1_blocks, parent).await; match validity { BatchValidity::Future => { self.prev.flush(); @@ -206,8 +198,7 @@ where let origin = self.origin.ok_or(PipelineError::MissingOrigin.crit())?; let data = BatchWithInclusionBlock { inclusion_block: origin, batch }; // If we drop the batch, validation logs the drop reason with WARN level. - let validity = - data.check_batch(&self.cfg, &self.l1_blocks, parent).await; + let validity = data.check_batch(&self.cfg, &self.l1_blocks, parent).await; // Post-Holocene, future batches are dropped due to prevent gaps. let drop = validity.is_drop(); if drop { @@ -240,8 +231,6 @@ where /// Returns the next valid batch upon the given safe head. /// Also returns the boolean that indicates if the batch is the last block in the batch. async fn next_batch(&mut self, parent: L2BlockInfo) -> PipelineResult { - - // If the epoch is advanced, update the l1 blocks. // Advancing epoch must be done after the pipeline successfully applies the entire span // batch to the chain. @@ -399,7 +388,6 @@ mod tests { BatchReader::new(bytes, MAX_RLP_BYTES_PER_CHANNEL_BEDROCK as usize) } - #[tokio::test] async fn test_batch_queue_flush() { let cfg = Arc::new(RollupConfig::default()); @@ -417,7 +405,6 @@ mod tests { assert!(!bq.l1_blocks.is_empty()); } - #[tokio::test] async fn test_add_batch_drop() { // Construct a single batch with BatchValidity::Drop. @@ -639,7 +626,6 @@ mod tests { assert!(logs[0].contains(warn_str)); } - #[tokio::test] async fn test_next_batch_clear_next_spans() { let mut reader = new_batch_reader(); diff --git a/crates/derive/src/stages/batch/batch_stream.rs b/crates/derive/src/stages/batch/batch_stream.rs index 4baf56bf29..d0d87306b1 100644 --- a/crates/derive/src/stages/batch/batch_stream.rs +++ b/crates/derive/src/stages/batch/batch_stream.rs @@ -40,7 +40,6 @@ where { /// The previous stage in the derivation pipeline. prev: P, - } impl

BatchStream

@@ -51,7 +50,6 @@ where pub const fn new(prev: P) -> Self { Self { prev } } - } #[async_trait] @@ -59,14 +57,11 @@ impl

NextBatchProvider for BatchStream

where P: BatchStreamProvider + OriginAdvancer + OriginProvider + SignalReceiver + Send + Debug, { - fn flush(&mut self) { // mantle have no holocene version } - async fn next_batch( - &mut self, - ) -> PipelineResult { + async fn next_batch(&mut self) -> PipelineResult { self.prev.next_batch().await } } @@ -109,10 +104,9 @@ mod test { types::ResetSignal, }; use alloc::vec; - use op_alloy_protocol::{SingleBatch}; + use op_alloy_protocol::SingleBatch; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; - #[tokio::test] async fn test_batch_stream_reset() { let config = Arc::new(RollupConfig { ..RollupConfig::default() }); @@ -133,7 +127,6 @@ mod test { assert!(stream.prev.flushed); } - #[tokio::test] async fn test_single_batch_pass_through() { let data = vec![Ok(Batch::Single(SingleBatch::default()))]; @@ -141,7 +134,6 @@ mod test { let prev = TestBatchStreamProvider::new(data); let mut stream = BatchStream::new(prev); - // The next batch should be passed through to the [BatchQueue] stage. let batch = stream.next_batch().await.unwrap(); assert!(matches!(batch, Batch::Single(_))); diff --git a/crates/derive/src/stages/batch/mod.rs b/crates/derive/src/stages/batch/mod.rs index a8e2334d03..4406782918 100644 --- a/crates/derive/src/stages/batch/mod.rs +++ b/crates/derive/src/stages/batch/mod.rs @@ -22,8 +22,6 @@ pub use batch_stream::{BatchStream, BatchStreamProvider}; mod batch_queue; pub use batch_queue::BatchQueue; - - mod batch_provider; pub use batch_provider::BatchProvider; @@ -37,10 +35,7 @@ pub trait NextBatchProvider { /// /// [ChannelReader]: crate::stages::ChannelReader /// [PipelineError::Eof]: crate::errors::PipelineError::Eof - async fn next_batch( - &mut self, - ) -> PipelineResult; - + async fn next_batch(&mut self) -> PipelineResult; /// Allows the stage to flush the buffer in the [crate::stages::BatchStream] /// if an invalid single batch is found. Pre-holocene hardfork, this will be a no-op. diff --git a/crates/derive/src/stages/channel/channel_assembler.rs b/crates/derive/src/stages/channel/channel_assembler.rs index fc9261e20c..9412d68ff4 100644 --- a/crates/derive/src/stages/channel/channel_assembler.rs +++ b/crates/derive/src/stages/channel/channel_assembler.rs @@ -10,9 +10,7 @@ use alloc::{boxed::Box, sync::Arc}; use alloy_primitives::{hex, Bytes}; use async_trait::async_trait; use core::fmt::Debug; -use op_alloy_genesis::{ - RollupConfig, MAX_RLP_BYTES_PER_CHANNEL_BEDROCK, -}; +use op_alloy_genesis::{RollupConfig, MAX_RLP_BYTES_PER_CHANNEL_BEDROCK}; use op_alloy_protocol::{BlockInfo, Channel}; /// The [ChannelAssembler] stage is responsible for assembling the [Frame]s from the [FrameQueue] @@ -187,9 +185,7 @@ mod test { test_utils::{CollectingLayer, TestNextFrameProvider, TraceStorage}, }; use alloc::{sync::Arc, vec}; - use op_alloy_genesis::{ - RollupConfig, MAX_RLP_BYTES_PER_CHANNEL_BEDROCK, - }; + use op_alloy_genesis::{RollupConfig, MAX_RLP_BYTES_PER_CHANNEL_BEDROCK}; use op_alloy_protocol::BlockInfo; use tracing::Level; use tracing_subscriber::layer::SubscriberExt; diff --git a/crates/derive/src/stages/channel/channel_bank.rs b/crates/derive/src/stages/channel/channel_bank.rs index c294428343..6990bd16d2 100644 --- a/crates/derive/src/stages/channel/channel_bank.rs +++ b/crates/derive/src/stages/channel/channel_bank.rs @@ -93,8 +93,8 @@ where }; // Check if the channel is not timed out. If it has, ignore the frame. - if current_channel.open_block_number() + self.cfg.channel_timeout(origin.timestamp) < - origin.number + if current_channel.open_block_number() + self.cfg.channel_timeout(origin.timestamp) + < origin.number { warn!( target: "channel-bank", @@ -159,8 +159,8 @@ where self.channels.get(&channel_id).ok_or(PipelineError::ChannelProviderEmpty.crit())?; let origin = self.origin().ok_or(PipelineError::MissingOrigin.crit())?; - let timed_out = channel.open_block_number() + self.cfg.channel_timeout(origin.timestamp) < - origin.number; + let timed_out = channel.open_block_number() + self.cfg.channel_timeout(origin.timestamp) + < origin.number; if timed_out || !channel.is_ready() { return Err(PipelineError::Eof.temp()); } @@ -241,7 +241,7 @@ mod tests { types::ResetSignal, }; use alloc::{vec, vec::Vec}; - use op_alloy_genesis::{ MANTLE_MAINNET_CONFIG }; + use op_alloy_genesis::MANTLE_MAINNET_CONFIG; use tracing::Level; use tracing_subscriber::layer::SubscriberExt; diff --git a/crates/derive/src/stages/channel/channel_provider.rs b/crates/derive/src/stages/channel/channel_provider.rs index f0e866c44b..94dcbe6166 100644 --- a/crates/derive/src/stages/channel/channel_provider.rs +++ b/crates/derive/src/stages/channel/channel_provider.rs @@ -59,7 +59,6 @@ where // On the first call to `attempt_update`, we need to determine the active stage to // initialize the mux with. self.channel_bank = Some(ChannelBank::new(self.cfg.clone(), prev)); - } Ok(()) } diff --git a/crates/derive/src/stages/channel/channel_reader.rs b/crates/derive/src/stages/channel/channel_reader.rs index 36f15941ce..05163ed239 100644 --- a/crates/derive/src/stages/channel/channel_reader.rs +++ b/crates/derive/src/stages/channel/channel_reader.rs @@ -12,9 +12,7 @@ use alloy_rlp::Decodable; use async_trait::async_trait; use core::fmt::Debug; use miniz_oxide::inflate::decompress_to_vec_zlib; -use op_alloy_genesis::{ - RollupConfig, MAX_RLP_BYTES_PER_CHANNEL_BEDROCK, -}; +use op_alloy_genesis::{RollupConfig, MAX_RLP_BYTES_PER_CHANNEL_BEDROCK}; use op_alloy_protocol::{Batch, BlockInfo}; use tracing::{debug, error, info, warn}; @@ -199,7 +197,6 @@ impl BatchReader { /// Pulls out the next batch from the reader. pub(crate) fn next_batch(&mut self, cfg: &RollupConfig) -> Option { - if let Some(data) = self.data.take() { // Peek at the data to determine the compression type. if data.is_empty() { @@ -207,14 +204,12 @@ impl BatchReader { return None; } - self.decompressed = decompress_to_vec_zlib(&data).ok()?; // Check the size of the decompressed channel RLP. if self.decompressed.len() > self.max_rlp_bytes_per_channel { return None; } - } // Decompress and RLP decode the batch data, before finally decoding the batch itself. @@ -265,10 +260,8 @@ mod test { async fn test_flush_channel_reader() { let mock = TestChannelReaderProvider::new(vec![Ok(Some(new_compressed_batch_data()))]); let mut reader = ChannelReader::new(mock, Arc::new(RollupConfig::default())); - reader.next_batch = Some(BatchReader::new( - new_compressed_batch_data(), - MAX_RLP_BYTES_PER_CHANNEL as usize, - )); + reader.next_batch = + Some(BatchReader::new(new_compressed_batch_data(), MAX_RLP_BYTES_PER_CHANNEL as usize)); reader.signal(Signal::FlushChannel).await.unwrap(); assert!(reader.next_batch.is_none()); } @@ -277,10 +270,8 @@ mod test { async fn test_reset_channel_reader() { let mock = TestChannelReaderProvider::new(vec![Ok(None)]); let mut reader = ChannelReader::new(mock, Arc::new(RollupConfig::default())); - reader.next_batch = Some(BatchReader::new( - vec![0x00, 0x01, 0x02], - MAX_RLP_BYTES_PER_CHANNEL as usize, - )); + reader.next_batch = + Some(BatchReader::new(vec![0x00, 0x01, 0x02], MAX_RLP_BYTES_PER_CHANNEL as usize)); assert!(!reader.prev.reset); reader.signal(ResetSignal::default().signal()).await.unwrap(); assert!(reader.next_batch.is_none()); diff --git a/crates/derive/src/stages/frame_queue.rs b/crates/derive/src/stages/frame_queue.rs index 50bc7e4a3a..8e7bd4a096 100644 --- a/crates/derive/src/stages/frame_queue.rs +++ b/crates/derive/src/stages/frame_queue.rs @@ -53,9 +53,6 @@ where Self { prev, queue: VecDeque::new(), rollup_config: cfg } } - - - /// Loads more frames into the [FrameQueue]. pub async fn load_frames(&mut self) -> PipelineResult<()> { // Skip loading frames if the queue is not empty. @@ -199,7 +196,7 @@ pub(crate) mod tests { .with_origin(BlockInfo::default()) .with_frames(&frames) .build(); - + assert.next_frames().await; } @@ -215,7 +212,7 @@ pub(crate) mod tests { .with_origin(BlockInfo::default()) .with_frames(&frames) .build(); - + assert.next_frames().await; } @@ -226,7 +223,7 @@ pub(crate) mod tests { .with_expected_frames(&frames) .with_frames(&frames) .build(); - + assert.missing_origin().await; } @@ -243,7 +240,7 @@ pub(crate) mod tests { .with_expected_frames(&frames) .with_frames(&frames) .build(); - + assert.next_frames().await; } @@ -256,7 +253,7 @@ pub(crate) mod tests { .with_expected_frames(&frames) .with_frames(&frames) .build(); - + assert.next_frames().await; } @@ -278,7 +275,7 @@ pub(crate) mod tests { .with_expected_frames(&[&frames[0..3], &frames[4..]].concat()) .with_frames(&frames) .build(); - + assert.next_frames().await; } @@ -297,7 +294,7 @@ pub(crate) mod tests { .with_expected_frames(&frames[0..2]) .with_frames(&frames) .build(); - + assert.next_frames().await; } @@ -319,7 +316,7 @@ pub(crate) mod tests { .with_expected_frames(&frames[4..]) .with_frames(&frames) .build(); - + assert.next_frames().await; } @@ -344,7 +341,7 @@ pub(crate) mod tests { .with_expected_frames(&[&frames[0..4], &frames[6..]].concat()) .with_frames(&frames) .build(); - + assert.next_frames().await; } @@ -366,7 +363,7 @@ pub(crate) mod tests { .with_expected_frames(&frames[0..4]) .with_frames(&frames) .build(); - + assert.next_frames().await; } @@ -389,7 +386,7 @@ pub(crate) mod tests { .with_expected_frames(&[&frames[0..2], &frames[4..]].concat()) .with_frames(&frames) .build(); - + assert.next_frames().await; } @@ -412,7 +409,7 @@ pub(crate) mod tests { .with_expected_frames(&frames[4..]) .with_frames(&frames) .build(); - + assert.next_frames().await; } @@ -435,7 +432,7 @@ pub(crate) mod tests { .with_expected_frames(&[&frames[1..2], &frames[3..]].concat()) .with_frames(&frames) .build(); - + assert.next_frames().await; } } diff --git a/crates/derive/src/stages/l1_retrieval.rs b/crates/derive/src/stages/l1_retrieval.rs index 9e68c53958..2619c93752 100644 --- a/crates/derive/src/stages/l1_retrieval.rs +++ b/crates/derive/src/stages/l1_retrieval.rs @@ -124,8 +124,8 @@ where async fn signal(&mut self, signal: Signal) -> PipelineResult<()> { self.prev.signal(signal).await?; match signal { - Signal::Reset(ResetSignal { l1_origin, .. }) | - Signal::Activation(ActivationSignal { l1_origin, .. }) => { + Signal::Reset(ResetSignal { l1_origin, .. }) + | Signal::Activation(ActivationSignal { l1_origin, .. }) => { self.next = Some(l1_origin); } _ => {} diff --git a/crates/derive/src/stages/l1_traversal.rs b/crates/derive/src/stages/l1_traversal.rs index 0c19c769d2..0b82fd6012 100644 --- a/crates/derive/src/stages/l1_traversal.rs +++ b/crates/derive/src/stages/l1_traversal.rs @@ -89,10 +89,10 @@ impl OriginAdvancer for L1Traversal { let receipts = self.data_source.receipts_by_hash(next_l1_origin.hash).await.map_err(Into::into)?; - if let Err(e) = self.system_config.update_with_receipts( - receipts.as_slice(), - self.rollup_config.l1_system_config_address, - ) { + if let Err(e) = self + .system_config + .update_with_receipts(receipts.as_slice(), self.rollup_config.l1_system_config_address) + { return Err(PipelineError::SystemConfigUpdate(e).crit()); } @@ -114,8 +114,8 @@ impl OriginProvider for L1Traversal { impl SignalReceiver for L1Traversal { async fn signal(&mut self, signal: Signal) -> PipelineResult<()> { match signal { - Signal::Reset(ResetSignal { l1_origin, system_config, .. }) | - Signal::Activation(ActivationSignal { l1_origin, system_config, .. }) => { + Signal::Reset(ResetSignal { l1_origin, system_config, .. }) + | Signal::Activation(ActivationSignal { l1_origin, system_config, .. }) => { self.block = Some(l1_origin); self.done = false; self.system_config = system_config.expect("System config must be provided."); diff --git a/crates/derive/src/stages/mod.rs b/crates/derive/src/stages/mod.rs index d3ce928e32..86df3585ec 100644 --- a/crates/derive/src/stages/mod.rs +++ b/crates/derive/src/stages/mod.rs @@ -31,9 +31,7 @@ pub use channel::{ }; mod batch; -pub use batch::{ - BatchProvider, BatchQueue, BatchStream, BatchStreamProvider, NextBatchProvider, -}; +pub use batch::{BatchProvider, BatchQueue, BatchStream, BatchStreamProvider, NextBatchProvider}; mod attributes_queue; pub use attributes_queue::AttributesQueue; diff --git a/crates/derive/src/test_utils/attributes_queue.rs b/crates/derive/src/test_utils/attributes_queue.rs index bd320e4e7d..3f5dfbca27 100644 --- a/crates/derive/src/test_utils/attributes_queue.rs +++ b/crates/derive/src/test_utils/attributes_queue.rs @@ -10,8 +10,8 @@ use crate::{ use alloc::{boxed::Box, string::ToString, vec::Vec}; use alloy_eips::BlockNumHash; use async_trait::async_trait; -use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use op_alloy_protocol::SingleBatch; +use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use op_alloy_rpc_types_engine::OpPayloadAttributes; use thiserror::Error; diff --git a/crates/derive/src/test_utils/batch_provider.rs b/crates/derive/src/test_utils/batch_provider.rs index aa534fc443..39118e5551 100644 --- a/crates/derive/src/test_utils/batch_provider.rs +++ b/crates/derive/src/test_utils/batch_provider.rs @@ -38,7 +38,6 @@ impl OriginProvider for TestNextBatchProvider { #[async_trait] impl NextBatchProvider for TestNextBatchProvider { - async fn next_batch(&mut self) -> PipelineResult { self.batches.pop().ok_or(PipelineError::Eof.temp())? } diff --git a/crates/derive/src/test_utils/eigen_da_provider.rs b/crates/derive/src/test_utils/eigen_da_provider.rs index 378cda24c7..1d3c2165f8 100644 --- a/crates/derive/src/test_utils/eigen_da_provider.rs +++ b/crates/derive/src/test_utils/eigen_da_provider.rs @@ -1,9 +1,9 @@ +use crate::errors::EigenDAProviderError; +use crate::traits::EigenDAProvider; +use alloc::boxed::Box; use alloc::string::ToString; use alloc::vec::Vec; -use alloc::boxed::Box; use async_trait::async_trait; -use crate::errors::EigenDAProviderError; -use crate::traits::EigenDAProvider; /// A mock blob provider for testing. #[derive(Debug, Clone, Default)] @@ -18,7 +18,11 @@ pub struct TestEigenDaProvider { impl EigenDAProvider for TestEigenDaProvider { type Error = EigenDAProviderError; - async fn retrieve_blob_with_commitment(&mut self, commitment: &[u8], blob_len: u32) -> Result, Self::Error> { + async fn retrieve_blob_with_commitment( + &mut self, + commitment: &[u8], + blob_len: u32, + ) -> Result, Self::Error> { if self.should_error { return Err(EigenDAProviderError::Blob("error".to_string())); } @@ -28,4 +32,4 @@ impl EigenDAProvider for TestEigenDaProvider { fn da_indexer_enable(&mut self) -> bool { false } -} \ No newline at end of file +} diff --git a/crates/derive/src/test_utils/mod.rs b/crates/derive/src/test_utils/mod.rs index 0c867c23c0..ebe2e6c22f 100644 --- a/crates/derive/src/test_utils/mod.rs +++ b/crates/derive/src/test_utils/mod.rs @@ -49,4 +49,4 @@ pub use sys_config_fetcher::{TestSystemConfigL2Fetcher, TestSystemConfigL2Fetche mod frames; pub use frames::{FrameQueueAsserter, FrameQueueBuilder}; -mod macros; \ No newline at end of file +mod macros; diff --git a/crates/derive/src/traits/attributes.rs b/crates/derive/src/traits/attributes.rs index f9a95a1bc8..be1e601dd6 100644 --- a/crates/derive/src/traits/attributes.rs +++ b/crates/derive/src/traits/attributes.rs @@ -4,7 +4,7 @@ use crate::types::PipelineResult; use alloc::boxed::Box; use alloy_eips::BlockNumHash; use async_trait::async_trait; -use op_alloy_protocol::{L2BlockInfo}; +use op_alloy_protocol::L2BlockInfo; use op_alloy_protocol::SingleBatch; use op_alloy_rpc_types_engine::{OpAttributesWithParent, OpPayloadAttributes}; @@ -15,7 +15,6 @@ use op_alloy_rpc_types_engine::{OpAttributesWithParent, OpPayloadAttributes}; pub trait AttributesProvider { /// Returns the next valid batch upon the given safe head. async fn next_batch(&mut self, parent: L2BlockInfo) -> PipelineResult; - } /// [NextAttributes] defines the interface for pulling attributes from diff --git a/crates/derive/src/traits/data_sources.rs b/crates/derive/src/traits/data_sources.rs index 0063ebf87e..a9eb69994d 100644 --- a/crates/derive/src/traits/data_sources.rs +++ b/crates/derive/src/traits/data_sources.rs @@ -38,10 +38,8 @@ pub trait EigenDAProvider { /// Weather use mantle eigen-da indexer service fn da_indexer_enable(&mut self) -> bool; - } - /// Describes the functionality of a data source that can provide data availability information. #[async_trait] pub trait DataAvailabilityProvider { diff --git a/crates/derive/src/traits/mod.rs b/crates/derive/src/traits/mod.rs index d90f542f95..bf12122977 100644 --- a/crates/derive/src/traits/mod.rs +++ b/crates/derive/src/traits/mod.rs @@ -11,7 +11,7 @@ mod attributes; pub use attributes::{AttributesBuilder, AttributesProvider, NextAttributes}; mod data_sources; -pub use data_sources::{BlobProvider, EigenDAProvider, DataAvailabilityProvider}; +pub use data_sources::{BlobProvider, DataAvailabilityProvider, EigenDAProvider}; mod reset; pub use reset::ResetProvider; diff --git a/crates/driver/src/core.rs b/crates/driver/src/core.rs index 42f924f64a..d6f3f78fdf 100644 --- a/crates/driver/src/core.rs +++ b/crates/driver/src/core.rs @@ -83,10 +83,7 @@ where if let Some(tb) = target { if tip_cursor.l2_safe_head.block_info.number >= tb { info!(target: "client", "Derivation complete, reached L2 safe head."); - return Ok(( - tip_cursor.l2_safe_head, - tip_cursor.l2_safe_head_output_root, - )); + return Ok((tip_cursor.l2_safe_head, tip_cursor.l2_safe_head_output_root)); } } diff --git a/crates/driver/src/executor.rs b/crates/driver/src/executor.rs index d241f790c4..e65aa796d1 100644 --- a/crates/driver/src/executor.rs +++ b/crates/driver/src/executor.rs @@ -8,7 +8,6 @@ use core::{ use kona_executor::ExecutionArtifacts; - use alloc::string::ToString; use alloy_consensus::{Header, Sealed}; use alloy_primitives::B256; diff --git a/crates/driver/src/pipeline.rs b/crates/driver/src/pipeline.rs index d694cb2224..fa936a42bc 100644 --- a/crates/driver/src/pipeline.rs +++ b/crates/driver/src/pipeline.rs @@ -46,7 +46,7 @@ where match e { PipelineErrorKind::Temporary(_) => { trace!(target: "client_derivation_driver", "Failed to step derivation pipeline temporarily: {:?}", e); - continue + continue; } PipelineErrorKind::Reset(e) => { warn!(target: "client_derivation_driver", "Failed to step derivation pipeline due to reset: {:?}", e); @@ -89,7 +89,7 @@ where } PipelineErrorKind::Critical(_) => { warn!(target: "client_derivation_driver", "Failed to step derivation pipeline: {:?}", e); - return Err(e) + return Err(e); } } } diff --git a/crates/eigen-da/src/codec.rs b/crates/eigen-da/src/codec.rs index c8924f053b..79636d017e 100644 --- a/crates/eigen-da/src/codec.rs +++ b/crates/eigen-da/src/codec.rs @@ -36,7 +36,6 @@ pub fn convert_by_padding_empty_byte(data: &[u8]) -> Vec { valid_data } - /// RemoveEmptyByteFromPaddedBytes takes bytes and remove the first byte from every 32 bytes. /// This reverses the change made by the function ConvertByPaddingEmptyByte. /// The function does not assume the input is a multiple of BYTES_PER_SYMBOL(32 bytes). @@ -60,10 +59,9 @@ pub fn remove_empty_byte_from_padded_bytes(data: &[u8]) -> Vec { valid_len = end - start + i * put_size; } - valid_data[i * put_size..(i + 1) * put_size] - .copy_from_slice(&data[start..end]); + valid_data[i * put_size..(i + 1) * put_size].copy_from_slice(&data[start..end]); } valid_data.truncate(valid_len); valid_data -} \ No newline at end of file +} diff --git a/crates/eigen-da/src/config.rs b/crates/eigen-da/src/config.rs index 5caa8b4f18..2f67a56e46 100644 --- a/crates/eigen-da/src/config.rs +++ b/crates/eigen-da/src/config.rs @@ -1,5 +1,5 @@ -use {String, ToString}; use core::time::Duration; +use {String, ToString}; /// The EigenDa configuration pub struct EigenDaConfig { @@ -23,4 +23,4 @@ impl Default for EigenDaConfig { retrieve_blob_timeout: Duration::from_secs(120), } } -} \ No newline at end of file +} diff --git a/crates/eigen-da/src/eigen_da_proxy.rs b/crates/eigen-da/src/eigen_da_proxy.rs index 760d7d1535..d24b1c8dae 100644 --- a/crates/eigen-da/src/eigen_da_proxy.rs +++ b/crates/eigen-da/src/eigen_da_proxy.rs @@ -1,25 +1,24 @@ -use {format, vec}; -use {String, ToString}; -use Vec; -use core::time::Duration; +use crate::config::EigenDaConfig; +use crate::grpc::BlobInfo; use anyhow::anyhow; use async_trait::async_trait; +use core::time::Duration; +use kona_derive::da::IEigenDA; +use kona_derive::errors::EigenDAProxyError; use prost::Message; use reqwest::{Client, StatusCode}; use rlp::{decode, RlpStream}; use tokio::time::timeout; -use crate::config::EigenDaConfig; -use kona_derive::da::IEigenDA; -use crate::grpc::{BlobInfo}; -use kona_derive::errors::EigenDAProxyError; use Box; +use Vec; +use {format, vec}; +use {String, ToString}; pub const CERT_V0: u8 = 0; pub const EIGEN_DA_COMMITMENT_TYPE: u8 = 0; pub const GENERIC_COMMITMENT_TYPE: u8 = 1; -pub const BYTES_PER_SYMBOL:usize = 32; - +pub const BYTES_PER_SYMBOL: usize = 32; /// An implementation of the [IEigenDA] trait. #[derive(Debug, Clone)] @@ -34,18 +33,22 @@ pub struct EigenDaProxy { pub retrieve_client: Client, /// The timeout for request form retrieve service. pub retrieve_blob_timeout: Duration, - } - impl EigenDaProxy { /// create a new EigenDA Proxy client. pub fn new(cfg: EigenDaConfig) -> Self { Self { proxy_url: cfg.proxy_url, disperser_url: cfg.disperse_url, - disperse_client: Client::builder().timeout(cfg.disperse_blob_timeout).build().expect("disperse client builder failed"), - retrieve_client: Client::builder().timeout(cfg.retrieve_blob_timeout).build().expect("retrieve client builder failed"), + disperse_client: Client::builder() + .timeout(cfg.disperse_blob_timeout) + .build() + .expect("disperse client builder failed"), + retrieve_client: Client::builder() + .timeout(cfg.retrieve_blob_timeout) + .build() + .expect("retrieve client builder failed"), retrieve_blob_timeout: cfg.retrieve_blob_timeout, } } @@ -60,18 +63,22 @@ impl EigenDaProxy { let da_provider = commitment[1]; let cert_version = commitment[2]; - if op_type != GENERIC_COMMITMENT_TYPE || da_provider != EIGEN_DA_COMMITMENT_TYPE || cert_version != CERT_V0 { + if op_type != GENERIC_COMMITMENT_TYPE + || da_provider != EIGEN_DA_COMMITMENT_TYPE + || cert_version != CERT_V0 + { anyhow::bail!("invalid commitment type"); } let data = &commitment[3..]; - let blob_info: BlobInfo = decode(data).map_err(|e| anyhow!("unable to decode commitment: {}", e))?; + let blob_info: BlobInfo = + decode(data).map_err(|e| anyhow!("unable to decode commitment: {}", e))?; Ok(blob_info) } pub fn encode_commitment(blob_info: BlobInfo) -> Result, anyhow::Error> { let mut blob_info_bytes = Vec::new(); - if let Err(err) = blob_info.encode(&mut blob_info_bytes) { + if let Err(err) = blob_info.encode(&mut blob_info_bytes) { anyhow::bail!(err); } let mut stream = RlpStream::new(); @@ -80,24 +87,25 @@ impl EigenDaProxy { let mut result = vec![GENERIC_COMMITMENT_TYPE, EIGEN_DA_COMMITMENT_TYPE, CERT_V0]; result.extend(rlp_encoded_bytes); Ok(result) - } - } #[async_trait] impl IEigenDA for EigenDaProxy { - - type Error = EigenDAProxyError; - async fn retrieve_blob_with_commitment(&self, commitment: &[u8]) -> Result, Self::Error> { - let blob_info = Self::decode_commitment(commitment).map_err(|e|EigenDAProxyError::RetrieveBlobWithCommitment(e.to_string()))?; + async fn retrieve_blob_with_commitment( + &self, + commitment: &[u8], + ) -> Result, Self::Error> { + let blob_info = Self::decode_commitment(commitment) + .map_err(|e| EigenDAProxyError::RetrieveBlobWithCommitment(e.to_string()))?; let request_url = format!("{}/get/0x{}", self.proxy_url, hex::encode(&commitment)); let req = self.retrieve_client.get(&request_url); - let response = timeout(self.retrieve_blob_timeout, req.send()) - .await.map_err(|e|EigenDAProxyError::RetrieveBlobWithCommitment(e.to_string()))? - .map_err(|e|EigenDAProxyError::RetrieveBlobWithCommitment(e.to_string()))?; + let response = timeout(self.retrieve_blob_timeout, req.send()) + .await + .map_err(|e| EigenDAProxyError::RetrieveBlobWithCommitment(e.to_string()))? + .map_err(|e| EigenDAProxyError::RetrieveBlobWithCommitment(e.to_string()))?; if response.status() == StatusCode::NOT_FOUND { return Err(EigenDAProxyError::RetrieveBlobWithCommitment("Blob not found".into())); } else if response.status() != StatusCode::OK { @@ -107,30 +115,26 @@ impl IEigenDA for EigenDaProxy { ))); } - - let body = response.bytes().await.map_err(|e| EigenDAProxyError::RetrieveBlobWithCommitment(e.to_string()))?; + let body = response + .bytes() + .await + .map_err(|e| EigenDAProxyError::RetrieveBlobWithCommitment(e.to_string()))?; Ok(body.to_vec()) } - - } - #[cfg(test)] mod tests { - use alloy_primitives::hex; use super::*; + use alloy_primitives::hex; #[test] fn test_decode_blob_info() { let commitment = hex!("010000f901d8f852f842a00dbbd22149b419a9a751c25065b58745f4216dc3ae4e9ad583306c395387b6a3a02673dfa25dd3095246eeffb639d3e11108a1ba75dd29b86c3a4200ed00210e4e820200cac480213701c401213710f90181830148ae81a5f873eba0c42bcd27bcd22ba55c4189a25d362343838cb75f57979baa0686ec5381a944c3820001826362832a79cba07263089b84cbb2963e4f50a930243c081ab14b01c0c92d57c3029590bd9dfc9200832a7a20a05419bc29ac025512311c14f23d9613e408448e47bb31f71614e1f82b6c63966cb9010074b13a3acaba35d3749063c19806c9a2f2004b318d55edd6cb5129d958807ea7ac09584a2c6ea029ed34c72f849862e4189928e90931e07093209016f5fc70a6c4a8c3237c25c4f236bb25c105fd7dbd6e4a00153c69c0757d8cbf02f966167ccae243412c20de1c3a38a50818dc7f9f3e02dcb3bc4e54800f2224b8c1eaa9955e41792fa0e401f2814ee209331126149c630c34e1b8e2f804955582022676e232d24d7784b496fc997d98db2849b1bfa8443b362723fc603da8de11704a1ef50414e11234496cfac67aebdd2faa24840ffe7f04506652b8a11a534b024a40bc7e99fee042336f425eb16e40e4267593415860204c9069723dbaca8cf2e596dc820001"); let blob_info = EigenDaProxy::decode_commitment(&commitment).unwrap(); let blob_header = blob_info.blob_header.unwrap(); - assert_eq!(blob_header.data_length,512); + assert_eq!(blob_header.data_length, 512); let blob_proof = blob_info.blob_verification_proof.unwrap(); - assert_eq!(blob_proof.blob_index,165); - assert_eq!(blob_proof.batch_id,84142); - + assert_eq!(blob_proof.blob_index, 165); + assert_eq!(blob_proof.batch_id, 84142); } } - - diff --git a/crates/eigen-da/src/grpc/disperser.rs b/crates/eigen-da/src/grpc/disperser.rs index 2a3838b062..f4e7e42223 100644 --- a/crates/eigen-da/src/grpc/disperser.rs +++ b/crates/eigen-da/src/grpc/disperser.rs @@ -307,4 +307,4 @@ impl BlobStatus { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/eigen-da/src/grpc/mod.rs b/crates/eigen-da/src/grpc/mod.rs index 18d41a1db6..e8d8bf2fcb 100644 --- a/crates/eigen-da/src/grpc/mod.rs +++ b/crates/eigen-da/src/grpc/mod.rs @@ -4,5 +4,4 @@ pub mod disperser; pub mod rlp; pub use rlp::*; - pub use disperser::*; diff --git a/crates/eigen-da/src/grpc/rlp.rs b/crates/eigen-da/src/grpc/rlp.rs index 7fe67a3f8a..377cde2639 100644 --- a/crates/eigen-da/src/grpc/rlp.rs +++ b/crates/eigen-da/src/grpc/rlp.rs @@ -1,21 +1,30 @@ -use Vec; +use crate::common::G1Commitment; +use crate::{ + BatchHeader, BatchMetadata, BlobHeader, BlobInfo, BlobQuorumParam, BlobVerificationProof, +}; use bytes::{Bytes, BytesMut}; use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; -use crate::common::G1Commitment; -use crate::{BlobInfo, BatchHeader, BatchMetadata, BlobHeader, BlobQuorumParam, BlobVerificationProof}; +use Vec; impl Encodable for BlobInfo { fn rlp_append(&self, s: &mut RlpStream) { s.begin_list(2); match &self.blob_header { - Some(blob_header) => {s.append(blob_header);}, - None => {s.append_empty_data();}, + Some(blob_header) => { + s.append(blob_header); + } + None => { + s.append_empty_data(); + } } match &self.blob_verification_proof { - Some(blob_verification_proof) => {s.append(blob_verification_proof);}, - None => {s.append_empty_data();}, - } - ; + Some(blob_verification_proof) => { + s.append(blob_verification_proof); + } + None => { + s.append_empty_data(); + } + }; } } @@ -25,30 +34,25 @@ impl Decodable for BlobInfo { if rlp.item_count()? != 2 { return Err(DecoderError::RlpIncorrectListLen); } - let blob_header = if !rlp.at(0)?.is_empty() { - Some(rlp.val_at(0)?) - } else { None }; - let blob_verification_proof = if !rlp.at(1)?.is_empty() { - Some(rlp.val_at(1)?) - }else { None }; - Ok( BlobInfo{ - blob_header, - blob_verification_proof, - }) + let blob_header = if !rlp.at(0)?.is_empty() { Some(rlp.val_at(0)?) } else { None }; + let blob_verification_proof = + if !rlp.at(1)?.is_empty() { Some(rlp.val_at(1)?) } else { None }; + Ok(BlobInfo { blob_header, blob_verification_proof }) } } - - - impl Encodable for BlobVerificationProof { fn rlp_append(&self, s: &mut RlpStream) { s.begin_list(5); s.append(&self.batch_id); s.append(&self.blob_index); match &self.batch_metadata { - Some(batch_metadata) => {s.append(batch_metadata);}, - None => {s.append_empty_data();}, + Some(batch_metadata) => { + s.append(batch_metadata); + } + None => { + s.append_empty_data(); + } } s.append(&self.inclusion_proof); s.append(&self.quorum_indexes); @@ -63,12 +67,10 @@ impl Decodable for BlobVerificationProof { } let batch_id = rlp.val_at(0)?; let blob_index = rlp.val_at(1)?; - let batch_metadata = if !rlp.at(2)?.is_empty() { - Some(rlp.val_at(2)?) - } else { None }; + let batch_metadata = if !rlp.at(2)?.is_empty() { Some(rlp.val_at(2)?) } else { None }; let inclusion_proof = rlp.val_at(3)?; let quorum_indexes = rlp.list_at(4)?; - Ok(BlobVerificationProof{ + Ok(BlobVerificationProof { batch_id, blob_index, batch_metadata, @@ -82,8 +84,12 @@ impl Encodable for BatchMetadata { fn rlp_append(&self, s: &mut RlpStream) { s.begin_list(5); match &self.batch_header { - Some(batch_header) => {s.append(batch_header);}, - None => {s.append_empty_data();}, + Some(batch_header) => { + s.append(batch_header); + } + None => { + s.append_empty_data(); + } } s.append(&self.signatory_record_hash); s.append(&self.fee); @@ -98,14 +104,12 @@ impl Decodable for BatchMetadata { if rlp.item_count()? != 5 { return Err(DecoderError::RlpIncorrectListLen); } - let batch_header = if !rlp.at(0)?.is_empty() { - Some(rlp.at(0)?.as_val()?) - } else { None }; + let batch_header = if !rlp.at(0)?.is_empty() { Some(rlp.at(0)?.as_val()?) } else { None }; let signatory_record_hash = rlp.at(1)?.as_val()?; let fee = rlp.at(2)?.as_val()?; let confirmation_block_number = rlp.at(3)?.as_val()?; let batch_header_hash = rlp.at(4)?.as_val()?; - Ok( BatchMetadata{ + Ok(BatchMetadata { batch_header, signatory_record_hash, fee, @@ -135,7 +139,7 @@ impl Decodable for BatchHeader { let quorum_numbers = rlp.val_at(1)?; let quorum_signed_percentages = rlp.val_at(2)?; let reference_block_number = rlp.val_at(3)?; - Ok( BatchHeader { + Ok(BatchHeader { batch_root, quorum_numbers, quorum_signed_percentages, @@ -144,17 +148,16 @@ impl Decodable for BatchHeader { } } - - - - - impl Encodable for BlobHeader { fn rlp_append(&self, s: &mut RlpStream) { s.begin_list(3); match &self.commitment { - Some(commitment) => {s.append(commitment);}, - None => {s.append_empty_data();}, + Some(commitment) => { + s.append(commitment); + } + None => { + s.append_empty_data(); + } } s.append(&self.data_length); s.begin_list(self.blob_quorum_params.len()); @@ -170,18 +173,14 @@ impl Decodable for BlobHeader { if rlp.item_count()? < 3 { return Err(DecoderError::RlpIncorrectListLen); } - let commitment = if !rlp.at(0)?.is_empty() { - Some(rlp.at(0)?.as_val()?) - } else { None }; + let commitment = if !rlp.at(0)?.is_empty() { Some(rlp.at(0)?.as_val()?) } else { None }; let data_length = rlp.val_at(1)?; let blob_quorum_params = rlp.list_at(2)?; - Ok( BlobHeader { commitment, blob_quorum_params, data_length } ) + Ok(BlobHeader { commitment, blob_quorum_params, data_length }) } } - - impl Encodable for G1Commitment { fn rlp_append(&self, s: &mut RlpStream) { s.begin_list(2); @@ -199,10 +198,7 @@ impl Decodable for G1Commitment { let x = rlp.val_at(0)?; let y = rlp.val_at(1)?; - Ok(G1Commitment { - x, - y, - }) + Ok(G1Commitment { x, y }) } } @@ -235,5 +231,3 @@ impl Decodable for BlobQuorumParam { }) } } - - diff --git a/crates/eigen-da/src/lib.rs b/crates/eigen-da/src/lib.rs index fb1d2095c0..ce89ac4a72 100644 --- a/crates/eigen-da/src/lib.rs +++ b/crates/eigen-da/src/lib.rs @@ -1,4 +1,3 @@ - mod config; pub use config::*; mod codec; @@ -8,5 +7,3 @@ mod grpc; pub use grpc::*; mod eigen_da_proxy; pub use eigen_da_proxy::*; - - diff --git a/crates/executor/src/constants.rs b/crates/executor/src/constants.rs index 400c293bfc..efeb00fed4 100644 --- a/crates/executor/src/constants.rs +++ b/crates/executor/src/constants.rs @@ -16,4 +16,4 @@ pub(crate) const HOLOCENE_EXTRA_DATA_VERSION: u8 = 0x00; /// Empty SHA-256 hash. pub(crate) const SHA256_EMPTY: B256 = - b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"); \ No newline at end of file + b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"); diff --git a/crates/executor/src/db/mod.rs b/crates/executor/src/db/mod.rs index 8dd7955050..4357ac0743 100644 --- a/crates/executor/src/db/mod.rs +++ b/crates/executor/src/db/mod.rs @@ -383,8 +383,8 @@ where let mut header = self.parent_block_header.inner().clone(); // Check if the block number is in range. If not, we can fail early. - if block_number > header.number || - header.number.saturating_sub(block_number) > BLOCK_HASH_HISTORY + if block_number > header.number + || header.number.saturating_sub(block_number) > BLOCK_HASH_HISTORY { return Ok(B256::default()); } diff --git a/crates/executor/src/executor/mod.rs b/crates/executor/src/executor/mod.rs index 66d8795406..3a64ff4793 100644 --- a/crates/executor/src/executor/mod.rs +++ b/crates/executor/src/executor/mod.rs @@ -315,9 +315,7 @@ where pub fn compute_output_root(&mut self) -> ExecutorResult { // Fetch the L2 to L1 message passer account from the cache or underlying trie. let storage_root = match self.trie_db.storage_roots().get(&L2_TO_L1_BRIDGE) { - Some(storage_root) => { - storage_root.blind() - } + Some(storage_root) => storage_root.blind(), None => { self.trie_db .get_trie_account(&L2_TO_L1_BRIDGE)? diff --git a/crates/executor/src/lib.rs b/crates/executor/src/lib.rs index d3c9ca7746..49aefc3744 100644 --- a/crates/executor/src/lib.rs +++ b/crates/executor/src/lib.rs @@ -16,7 +16,10 @@ mod errors; pub use errors::{ExecutorError, ExecutorResult, TrieDBError, TrieDBResult}; mod executor; -pub use executor::{ExecutionArtifacts, KonaHandleRegister, StatelessL2BlockExecutor, StatelessL2BlockExecutorBuilder}; +pub use executor::{ + ExecutionArtifacts, KonaHandleRegister, StatelessL2BlockExecutor, + StatelessL2BlockExecutorBuilder, +}; mod db; pub use db::{NoopTrieDBProvider, TrieDB, TrieDBProvider}; diff --git a/crates/executor/src/syscalls/eip2935.rs b/crates/executor/src/syscalls/eip2935.rs index 7d17aaa6c2..584299eb34 100644 --- a/crates/executor/src/syscalls/eip2935.rs +++ b/crates/executor/src/syscalls/eip2935.rs @@ -84,7 +84,7 @@ where // If the block number is zero (genesis block) then no system // transaction may occur as per EIP-2935. if block_number == 0 { - return Ok(()) + return Ok(()); } // Get the previous environment diff --git a/crates/executor/src/syscalls/eip4788.rs b/crates/executor/src/syscalls/eip4788.rs index ad592b97e8..b3e7a5e988 100644 --- a/crates/executor/src/syscalls/eip4788.rs +++ b/crates/executor/src/syscalls/eip4788.rs @@ -66,7 +66,7 @@ where // if !config.is_ecotone_active(timestamp) { // return Ok(()); // } - return Ok(()); + return Ok(()); let parent_beacon_block_root = parent_beacon_block_root.ok_or(ExecutorError::MissingParentBeaconBlockRoot)?; diff --git a/crates/executor/src/syscalls/mod.rs b/crates/executor/src/syscalls/mod.rs index 9c873ba4a0..8826c4230d 100644 --- a/crates/executor/src/syscalls/mod.rs +++ b/crates/executor/src/syscalls/mod.rs @@ -6,6 +6,5 @@ pub(crate) use eip2935::pre_block_block_hash_contract_call; mod eip4788; pub(crate) use eip4788::pre_block_beacon_root_contract_call; - mod tx_env; pub(crate) use tx_env::fill_tx_env_for_contract_call; diff --git a/crates/proof-sdk/proof/src/executor.rs b/crates/proof-sdk/proof/src/executor.rs index 02a3962757..809e3e9ea4 100644 --- a/crates/proof-sdk/proof/src/executor.rs +++ b/crates/proof-sdk/proof/src/executor.rs @@ -5,7 +5,9 @@ use alloy_consensus::{Header, Sealed}; use alloy_primitives::B256; use async_trait::async_trait; use kona_driver::Executor; -use kona_executor::{ExecutionArtifacts, KonaHandleRegister, StatelessL2BlockExecutor, TrieDBProvider}; +use kona_executor::{ + ExecutionArtifacts, KonaHandleRegister, StatelessL2BlockExecutor, TrieDBProvider, +}; use kona_mpt::TrieHinter; use op_alloy_genesis::RollupConfig; use op_alloy_rpc_types_engine::OpPayloadAttributes; @@ -83,12 +85,10 @@ where &mut self, attributes: OpPayloadAttributes, ) -> Result { - self.inner - .as_mut() - .map_or_else( - || Err(kona_executor::ExecutorError::MissingExecutor), - |e| e.execute_payload(attributes), - ) + self.inner.as_mut().map_or_else( + || Err(kona_executor::ExecutorError::MissingExecutor), + |e| e.execute_payload(attributes), + ) } /// Computes the output root. diff --git a/crates/proof-sdk/proof/src/l1/eigen_da_provider.rs b/crates/proof-sdk/proof/src/l1/eigen_da_provider.rs index 5ccb1ff05c..a8849109c3 100644 --- a/crates/proof-sdk/proof/src/l1/eigen_da_provider.rs +++ b/crates/proof-sdk/proof/src/l1/eigen_da_provider.rs @@ -1,23 +1,22 @@ -use alloc::sync::Arc; -use alloc::vec::Vec; use alloc::boxed::Box; +use alloc::sync::Arc; use alloc::vec; +use alloc::vec::Vec; use alloy_primitives::keccak256; use async_trait::async_trait; // use tokio::io::AsyncReadExt; -use kona_derive::traits::EigenDAProvider; -use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType}; -use kona_preimage::PreimageKeyType::Precompile; use crate::errors::OracleProviderError; use crate::HintType; +use kona_derive::traits::EigenDAProvider; +use kona_preimage::PreimageKeyType::Precompile; +use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType}; -#[derive(Debug,Clone)] +#[derive(Debug, Clone)] pub struct OracleEigenDaProvider { /// The preimage oracle client. pub oracle: Arc, } - impl OracleEigenDaProvider { /// Constructs a new `OracleBlobProvider`. pub fn new(oracle: Arc) -> Self { @@ -32,26 +31,37 @@ impl OracleEigenDaProvider { /// ## Returns /// - `Ok(blob)`: The blob. /// - `Err(e)`: The blob could not be retrieved. - async fn get_blob(&self, commitment: &[u8], blob_len: u32) -> Result, OracleProviderError> { + async fn get_blob( + &self, + commitment: &[u8], + blob_len: u32, + ) -> Result, OracleProviderError> { HintType::EigenDa.with_data(&[commitment.as_ref()]).send(self.oracle.as_ref()).await?; let mut out_data = vec![0u8; blob_len as usize]; - self.oracle.get_exact(PreimageKey::new(*keccak256(commitment),PreimageKeyType::GlobalGeneric), &mut out_data) + self.oracle + .get_exact( + PreimageKey::new(*keccak256(commitment), PreimageKeyType::GlobalGeneric), + &mut out_data, + ) .await .map_err(OracleProviderError::Preimage)?; tracing::info!(target: "client_oracle", "Retrieved blob from eigen da with commitment {commitment:?} from the oracle."); Ok(out_data) } - } #[async_trait] impl EigenDAProvider for OracleEigenDaProvider { type Error = OracleProviderError; - async fn retrieve_blob_with_commitment(&mut self, commitment: &[u8], blob_len: u32) -> Result, Self::Error> { + async fn retrieve_blob_with_commitment( + &mut self, + commitment: &[u8], + blob_len: u32, + ) -> Result, Self::Error> { trace!("Start to get blobs from eigen da with commitment {:?}", commitment); - let out_data:Vec = self.get_blob(commitment, blob_len).await?; + let out_data: Vec = self.get_blob(commitment, blob_len).await?; Ok(out_data) } diff --git a/crates/proof-sdk/proof/src/l1/mod.rs b/crates/proof-sdk/proof/src/l1/mod.rs index a9bb7d8ba1..0282590506 100644 --- a/crates/proof-sdk/proof/src/l1/mod.rs +++ b/crates/proof-sdk/proof/src/l1/mod.rs @@ -14,4 +14,4 @@ mod eigen_da_provider; pub use chain_provider::OracleL1ChainProvider; -pub use eigen_da_provider::OracleEigenDaProvider; \ No newline at end of file +pub use eigen_da_provider::OracleEigenDaProvider; diff --git a/crates/proof-sdk/proof/src/l1/pipeline.rs b/crates/proof-sdk/proof/src/l1/pipeline.rs index 1e28ac2ed6..00a786d4ca 100644 --- a/crates/proof-sdk/proof/src/l1/pipeline.rs +++ b/crates/proof-sdk/proof/src/l1/pipeline.rs @@ -4,6 +4,8 @@ use crate::{l1::OracleL1ChainProvider, l2::OracleL2ChainProvider, FlushableCache use alloc::{boxed::Box, sync::Arc}; use async_trait::async_trait; use core::fmt::Debug; +use kona_derive::prelude::EigenDaSource; +use kona_derive::traits::EigenDAProvider; use kona_derive::{ attributes::StatefulAttributesBuilder, errors::PipelineErrorKind, @@ -21,8 +23,6 @@ use kona_preimage::CommsClient; use op_alloy_genesis::{RollupConfig, SystemConfig}; use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use op_alloy_rpc_types_engine::OpAttributesWithParent; -use kona_derive::prelude::EigenDaSource; -use kona_derive::traits::EigenDAProvider; use spin::RwLock; /// An oracle-backed derivation pipeline. @@ -89,8 +89,12 @@ where chain_provider.clone(), ); - let dap = EthereumDataSource::new_from_parts(chain_provider.clone(), blob_provider.clone(), eigen_da_provider.clone(), &cfg); - + let dap = EthereumDataSource::new_from_parts( + chain_provider.clone(), + blob_provider.clone(), + eigen_da_provider.clone(), + &cfg, + ); let pipeline = PipelineBuilder::new() .rollup_config(cfg) diff --git a/crates/proof-sdk/proof/src/l2/chain_provider.rs b/crates/proof-sdk/proof/src/l2/chain_provider.rs index 6713b003d5..0b022768ea 100644 --- a/crates/proof-sdk/proof/src/l2/chain_provider.rs +++ b/crates/proof-sdk/proof/src/l2/chain_provider.rs @@ -118,11 +118,7 @@ impl BatchValidationProvider for OracleL2ChainProv let optimism_block = OpBlock { header, - body: BlockBody { - transactions, - ommers: Vec::new(), - withdrawals: None, - }, + body: BlockBody { transactions, ommers: Vec::new(), withdrawals: None }, }; Ok(optimism_block) } diff --git a/crates/proof-sdk/proof/src/sync.rs b/crates/proof-sdk/proof/src/sync.rs index dfa14d929f..1c097081ff 100644 --- a/crates/proof-sdk/proof/src/sync.rs +++ b/crates/proof-sdk/proof/src/sync.rs @@ -6,12 +6,12 @@ use crate::{ }; use alloc::sync::Arc; use alloy_consensus::{Header, Sealed}; -use op_alloy_genesis::RollupConfig; use alloy_primitives::B256; use core::fmt::Debug; use kona_derive::traits::ChainProvider; use kona_driver::{PipelineCursor, TipCursor}; use kona_preimage::CommsClient; +use op_alloy_genesis::RollupConfig; use op_alloy_protocol::BatchValidationProvider; use spin::RwLock; diff --git a/crates/providers-alloy/src/blobs.rs b/crates/providers-alloy/src/blobs.rs index 9d71256170..b98905a74d 100644 --- a/crates/providers-alloy/src/blobs.rs +++ b/crates/providers-alloy/src/blobs.rs @@ -93,7 +93,10 @@ impl OnlineBlobProvider { // Validate the correct number of blob sidecars were retrieved. if blob_hashes.len() != filtered.len() { - return Err(BlobProviderError::SidecarLengthMismatch(blob_hashes.len(), filtered.len())); + return Err(BlobProviderError::SidecarLengthMismatch( + blob_hashes.len(), + filtered.len(), + )); } Ok(filtered diff --git a/crates/providers-alloy/src/eigen_da_provider.rs b/crates/providers-alloy/src/eigen_da_provider.rs index 8b51cfd8d0..7862770b58 100644 --- a/crates/providers-alloy/src/eigen_da_provider.rs +++ b/crates/providers-alloy/src/eigen_da_provider.rs @@ -1,14 +1,13 @@ //! Contains an online implementation of the `EigenDaProvider` trait. use async_trait::async_trait; -use kona_derive::da::{ IEigenDA}; -use kona_derive::errors::{EigenDAProviderError}; +use kona_derive::da::IEigenDA; +use kona_derive::errors::EigenDAProviderError; use kona_derive::traits::EigenDAProvider; - /// An online implementation of the [EigenDaProvider] #[derive(Debug, Clone)] -pub struct OnlineEigenDaProvider { +pub struct OnlineEigenDaProvider { /// The EigenDA Proxy client. eigen_da_proxy_client: E, /// The Mantle da indexer socket url. @@ -17,22 +16,20 @@ pub struct OnlineEigenDaProvider { pub mantle_da_indexer_enable: bool, } -impl OnlineEigenDaProvider { +impl OnlineEigenDaProvider { pub const fn new( eigen_da_proxy_client: E, mantle_da_indexer_socket: String, mantle_da_indexer_enable: bool, ) -> Self { - Self{ - eigen_da_proxy_client, - mantle_da_indexer_socket, - mantle_da_indexer_enable, - } + Self { eigen_da_proxy_client, mantle_da_indexer_socket, mantle_da_indexer_enable } } - pub async fn get_blob(&self,commitment: &[u8]) -> Result, EigenDAProviderError> { - self.eigen_da_proxy_client.retrieve_blob_with_commitment(commitment).await - .map_err(|e|EigenDAProviderError::Status(e.to_string())) + pub async fn get_blob(&self, commitment: &[u8]) -> Result, EigenDAProviderError> { + self.eigen_da_proxy_client + .retrieve_blob_with_commitment(commitment) + .await + .map_err(|e| EigenDAProviderError::Status(e.to_string())) } } @@ -43,9 +40,15 @@ where { type Error = EigenDAProviderError; - async fn retrieve_blob_with_commitment(&mut self, commitment: &[u8], blob_len: u32) -> Result, Self::Error> { - self.eigen_da_proxy_client.retrieve_blob_with_commitment(commitment).await - .map_err(|e|EigenDAProviderError::Status(e.to_string())) + async fn retrieve_blob_with_commitment( + &mut self, + commitment: &[u8], + blob_len: u32, + ) -> Result, Self::Error> { + self.eigen_da_proxy_client + .retrieve_blob_with_commitment(commitment) + .await + .map_err(|e| EigenDAProviderError::Status(e.to_string())) } fn da_indexer_enable(&mut self) -> bool { @@ -55,19 +58,17 @@ where #[cfg(test)] mod tests { + use super::*; use alloy_primitives::hex; use eigen_da::{EigenDaConfig, EigenDaProxy}; - use super::*; #[tokio::test] async fn test_get_blob() { let commitment = hex!("010000f901d8f852f842a00dbbd22149b419a9a751c25065b58745f4216dc3ae4e9ad583306c395387b6a3a02673dfa25dd3095246eeffb639d3e11108a1ba75dd29b86c3a4200ed00210e4e820200cac480213701c401213710f90181830148ae81a5f873eba0c42bcd27bcd22ba55c4189a25d362343838cb75f57979baa0686ec5381a944c3820001826362832a79cba07263089b84cbb2963e4f50a930243c081ab14b01c0c92d57c3029590bd9dfc9200832a7a20a05419bc29ac025512311c14f23d9613e408448e47bb31f71614e1f82b6c63966cb9010074b13a3acaba35d3749063c19806c9a2f2004b318d55edd6cb5129d958807ea7ac09584a2c6ea029ed34c72f849862e4189928e90931e07093209016f5fc70a6c4a8c3237c25c4f236bb25c105fd7dbd6e4a00153c69c0757d8cbf02f966167ccae243412c20de1c3a38a50818dc7f9f3e02dcb3bc4e54800f2224b8c1eaa9955e41792fa0e401f2814ee209331126149c630c34e1b8e2f804955582022676e232d24d7784b496fc997d98db2849b1bfa8443b362723fc603da8de11704a1ef50414e11234496cfac67aebdd2faa24840ffe7f04506652b8a11a534b024a40bc7e99fee042336f425eb16e40e4267593415860204c9069723dbaca8cf2e596dc820001"); let eigen_config = EigenDaConfig::default(); let eigen_da_proxy = EigenDaProxy::new(eigen_config); - let eigen_da_provider = OnlineEigenDaProvider::new(eigen_da_proxy,"".to_string(),false); + let eigen_da_provider = OnlineEigenDaProvider::new(eigen_da_proxy, "".to_string(), false); let out = eigen_da_provider.get_blob(&commitment).await.unwrap(); - assert_eq!(out.len(),11681) + assert_eq!(out.len(), 11681) } - - } diff --git a/crates/providers-alloy/src/l2_chain_provider.rs b/crates/providers-alloy/src/l2_chain_provider.rs index 0eb488f1fe..0bea15458c 100644 --- a/crates/providers-alloy/src/l2_chain_provider.rs +++ b/crates/providers-alloy/src/l2_chain_provider.rs @@ -9,9 +9,9 @@ use kona_derive::{ errors::{PipelineError, PipelineErrorKind}, traits::L2ChainProvider, }; +use op_alloy_consensus::OpBlock; use op_alloy_genesis::{RollupConfig, SystemConfig}; use op_alloy_protocol::{to_system_config, BatchValidationProvider, L2BlockInfo}; -use op_alloy_consensus::OpBlock; use std::sync::Arc; /// The [AlloyL2ChainProvider] is a concrete implementation of the [L2ChainProvider] trait,