mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: run StaticFileProvider::check_consistency on start up (#8143)
This commit is contained in:
@ -131,11 +131,6 @@ pub enum BlockExecutionError {
|
||||
/// The fork on the other chain
|
||||
other_chain_fork: Box<BlockNumHash>,
|
||||
},
|
||||
/// Only used for TestExecutor
|
||||
///
|
||||
/// 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),
|
||||
|
||||
@ -245,7 +245,7 @@ mod tests {
|
||||
type Error = BlockExecutionError;
|
||||
|
||||
fn execute(self, _input: Self::Input<'_>) -> Result<Self::Output, Self::Error> {
|
||||
Err(BlockExecutionError::UnavailableForTest)
|
||||
Err(BlockExecutionError::msg("execution unavailable for tests"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, SpecId,
|
||||
|
||||
pub mod either;
|
||||
pub mod execute;
|
||||
pub mod noop;
|
||||
pub mod provider;
|
||||
|
||||
#[cfg(any(test, feature = "test-utils"))]
|
||||
|
||||
68
crates/evm/src/noop.rs
Normal file
68
crates/evm/src/noop.rs
Normal file
@ -0,0 +1,68 @@
|
||||
//! A no operation block executor implementation.
|
||||
|
||||
use reth_execution_errors::BlockExecutionError;
|
||||
use reth_primitives::{BlockNumber, BlockWithSenders, PruneModes, Receipt};
|
||||
use reth_storage_errors::provider::ProviderError;
|
||||
use revm_primitives::db::Database;
|
||||
|
||||
use crate::execute::{
|
||||
BatchBlockExecutionOutput, BatchExecutor, BlockExecutionInput, BlockExecutionOutput,
|
||||
BlockExecutorProvider, Executor,
|
||||
};
|
||||
|
||||
const UNAVAILABLE_FOR_NOOP: &str = "execution unavailable for noop";
|
||||
|
||||
/// A [BlockExecutorProvider] implementation that does nothing.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
#[non_exhaustive]
|
||||
pub struct NoopBlockExecutorProvider;
|
||||
|
||||
impl BlockExecutorProvider for NoopBlockExecutorProvider {
|
||||
type Executor<DB: Database<Error = ProviderError>> = Self;
|
||||
|
||||
type BatchExecutor<DB: Database<Error = ProviderError>> = Self;
|
||||
|
||||
fn executor<DB>(&self, _: DB) -> Self::Executor<DB>
|
||||
where
|
||||
DB: Database<Error = ProviderError>,
|
||||
{
|
||||
Self
|
||||
}
|
||||
|
||||
fn batch_executor<DB>(&self, _: DB, _: PruneModes) -> Self::BatchExecutor<DB>
|
||||
where
|
||||
DB: Database<Error = ProviderError>,
|
||||
{
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB> Executor<DB> for NoopBlockExecutorProvider {
|
||||
type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>;
|
||||
type Output = BlockExecutionOutput<Receipt>;
|
||||
type Error = BlockExecutionError;
|
||||
|
||||
fn execute(self, _: Self::Input<'_>) -> Result<Self::Output, Self::Error> {
|
||||
Err(BlockExecutionError::msg(UNAVAILABLE_FOR_NOOP))
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB> BatchExecutor<DB> for NoopBlockExecutorProvider {
|
||||
type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>;
|
||||
type Output = BatchBlockExecutionOutput;
|
||||
type Error = BlockExecutionError;
|
||||
|
||||
fn execute_and_verify_one(&mut self, _: Self::Input<'_>) -> Result<(), Self::Error> {
|
||||
Err(BlockExecutionError::msg(UNAVAILABLE_FOR_NOOP))
|
||||
}
|
||||
|
||||
fn finalize(self) -> Self::Output {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
fn set_tip(&mut self, _: BlockNumber) {}
|
||||
|
||||
fn size_hint(&self) -> Option<usize> {
|
||||
None
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user