chore: extract block execution errors (#8386)

This commit is contained in:
Matthias Seitz
2024-05-24 12:11:08 +02:00
committed by GitHub
parent 6df2b1c1e9
commit 9f61d1856f
17 changed files with 78 additions and 39 deletions

15
Cargo.lock generated
View File

@ -6962,8 +6962,9 @@ version = "0.2.0-beta.7"
dependencies = [
"futures-util",
"parking_lot 0.12.2",
"reth-interfaces",
"reth-execution-errors",
"reth-primitives",
"reth-storage-errors",
"revm",
"revm-primitives",
]
@ -6975,7 +6976,6 @@ dependencies = [
"alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=64feb9b)",
"reth-ethereum-consensus",
"reth-evm",
"reth-interfaces",
"reth-primitives",
"reth-revm",
"revm-primitives",
@ -6998,6 +6998,16 @@ dependencies = [
"tracing",
]
[[package]]
name = "reth-execution-errors"
version = "0.2.0-beta.7"
dependencies = [
"reth-consensus",
"reth-primitives",
"reth-storage-errors",
"thiserror",
]
[[package]]
name = "reth-exex"
version = "0.2.0-beta.7"
@ -7032,6 +7042,7 @@ version = "0.2.0-beta.7"
dependencies = [
"auto_impl",
"reth-consensus",
"reth-execution-errors",
"reth-fs-util",
"reth-network-api",
"reth-network-p2p",

View File

@ -17,6 +17,7 @@ members = [
"crates/ethereum/node",
"crates/etl/",
"crates/evm/",
"crates/evm/execution-errors",
"crates/exex/",
"crates/interfaces/",
"crates/metrics/",
@ -238,6 +239,7 @@ reth-etl = { path = "crates/etl" }
reth-evm = { path = "crates/evm" }
reth-evm-ethereum = { path = "crates/ethereum/evm" }
reth-evm-optimism = { path = "crates/optimism/evm" }
reth-execution-errors = { path = "crates/evm/execution-errors" }
reth-exex = { path = "crates/exex" }
reth-fs-util = { path = "crates/fs-util" }
reth-interfaces = { path = "crates/interfaces" }

View File

@ -15,7 +15,6 @@ workspace = true
reth-evm.workspace = true
reth-primitives.workspace = true
reth-revm.workspace = true
reth-interfaces.workspace = true
reth-ethereum-consensus.workspace = true
# Ethereum

View File

@ -7,15 +7,11 @@ use crate::{
use reth_ethereum_consensus::validate_block_post_execution;
use reth_evm::{
execute::{
BatchBlockExecutionOutput, BatchExecutor, BlockExecutionInput, BlockExecutionOutput,
BlockExecutorProvider, Executor,
BatchBlockExecutionOutput, BatchExecutor, BlockExecutionError, BlockExecutionInput,
BlockExecutionOutput, BlockExecutorProvider, BlockValidationError, Executor, ProviderError,
},
ConfigureEvm,
};
use reth_interfaces::{
executor::{BlockExecutionError, BlockValidationError},
provider::ProviderError,
};
use reth_primitives::{
BlockNumber, BlockWithSenders, ChainSpec, Hardfork, Header, PruneModes, Receipt, Withdrawals,
MAINNET, U256,

View File

@ -12,10 +12,12 @@ workspace = true
[dependencies]
# reth
reth-execution-errors.workspace = true
reth-primitives.workspace = true
revm-primitives.workspace = true
reth-storage-errors.workspace = true
revm.workspace = true
reth-interfaces.workspace = true
futures-util.workspace = true
parking_lot = { workspace = true, optional = true }

View File

@ -0,0 +1,18 @@
[package]
name = "reth-execution-errors"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
[lints]
workspace = true
[dependencies]
reth-consensus.workspace = true
reth-primitives.workspace = true
reth-storage-errors.workspace = true
thiserror.workspace = true

View File

@ -1,8 +1,21 @@
use crate::{provider::ProviderError, trie::StateRootError};
//! Commonly used error types used when doing block execution.
#![doc(
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
use reth_consensus::ConsensusError;
use reth_primitives::{revm_primitives::EVMError, BlockNumHash, PruneSegmentError, B256};
use reth_storage_errors::provider::ProviderError;
use thiserror::Error;
pub mod trie;
pub use trie::{StateRootError, StorageRootError};
/// Transaction validation errors
#[derive(Error, Debug, Clone, PartialEq, Eq)]
pub enum BlockValidationError {

View File

@ -1,7 +1,9 @@
use crate::db::DatabaseError;
//! Errors when computing the state root.
use reth_storage_errors::db::DatabaseError;
use thiserror::Error;
/// State root error.
/// State root errors.
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum StateRootError {
/// Internal database error.

View File

@ -4,8 +4,9 @@ use crate::execute::{
BatchBlockExecutionOutput, BatchExecutor, BlockExecutionInput, BlockExecutionOutput,
BlockExecutorProvider, Executor,
};
use reth_interfaces::{executor::BlockExecutionError, provider::ProviderError};
use reth_execution_errors::BlockExecutionError;
use reth_primitives::{BlockNumber, BlockWithSenders, PruneModes, Receipt};
use reth_storage_errors::provider::ProviderError;
use revm_primitives::db::Database;
// re-export Either

View File

@ -1,10 +1,12 @@
//! Traits for execution.
use reth_interfaces::{executor::BlockExecutionError, provider::ProviderError};
use reth_primitives::{BlockNumber, BlockWithSenders, PruneModes, Receipt, Receipts, U256};
use revm::db::BundleState;
use revm_primitives::db::Database;
pub use reth_execution_errors::{BlockExecutionError, BlockValidationError};
pub use reth_storage_errors::provider::ProviderError;
/// A general purpose executor trait that executes an input (e.g. block) and produces an output
/// (e.g. state changes and receipts).
///

View File

@ -5,8 +5,9 @@ use crate::execute::{
BlockExecutorProvider, Executor,
};
use parking_lot::Mutex;
use reth_interfaces::{executor::BlockExecutionError, provider::ProviderError};
use reth_execution_errors::BlockExecutionError;
use reth_primitives::{BlockNumber, BlockWithSenders, PruneModes, Receipt};
use reth_storage_errors::provider::ProviderError;
use revm_primitives::db::Database;
use std::sync::Arc;

View File

@ -11,12 +11,13 @@ repository.workspace = true
workspace = true
[dependencies]
reth-primitives.workspace = true
reth-consensus.workspace = true
reth-execution-errors.workspace = true
reth-fs-util.workspace = true
reth-network-api.workspace = true
reth-consensus.workspace = true
reth-storage-errors.workspace = true
reth-network-p2p.workspace = true
reth-primitives.workspace = true
reth-storage-errors.workspace = true
# misc
auto_impl.workspace = true

View File

@ -1,12 +1,10 @@
//! Error handling for the blockchain tree
use crate::{
executor::{BlockExecutionError, BlockValidationError},
provider::ProviderError,
RethError,
};
use crate::RethError;
use reth_consensus::ConsensusError;
use reth_execution_errors::{BlockExecutionError, BlockValidationError};
use reth_primitives::{BlockHash, BlockNumber, SealedBlock};
use reth_storage_errors::provider::ProviderError;
/// Various error cases that can occur when a block violates tree assumptions.
#[derive(Debug, Clone, Copy, thiserror::Error, Eq, PartialEq)]

View File

@ -1,12 +1,9 @@
use crate::{
blockchain_tree::error::{BlockchainTreeError, CanonicalError},
db::DatabaseError,
executor::BlockExecutionError,
provider::ProviderError,
};
use crate::blockchain_tree::error::{BlockchainTreeError, CanonicalError};
use reth_consensus::ConsensusError;
use reth_execution_errors::BlockExecutionError;
use reth_fs_util::FsPathError;
use reth_network_api::NetworkError;
use reth_storage_errors::{db::DatabaseError, provider::ProviderError};
/// Result alias for [`RethError`].
pub type RethResult<T> = Result<T, RethError>;

View File

@ -16,7 +16,7 @@
pub use reth_storage_errors::{db, provider};
/// Block Execution traits.
pub mod executor;
pub use reth_execution_errors as executor;
/// Possible errors when interacting with the chain.
mod error;
@ -26,7 +26,7 @@ pub use error::{RethError, RethResult};
pub use reth_network_p2p as p2p;
/// Trie error
pub mod trie;
pub use reth_execution_errors::trie;
/// Syncing related traits.
pub mod sync;

View File

@ -1,6 +1,6 @@
//! Error types for the Optimism EVM module.
use reth_interfaces::executor::BlockExecutionError;
use reth_evm::execute::BlockExecutionError;
/// Optimism Block Executor Errors
#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]

View File

@ -3,15 +3,11 @@
use crate::{l1::ensure_create2_deployer, OptimismBlockExecutionError, OptimismEvmConfig};
use reth_evm::{
execute::{
BatchBlockExecutionOutput, BatchExecutor, BlockExecutionInput, BlockExecutionOutput,
BlockExecutorProvider, Executor,
BatchBlockExecutionOutput, BatchExecutor, BlockExecutionError, BlockExecutionInput,
BlockExecutionOutput, BlockExecutorProvider, BlockValidationError, Executor, ProviderError,
},
ConfigureEvm,
};
use reth_interfaces::{
executor::{BlockExecutionError, BlockValidationError},
provider::ProviderError,
};
use reth_optimism_consensus::validate_block_post_execution;
use reth_primitives::{
BlockNumber, BlockWithSenders, ChainSpec, Hardfork, Header, PruneModes, Receipt, Receipts,