mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: make more descriptive errors instead of ProviderError (#7380)
Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
This commit is contained in:
@ -409,7 +409,7 @@ impl StorageInner {
|
||||
// calculate the state root
|
||||
let state_root = client
|
||||
.latest()
|
||||
.map_err(|_| BlockExecutionError::ProviderError)?
|
||||
.map_err(BlockExecutionError::LatestBlock)?
|
||||
.state_root(bundle_state.state())
|
||||
.unwrap();
|
||||
header.state_root = state_root;
|
||||
@ -439,7 +439,9 @@ impl StorageInner {
|
||||
|
||||
// now execute the block
|
||||
let db = State::builder()
|
||||
.with_database_boxed(Box::new(StateProviderDatabase::new(client.latest().unwrap())))
|
||||
.with_database_boxed(Box::new(StateProviderDatabase::new(
|
||||
client.latest().map_err(BlockExecutionError::LatestBlock)?,
|
||||
)))
|
||||
.with_bundle_update()
|
||||
.build();
|
||||
let mut executor = EVMProcessor::new_with_state(chain_spec.clone(), db, evm_config);
|
||||
|
||||
@ -248,7 +248,7 @@ impl InsertBlockErrorKind {
|
||||
true
|
||||
}
|
||||
// these are internal errors, not caused by an invalid block
|
||||
BlockExecutionError::ProviderError |
|
||||
BlockExecutionError::LatestBlock(_) |
|
||||
BlockExecutionError::Pruning(_) |
|
||||
BlockExecutionError::CanonicalRevert { .. } |
|
||||
BlockExecutionError::CanonicalCommit { .. } |
|
||||
|
||||
@ -70,8 +70,8 @@ mod size_asserts {
|
||||
};
|
||||
}
|
||||
|
||||
static_assert_size!(RethError, 56);
|
||||
static_assert_size!(BlockExecutionError, 48);
|
||||
static_assert_size!(RethError, 64);
|
||||
static_assert_size!(BlockExecutionError, 56);
|
||||
static_assert_size!(ConsensusError, 48);
|
||||
static_assert_size!(DatabaseError, 40);
|
||||
static_assert_size!(ProviderError, 48);
|
||||
|
||||
@ -88,9 +88,6 @@ pub enum BlockExecutionError {
|
||||
/// Pruning error, transparently wrapping `PruneSegmentError`
|
||||
#[error(transparent)]
|
||||
Pruning(#[from] PruneSegmentError),
|
||||
/// Error representing a provider error
|
||||
#[error("provider error")]
|
||||
ProviderError,
|
||||
/// Transaction error on revert with inner details
|
||||
#[error("transaction error on revert: {inner}")]
|
||||
CanonicalRevert {
|
||||
@ -118,6 +115,9 @@ pub enum BlockExecutionError {
|
||||
/// Note: this is not feature gated for convenience.
|
||||
#[error("execution unavailable for tests")]
|
||||
UnavailableForTest,
|
||||
/// Error when fetching latest block state.
|
||||
#[error(transparent)]
|
||||
LatestBlock(#[from] ProviderError),
|
||||
|
||||
/// Optimism Block Executor Errors
|
||||
#[cfg(feature = "optimism")]
|
||||
@ -141,6 +141,9 @@ pub enum OptimismBlockExecutionError {
|
||||
/// Thrown when a blob transaction is included in a sequencer's block.
|
||||
#[error("blob transaction included in sequencer block")]
|
||||
BlobTransactionRejected,
|
||||
/// Thrown when a database account could not be loaded.
|
||||
#[error("failed to load account {0}")]
|
||||
AccountLoadFailed(reth_primitives::Address),
|
||||
}
|
||||
|
||||
impl BlockExecutionError {
|
||||
|
||||
@ -2,6 +2,7 @@ use crate::processor::{compare_receipts_root_and_logs_bloom, EVMProcessor};
|
||||
use reth_interfaces::executor::{
|
||||
BlockExecutionError, BlockValidationError, OptimismBlockExecutionError,
|
||||
};
|
||||
|
||||
use reth_node_api::ConfigureEvm;
|
||||
use reth_primitives::{
|
||||
proofs::calculate_receipt_root_optimism, revm_primitives::ResultAndState, BlockWithSenders,
|
||||
@ -145,7 +146,11 @@ where
|
||||
.map(|acc| acc.account_info().unwrap_or_default())
|
||||
})
|
||||
.transpose()
|
||||
.map_err(|_| BlockExecutionError::ProviderError)?;
|
||||
.map_err(|_| {
|
||||
BlockExecutionError::OptimismBlockExecution(
|
||||
OptimismBlockExecutionError::AccountLoadFailed(*sender),
|
||||
)
|
||||
})?;
|
||||
|
||||
// Execute transaction.
|
||||
let ResultAndState { result, state } = self.transact(transaction, *sender)?;
|
||||
|
||||
Reference in New Issue
Block a user