feat: extends engine validator (#12900)

This commit is contained in:
Matthias Seitz
2024-11-27 12:31:24 +01:00
committed by GitHub
parent 51afa4cdc9
commit b33757fcbe
10 changed files with 228 additions and 81 deletions

View File

@ -1,6 +1,7 @@
//! Error types emitted by types or implementations of this crate.
use alloy_primitives::B256;
use alloy_rpc_types_engine::ForkchoiceUpdateError;
use reth_errors::{ProviderError, RethError};
use revm_primitives::EVMError;
use tokio::sync::oneshot;
@ -53,7 +54,7 @@ impl From<oneshot::error::RecvError> for PayloadBuilderError {
}
}
/// Thrown when the payload or attributes are known to be invalid before processing.
/// Thrown when the payload or attributes are known to be invalid __before__ processing.
///
/// This is used mainly for
/// [`validate_version_specific_fields`](crate::validate_version_specific_fields), which validates
@ -115,3 +116,20 @@ impl EngineObjectValidationError {
Self::InvalidParams(Box::new(error))
}
}
/// Thrown when validating the correctness of a payloadattributes object.
#[derive(thiserror::Error, Debug)]
pub enum InvalidPayloadAttributesError {
/// Thrown if the timestamp of the payload attributes is invalid according to the engine specs.
#[error("parent beacon block root not supported before V3")]
InvalidTimestamp,
/// Another type of error that is not covered by the above variants.
#[error("Invalid params: {0}")]
InvalidParams(#[from] Box<dyn core::error::Error + Send + Sync>),
}
impl From<InvalidPayloadAttributesError> for ForkchoiceUpdateError {
fn from(_: InvalidPayloadAttributesError) -> Self {
Self::UpdatedInvalidPayloadAttributes
}
}

View File

@ -9,7 +9,10 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
mod error;
pub use error::{EngineObjectValidationError, PayloadBuilderError, VersionSpecificValidationError};
pub use error::{
EngineObjectValidationError, InvalidPayloadAttributesError, PayloadBuilderError,
VersionSpecificValidationError,
};
/// Contains traits to abstract over payload attributes types and default implementations of the
/// [`PayloadAttributes`] trait for ethereum mainnet and optimism types.