diff --git a/crates/rpc/rpc/src/validation.rs b/crates/rpc/rpc/src/validation.rs index c3f2aab70bb9..b997dec1e015 100644 --- a/crates/rpc/rpc/src/validation.rs +++ b/crates/rpc/rpc/src/validation.rs @@ -30,60 +30,6 @@ use serde::{Deserialize, Serialize}; use std::{collections::HashSet, sync::Arc}; use tokio::sync::RwLock; -/// Configuration for validation API. -#[derive(Debug, Clone, Default, Eq, PartialEq, Serialize, Deserialize)] -pub struct ValidationApiConfig { - /// Disallowed addresses. - pub disallow: HashSet
, -} - -#[derive(Debug, thiserror::Error)] -pub enum ValidationApiError { - #[error("block gas limit mismatch: {_0}")] - GasLimitMismatch(GotExpected), - #[error("block gas used mismatch: {_0}")] - GasUsedMismatch(GotExpected), - #[error("block parent hash mismatch: {_0}")] - ParentHashMismatch(GotExpected), - #[error("block hash mismatch: {_0}")] - BlockHashMismatch(GotExpected), - #[error("missing latest block in database")] - MissingLatestBlock, - #[error("could not verify proposer payment")] - ProposerPayment, - #[error("invalid blobs bundle")] - InvalidBlobsBundle, - #[error("block accesses blacklisted address: {_0}")] - Blacklist(Address), - #[error(transparent)] - Blob(#[from] BlobTransactionValidationError), - #[error(transparent)] - Consensus(#[from] ConsensusError), - #[error(transparent)] - Provider(#[from] ProviderError), - #[error(transparent)] - Execution(#[from] BlockExecutionError), -} - -#[derive(Debug)] -pub struct ValidationApiInner { - /// The provider that can interact with the chain. - provider: Provider, - /// Consensus implementation. - consensus: Arc, - /// Execution payload validator. - payload_validator: ExecutionPayloadValidator, - /// Block executor factory. - executor_provider: E, - /// Set of disallowed addresses - disallow: HashSet
, - /// Cached state reads to avoid redundant disk I/O across multiple validation attempts - /// targeting the same state. Stores a tuple of (`block_hash`, `cached_reads`) for the - /// latest head block state. Uses async `RwLock` to safely handle concurrent validation - /// requests. - cached_state: RwLock<(B256, CachedReads)>, -} - /// The type that implements the `validation` rpc namespace trait #[derive(Debug, derive_more::Deref)] pub struct ValidationApi { @@ -486,3 +432,58 @@ where .to_rpc_result() } } + +#[derive(Debug)] +pub struct ValidationApiInner { + /// The provider that can interact with the chain. + provider: Provider, + /// Consensus implementation. + consensus: Arc, + /// Execution payload validator. + payload_validator: ExecutionPayloadValidator, + /// Block executor factory. + executor_provider: E, + /// Set of disallowed addresses + disallow: HashSet
, + /// Cached state reads to avoid redundant disk I/O across multiple validation attempts + /// targeting the same state. Stores a tuple of (`block_hash`, `cached_reads`) for the + /// latest head block state. Uses async `RwLock` to safely handle concurrent validation + /// requests. + cached_state: RwLock<(B256, CachedReads)>, +} + +/// Configuration for validation API. +#[derive(Debug, Clone, Default, Eq, PartialEq, Serialize, Deserialize)] +pub struct ValidationApiConfig { + /// Disallowed addresses. + pub disallow: HashSet
, +} + +/// Errors thrown by the validation API. +#[derive(Debug, thiserror::Error)] +pub enum ValidationApiError { + #[error("block gas limit mismatch: {_0}")] + GasLimitMismatch(GotExpected), + #[error("block gas used mismatch: {_0}")] + GasUsedMismatch(GotExpected), + #[error("block parent hash mismatch: {_0}")] + ParentHashMismatch(GotExpected), + #[error("block hash mismatch: {_0}")] + BlockHashMismatch(GotExpected), + #[error("missing latest block in database")] + MissingLatestBlock, + #[error("could not verify proposer payment")] + ProposerPayment, + #[error("invalid blobs bundle")] + InvalidBlobsBundle, + #[error("block accesses blacklisted address: {_0}")] + Blacklist(Address), + #[error(transparent)] + Blob(#[from] BlobTransactionValidationError), + #[error(transparent)] + Consensus(#[from] ConsensusError), + #[error(transparent)] + Provider(#[from] ProviderError), + #[error(transparent)] + Execution(#[from] BlockExecutionError), +}