Skip to main content

reth_engine_tree/tree/
types.rs

1//! Shared types for blockchain tree validation.
2
3use crate::tree::error::InsertPayloadError;
4use alloy_eip7928::bal::RawBal;
5use reth_chain_state::{ExecutedBlock, ExecutionTimingStats};
6use reth_primitives_traits::{BlockTy, NodePrimitives};
7
8/// Result of block or payload validation.
9pub type ValidationOutcome<N, E = InsertPayloadError<BlockTy<N>>> = Result<ValidationOutput<N>, E>;
10
11/// Result type for block validation with optional timing stats.
12pub(crate) type InsertPayloadResult<N> =
13    Result<ValidationOutput<N>, InsertPayloadError<<N as NodePrimitives>::Block>>;
14
15/// Output of block or payload validation.
16#[derive(Clone, Debug)]
17pub struct ValidationOutput<N: NodePrimitives> {
18    /// The executed block produced by validation.
19    pub executed_block: ExecutedBlock<N>,
20    /// Optional execution timing stats collected during validation.
21    pub execution_timing_stats: Option<Box<ExecutionTimingStats>>,
22    /// Validated raw block access list carried by the payload.
23    pub raw_bal: Option<RawBal>,
24}
25
26impl<N: NodePrimitives> ValidationOutput<N> {
27    /// Creates a new validation output.
28    pub const fn new(
29        executed_block: ExecutedBlock<N>,
30        execution_timing_stats: Option<Box<ExecutionTimingStats>>,
31    ) -> Self {
32        Self { executed_block, execution_timing_stats, raw_bal: None }
33    }
34
35    /// Sets the validated raw block access list carried by the payload.
36    pub fn with_raw_bal(mut self, raw_bal: Option<RawBal>) -> Self {
37        self.raw_bal = raw_bal;
38        self
39    }
40}