diff --git a/Cargo.lock b/Cargo.lock index 81570563d..813e595dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8001,6 +8001,7 @@ dependencies = [ "reth-primitives", "reth-provider", "reth-stages", + "reth-storage-errors", "reth-tokio-util", "tempfile", "tokio", diff --git a/crates/consensus/beacon/src/engine/hooks/static_file.rs b/crates/consensus/beacon/src/engine/hooks/static_file.rs index 3786e29f8..3d78d51d9 100644 --- a/crates/consensus/beacon/src/engine/hooks/static_file.rs +++ b/crates/consensus/beacon/src/engine/hooks/static_file.rs @@ -55,7 +55,7 @@ impl StaticFileHook { match result { Ok(_) => EngineHookEvent::Finished(Ok(())), - Err(err) => EngineHookEvent::Finished(Err(err.into())), + Err(err) => EngineHookEvent::Finished(Err(EngineHookError::Common(err.into()))), } } Err(_) => { diff --git a/crates/static-file/Cargo.toml b/crates/static-file/Cargo.toml index 0f6608c80..f73300841 100644 --- a/crates/static-file/Cargo.toml +++ b/crates/static-file/Cargo.toml @@ -16,7 +16,7 @@ workspace = true reth-primitives.workspace = true reth-db.workspace = true reth-provider.workspace = true -reth-interfaces.workspace = true +reth-storage-errors.workspace = true reth-nippy-jar.workspace = true reth-tokio-util.workspace = true @@ -30,6 +30,7 @@ rayon.workspace = true parking_lot = { workspace = true, features = ["send_guard", "arc_lock"] } [dev-dependencies] +reth-interfaces.workspace = true reth-db = { workspace = true, features = ["test-utils"] } reth-stages = { workspace = true, features = ["test-utils"] } diff --git a/crates/static-file/src/segments/headers.rs b/crates/static-file/src/segments/headers.rs index 4390ff6ed..2c7e62e50 100644 --- a/crates/static-file/src/segments/headers.rs +++ b/crates/static-file/src/segments/headers.rs @@ -3,12 +3,12 @@ use reth_db::{ cursor::DbCursorRO, database::Database, static_file::create_static_file_T1_T2_T3, tables, transaction::DbTx, RawKey, RawTable, }; -use reth_interfaces::provider::ProviderResult; use reth_primitives::{static_file::SegmentConfig, BlockNumber, StaticFileSegment}; use reth_provider::{ providers::{StaticFileProvider, StaticFileWriter}, DatabaseProviderRO, }; +use reth_storage_errors::provider::ProviderResult; use std::{ops::RangeInclusive, path::Path}; /// Static File segment responsible for [StaticFileSegment::Headers] part of data. diff --git a/crates/static-file/src/segments/mod.rs b/crates/static-file/src/segments/mod.rs index be3ca0e71..581a2cba7 100644 --- a/crates/static-file/src/segments/mod.rs +++ b/crates/static-file/src/segments/mod.rs @@ -12,7 +12,6 @@ pub use receipts::Receipts; use reth_db::{ cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx, RawKey, RawTable, }; -use reth_interfaces::provider::ProviderResult; use reth_nippy_jar::NippyJar; use reth_primitives::{ static_file::{ @@ -24,6 +23,7 @@ use reth_primitives::{ use reth_provider::{ providers::StaticFileProvider, DatabaseProviderRO, ProviderError, TransactionsProviderExt, }; +use reth_storage_errors::provider::ProviderResult; use std::{ops::RangeInclusive, path::Path}; pub(crate) type Rows = [Vec>; COLUMNS]; diff --git a/crates/static-file/src/segments/receipts.rs b/crates/static-file/src/segments/receipts.rs index 61b191c18..85b4863d8 100644 --- a/crates/static-file/src/segments/receipts.rs +++ b/crates/static-file/src/segments/receipts.rs @@ -3,7 +3,6 @@ use reth_db::{ cursor::DbCursorRO, database::Database, static_file::create_static_file_T1, tables, transaction::DbTx, }; -use reth_interfaces::provider::{ProviderError, ProviderResult}; use reth_primitives::{ static_file::{SegmentConfig, SegmentHeader}, BlockNumber, StaticFileSegment, TxNumber, @@ -12,6 +11,7 @@ use reth_provider::{ providers::{StaticFileProvider, StaticFileWriter}, BlockReader, DatabaseProviderRO, TransactionsProviderExt, }; +use reth_storage_errors::provider::{ProviderError, ProviderResult}; use std::{ops::RangeInclusive, path::Path}; /// Static File segment responsible for [StaticFileSegment::Receipts] part of data. diff --git a/crates/static-file/src/segments/transactions.rs b/crates/static-file/src/segments/transactions.rs index 36110243c..ba1745077 100644 --- a/crates/static-file/src/segments/transactions.rs +++ b/crates/static-file/src/segments/transactions.rs @@ -3,7 +3,6 @@ use reth_db::{ cursor::DbCursorRO, database::Database, static_file::create_static_file_T1, tables, transaction::DbTx, }; -use reth_interfaces::provider::{ProviderError, ProviderResult}; use reth_primitives::{ static_file::{SegmentConfig, SegmentHeader}, BlockNumber, StaticFileSegment, TxNumber, @@ -12,6 +11,7 @@ use reth_provider::{ providers::{StaticFileProvider, StaticFileWriter}, BlockReader, DatabaseProviderRO, TransactionsProviderExt, }; +use reth_storage_errors::provider::{ProviderError, ProviderResult}; use std::{ops::RangeInclusive, path::Path}; /// Static File segment responsible for [StaticFileSegment::Transactions] part of data. diff --git a/crates/static-file/src/static_file_producer.rs b/crates/static-file/src/static_file_producer.rs index 4eb082561..ef66a12ed 100644 --- a/crates/static-file/src/static_file_producer.rs +++ b/crates/static-file/src/static_file_producer.rs @@ -4,12 +4,12 @@ use crate::{segments, segments::Segment, StaticFileProducerEvent}; use parking_lot::Mutex; use rayon::prelude::*; use reth_db::database::Database; -use reth_interfaces::RethResult; use reth_primitives::{static_file::HighestStaticFiles, BlockNumber, PruneModes}; use reth_provider::{ providers::{StaticFileProvider, StaticFileWriter}, ProviderFactory, }; +use reth_storage_errors::provider::ProviderResult; use reth_tokio_util::{EventSender, EventStream}; use std::{ ops::{Deref, RangeInclusive}, @@ -19,7 +19,7 @@ use std::{ use tracing::{debug, trace}; /// Result of [StaticFileProducerInner::run] execution. -pub type StaticFileProducerResult = RethResult; +pub type StaticFileProducerResult = ProviderResult; /// The [StaticFileProducer] instance itself with the result of [StaticFileProducerInner::run] pub type StaticFileProducerWithResult = (StaticFileProducer, StaticFileProducerResult); @@ -154,7 +154,7 @@ impl StaticFileProducerInner { segments.push((Box::new(segments::Receipts), block_range)); } - segments.par_iter().try_for_each(|(segment, block_range)| -> RethResult<()> { + segments.par_iter().try_for_each(|(segment, block_range)| -> ProviderResult<()> { debug!(target: "static_file", segment = %segment.segment(), ?block_range, "StaticFileProducer segment"); let start = Instant::now(); @@ -189,7 +189,7 @@ impl StaticFileProducerInner { pub fn get_static_file_targets( &self, finalized_block_numbers: HighestStaticFiles, - ) -> RethResult { + ) -> ProviderResult { let highest_static_files = self.static_file_provider.get_highest_static_files(); let targets = StaticFileTargets { @@ -252,7 +252,6 @@ mod tests { generators, generators::{random_block_range, random_receipt}, }, - RethError, }; use reth_primitives::{ static_file::HighestStaticFiles, PruneModes, StaticFileSegment, B256, U256, @@ -373,7 +372,7 @@ mod tests { ); assert_matches!( static_file_producer.run(targets), - Err(RethError::Provider(ProviderError::BlockBodyIndicesNotFound(4))) + Err(ProviderError::BlockBodyIndicesNotFound(4)) ); assert_eq!( static_file_provider.get_highest_static_files(),