diff --git a/Cargo.lock b/Cargo.lock index 0962f0fd2..9d1b17780 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2239,13 +2239,9 @@ dependencies = [ "alloc-no-stdlib", "alloy-consensus", "alloy-eips", - "alloy-node-bindings", "alloy-primitives", "alloy-rlp", - "alloy-rpc-client", "alloy-rpc-types-engine", - "alloy-transport-http", - "anyhow", "async-trait", "brotli", "derive_more", diff --git a/crates/derive/Cargo.toml b/crates/derive/Cargo.toml index 58d25c22f..e1554acaa 100644 --- a/crates/derive/Cargo.toml +++ b/crates/derive/Cargo.toml @@ -39,20 +39,12 @@ serde = { workspace = true, optional = true, features = ["derive"] } # `test-utils` feature dependencies spin = { workspace = true, optional = true } -anyhow = { workspace = true, optional = true } -alloy-rpc-client = { workspace = true, optional = true } -alloy-node-bindings = { workspace = true, optional = true } -alloy-transport-http = { workspace = true, optional = true } tracing-subscriber = { workspace = true, optional = true, features = ["fmt"] } [dev-dependencies] spin.workspace = true -anyhow.workspace = true proptest.workspace = true serde_json.workspace = true -alloy-rpc-client.workspace = true -alloy-node-bindings.workspace = true -alloy-transport-http.workspace = true tokio = { workspace = true, features = ["full"] } tracing-subscriber = { workspace = true, features = ["fmt"] } alloy-primitives = { workspace = true, features = ["rlp", "k256", "map", "arbitrary"] } @@ -70,10 +62,5 @@ serde = [ ] test-utils = [ "dep:spin", - "dep:anyhow", - "dep:alloy-transport-http", - "dep:alloy-node-bindings", "dep:tracing-subscriber", - "dep:alloy-rpc-client", - "alloy-transport-http/reqwest" ] diff --git a/crates/derive/src/lib.rs b/crates/derive/src/lib.rs index ad603141c..2e6691467 100644 --- a/crates/derive/src/lib.rs +++ b/crates/derive/src/lib.rs @@ -4,7 +4,7 @@ html_favicon_url = "https://raw.githubusercontent.com/anton-rs/kona/main/assets/favicon.ico" )] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -#![cfg_attr(not(any(test, feature = "test-utils")), warn(unused_crate_dependencies))] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(not(test), no_std)] extern crate alloc; diff --git a/crates/derive/src/test_utils/attributes_queue.rs b/crates/derive/src/test_utils/attributes_queue.rs index 3e2aaf1e6..c015ac97a 100644 --- a/crates/derive/src/test_utils/attributes_queue.rs +++ b/crates/derive/src/test_utils/attributes_queue.rs @@ -14,11 +14,17 @@ use async_trait::async_trait; use op_alloy_protocol::{BlockInfo, L2BlockInfo}; use op_alloy_rpc_types_engine::OpPayloadAttributes; +/// An error returned by the [`TestAttributesBuilder`]. +#[derive(derive_more::Display, Debug, PartialEq, Eq)] +pub enum TestAttributesBuilderError {} + +impl core::error::Error for TestAttributesBuilderError {} + /// A mock implementation of the [`AttributesBuilder`] for testing. #[derive(Debug, Default)] pub struct TestAttributesBuilder { /// The attributes to return. - pub attributes: Vec>, + pub attributes: Vec>, } #[async_trait] diff --git a/crates/derive/src/test_utils/mod.rs b/crates/derive/src/test_utils/mod.rs index 55bb9795f..8be980757 100644 --- a/crates/derive/src/test_utils/mod.rs +++ b/crates/derive/src/test_utils/mod.rs @@ -21,7 +21,8 @@ pub use batch_provider::TestNextBatchProvider; mod attributes_queue; pub use attributes_queue::{ - new_test_attributes_provider, TestAttributesBuilder, TestAttributesProvider, + new_test_attributes_provider, TestAttributesBuilder, TestAttributesBuilderError, + TestAttributesProvider, }; mod batch_stream; @@ -40,7 +41,7 @@ mod tracing; pub use tracing::{CollectingLayer, TraceStorage}; mod sys_config_fetcher; -pub use sys_config_fetcher::TestSystemConfigL2Fetcher; +pub use sys_config_fetcher::{TestSystemConfigL2Fetcher, TestSystemConfigL2FetcherError}; mod frames; pub use frames::{FrameQueueAsserter, FrameQueueBuilder}; diff --git a/crates/derive/src/test_utils/sys_config_fetcher.rs b/crates/derive/src/test_utils/sys_config_fetcher.rs index 291bcd281..2a37085ab 100644 --- a/crates/derive/src/test_utils/sys_config_fetcher.rs +++ b/crates/derive/src/test_utils/sys_config_fetcher.rs @@ -3,7 +3,6 @@ use crate::traits::L2ChainProvider; use alloc::{boxed::Box, sync::Arc}; use alloy_primitives::map::HashMap; -use anyhow::Result; use async_trait::async_trait; use op_alloy_consensus::OpBlock; use op_alloy_genesis::{RollupConfig, SystemConfig}; @@ -28,26 +27,36 @@ impl TestSystemConfigL2Fetcher { } } +/// An error returned by the [TestSystemConfigL2Fetcher]. +#[derive(derive_more::Display, Debug, PartialEq, Eq)] +pub enum TestSystemConfigL2FetcherError { + /// The system config was not found. + #[display("system config not found: {_0}")] + NotFound(u64), +} + +impl core::error::Error for TestSystemConfigL2FetcherError {} + #[async_trait] impl L2ChainProvider for TestSystemConfigL2Fetcher { - type Error = anyhow::Error; + type Error = TestSystemConfigL2FetcherError; async fn system_config_by_number( &mut self, number: u64, _: Arc, - ) -> Result { + ) -> Result { self.system_configs .get(&number) .cloned() - .ok_or_else(|| anyhow::anyhow!("system config not found: {number}")) + .ok_or_else(|| TestSystemConfigL2FetcherError::NotFound(number)) } - async fn l2_block_info_by_number(&mut self, _: u64) -> Result { + async fn l2_block_info_by_number(&mut self, _: u64) -> Result { unimplemented!() } - async fn block_by_number(&mut self, _: u64) -> Result { + async fn block_by_number(&mut self, _: u64) -> Result { unimplemented!() } }