reth_payload_primitives/
error.rs1use alloy_primitives::B256;
4use alloy_rpc_types_engine::ForkchoiceUpdateError;
5use reth_errors::{ProviderError, RethError};
6use revm_primitives::EVMError;
7use tokio::sync::oneshot;
8
9#[derive(Debug, thiserror::Error)]
11pub enum PayloadBuilderError {
12 #[error("missing parent header: {0}")]
14 MissingParentHeader(B256),
15 #[error("missing parent block {0}")]
17 MissingParentBlock(B256),
18 #[error("sender has been dropped")]
20 ChannelClosed,
21 #[error("missing payload")]
23 MissingPayload,
24 #[error(transparent)]
26 Internal(#[from] RethError),
27 #[error("evm execution error: {0}")]
29 EvmExecutionError(EVMError<ProviderError>),
30 #[error(transparent)]
32 Other(Box<dyn core::error::Error + Send + Sync>),
33}
34
35impl PayloadBuilderError {
36 pub fn other<E>(error: E) -> Self
38 where
39 E: core::error::Error + Send + Sync + 'static,
40 {
41 Self::Other(Box::new(error))
42 }
43}
44
45impl From<ProviderError> for PayloadBuilderError {
46 fn from(error: ProviderError) -> Self {
47 Self::Internal(RethError::Provider(error))
48 }
49}
50
51impl From<oneshot::error::RecvError> for PayloadBuilderError {
52 fn from(_: oneshot::error::RecvError) -> Self {
53 Self::ChannelClosed
54 }
55}
56
57#[derive(thiserror::Error, Debug)]
63pub enum EngineObjectValidationError {
64 #[error("Payload validation error: {0}")]
67 Payload(VersionSpecificValidationError),
68
69 #[error("Payload attributes validation error: {0}")]
72 PayloadAttributes(VersionSpecificValidationError),
73
74 #[error("Unsupported fork")]
78 UnsupportedFork,
79 #[error("Invalid params: {0}")]
81 InvalidParams(#[from] Box<dyn core::error::Error + Send + Sync>),
82}
83
84#[derive(thiserror::Error, Debug)]
88pub enum VersionSpecificValidationError {
89 #[error("parent beacon block root not supported before V3")]
92 ParentBeaconBlockRootNotSupportedBeforeV3,
93 #[error("withdrawals not supported in V1")]
95 WithdrawalsNotSupportedInV1,
96 #[error("no withdrawals post-Shanghai")]
99 NoWithdrawalsPostShanghai,
100 #[error("withdrawals pre-Shanghai")]
103 HasWithdrawalsPreShanghai,
104 #[error("no parent beacon block root post-cancun")]
107 NoParentBeaconBlockRootPostCancun,
108}
109
110impl EngineObjectValidationError {
111 pub fn invalid_params<E>(error: E) -> Self
113 where
114 E: core::error::Error + Send + Sync + 'static,
115 {
116 Self::InvalidParams(Box::new(error))
117 }
118}
119
120#[derive(thiserror::Error, Debug)]
122pub enum InvalidPayloadAttributesError {
123 #[error("parent beacon block root not supported before V3")]
125 InvalidTimestamp,
126 #[error("Invalid params: {0}")]
128 InvalidParams(#[from] Box<dyn core::error::Error + Send + Sync>),
129}
130
131impl From<InvalidPayloadAttributesError> for ForkchoiceUpdateError {
132 fn from(_: InvalidPayloadAttributesError) -> Self {
133 Self::UpdatedInvalidPayloadAttributes
134 }
135}