refactor: remove PostExecutionInput (#14464)

This commit is contained in:
Arsenii Kulikov
2025-02-13 14:24:00 +04:00
committed by GitHub
parent f425a4dbcd
commit 46462ae0a6
18 changed files with 78 additions and 88 deletions

View File

@ -26,6 +26,8 @@ alloy-eips.workspace = true
serde = { workspace = true, optional = true }
serde_with = { workspace = true, optional = true }
derive_more.workspace = true
[dev-dependencies]
arbitrary.workspace = true
bincode.workspace = true
@ -65,4 +67,5 @@ std = [
"reth-trie-common/std",
"reth-ethereum-primitives/std",
"reth-execution-errors/std",
"derive_more/std",
]

View File

@ -13,17 +13,24 @@ pub struct BlockExecutionResult<T> {
pub gas_used: u64,
}
/// The output of an ethereum block.
///
/// Contains the state changes, transaction receipts, and total gas used in the block.
#[derive(Debug, Clone, PartialEq, Eq)]
/// [`BlockExecutionResult`] combined with state.
#[derive(
Debug,
Clone,
PartialEq,
Eq,
derive_more::AsRef,
derive_more::AsMut,
derive_more::Deref,
derive_more::DerefMut,
)]
pub struct BlockExecutionOutput<T> {
/// All the receipts of the transactions in the block.
#[as_ref]
#[as_mut]
#[deref]
#[deref_mut]
pub result: BlockExecutionResult<T>,
/// The changed state of the block after execution.
pub state: BundleState,
/// All the receipts of the transactions in the block.
pub receipts: Vec<T>,
/// All the EIP-7685 requests in the block.
pub requests: Requests,
/// The total gas used by the block.
pub gas_used: u64,
}

View File

@ -129,12 +129,12 @@ impl<T> ExecutionOutcome<T> {
}
/// Creates a new `ExecutionOutcome` from a single block execution result.
pub fn single(block_number: u64, result: BlockExecutionOutput<T>) -> Self {
pub fn single(block_number: u64, output: BlockExecutionOutput<T>) -> Self {
Self {
bundle: result.state,
receipts: vec![result.receipts],
bundle: output.state,
receipts: vec![output.result.receipts],
first_block: block_number,
requests: vec![result.requests],
requests: vec![output.result.requests],
}
}
@ -396,13 +396,8 @@ impl ExecutionOutcome {
}
impl<T> From<(BlockExecutionOutput<T>, BlockNumber)> for ExecutionOutcome<T> {
fn from(value: (BlockExecutionOutput<T>, BlockNumber)) -> Self {
Self {
bundle: value.0.state,
receipts: vec![value.0.receipts],
first_block: value.1,
requests: vec![value.0.requests],
}
fn from((output, block_number): (BlockExecutionOutput<T>, BlockNumber)) -> Self {
Self::single(block_number, output)
}
}

View File

@ -57,9 +57,9 @@ pub trait Executor<DB: Database>: Sized {
block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>,
) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
{
let BlockExecutionResult { receipts, requests, gas_used } = self.execute_one(block)?;
let result = self.execute_one(block)?;
let mut state = self.into_state();
Ok(BlockExecutionOutput { state: state.take_bundle(), receipts, requests, gas_used })
Ok(BlockExecutionOutput { state: state.take_bundle(), result })
}
/// Executes multiple inputs in the batch, and returns an aggregated [`ExecutionOutcome`].
@ -96,10 +96,10 @@ pub trait Executor<DB: Database>: Sized {
where
F: FnMut(&State<DB>),
{
let BlockExecutionResult { receipts, requests, gas_used } = self.execute_one(block)?;
let result = self.execute_one(block)?;
let mut state = self.into_state();
f(&state);
Ok(BlockExecutionOutput { state: state.take_bundle(), receipts, requests, gas_used })
Ok(BlockExecutionOutput { state: state.take_bundle(), result })
}
/// Executes the EVM with the given input and accepts a state hook closure that is invoked with
@ -112,10 +112,9 @@ pub trait Executor<DB: Database>: Sized {
where
F: OnStateHook + 'static,
{
let BlockExecutionResult { receipts, requests, gas_used } =
self.execute_one_with_state_hook(block, state_hook)?;
let result = self.execute_one_with_state_hook(block, state_hook)?;
let mut state = self.into_state();
Ok(BlockExecutionOutput { state: state.take_bundle(), receipts, requests, gas_used })
Ok(BlockExecutionOutput { state: state.take_bundle(), result })
}
/// Consumes the executor and returns the [`State`] containing all state changes.

View File

@ -83,12 +83,14 @@ impl<DB: Database> Executor<DB> for MockExecutorProvider {
self.exec_results.lock().pop().unwrap();
Ok(BlockExecutionOutput {
state: bundle,
receipts: receipts.into_iter().flatten().collect(),
requests: requests.into_iter().fold(Requests::default(), |mut reqs, req| {
reqs.extend(req);
reqs
}),
gas_used: 0,
result: BlockExecutionResult {
receipts: receipts.into_iter().flatten().collect(),
requests: requests.into_iter().fold(Requests::default(), |mut reqs, req| {
reqs.extend(req);
reqs
}),
gas_used: 0,
},
})
}