refactor: remove PruneModes from batch executor (#14025)

This commit is contained in:
Arsenii Kulikov
2025-01-29 15:50:37 +04:00
committed by GitHub
parent 2652ec8af5
commit 5fcefcea8c
17 changed files with 61 additions and 180 deletions

View File

@ -20,7 +20,6 @@ reth-execution-types.workspace = true
reth-metrics = { workspace = true, optional = true }
reth-primitives.workspace = true
reth-primitives-traits.workspace = true
reth-prune-types.workspace = true
reth-revm.workspace = true
reth-storage-errors.workspace = true
@ -69,5 +68,4 @@ test-utils = [
"reth-primitives-traits/test-utils",
"reth-revm/test-utils",
"revm/test-utils",
"reth-prune-types/test-utils",
]

View File

@ -6,8 +6,6 @@ use crate::{
execute::{BatchExecutor, BlockExecutorProvider, Executor},
system_calls::OnStateHook,
};
use alloy_primitives::BlockNumber;
use reth_prune_types::PruneModes;
use reth_storage_errors::provider::ProviderError;
use revm_primitives::db::Database;
@ -119,20 +117,6 @@ where
}
}
fn set_tip(&mut self, tip: BlockNumber) {
match self {
Self::Left(a) => a.set_tip(tip),
Self::Right(b) => b.set_tip(tip),
}
}
fn set_prune_modes(&mut self, prune_modes: PruneModes) {
match self {
Self::Left(a) => a.set_prune_modes(prune_modes),
Self::Right(b) => b.set_prune_modes(prune_modes),
}
}
fn size_hint(&self) -> Option<usize> {
match self {
Self::Left(a) => a.size_hint(),

View File

@ -13,12 +13,11 @@ use alloc::{boxed::Box, vec::Vec};
use alloy_eips::eip7685::Requests;
use alloy_primitives::{
map::{DefaultHashBuilder, HashMap},
Address, BlockNumber,
Address,
};
use core::fmt::Display;
use reth_consensus::ConsensusError;
use reth_primitives::{NodePrimitives, Receipt, RecoveredBlock};
use reth_prune_types::PruneModes;
use reth_revm::batch::BlockBatchRecord;
use revm::{
db::{states::bundle_state::BundleRetention, BundleState},
@ -113,16 +112,6 @@ pub trait BatchExecutor<DB> {
/// Finishes the batch and return the final state.
fn finalize(self) -> Self::Output;
/// Set the expected tip of the batch.
///
/// This can be used to optimize state pruning during execution.
fn set_tip(&mut self, tip: BlockNumber);
/// Set the prune modes.
///
/// They are used to determine which parts of the state should be kept during execution.
fn set_prune_modes(&mut self, prune_modes: PruneModes);
/// The size hint of the batch's tracked state size.
///
/// This is used to optimize DB commits depending on the size of the state.
@ -429,9 +418,7 @@ where
self.strategy.validate_block_post_execution(block, &receipts, &requests)?;
// prepare the state according to the prune mode
let retention = self.batch_record.bundle_retention(block.header().number());
self.strategy.state_mut().merge_transitions(retention);
self.strategy.state_mut().merge_transitions(BundleRetention::Reverts);
// store receipts in the set
self.batch_record.save_receipts(receipts);
@ -451,14 +438,6 @@ where
)
}
fn set_tip(&mut self, tip: BlockNumber) {
self.batch_record.set_tip(tip);
}
fn set_prune_modes(&mut self, prune_modes: PruneModes) {
self.batch_record.set_prune_modes(prune_modes);
}
fn size_hint(&self) -> Option<usize> {
Some(self.strategy.state_ref().bundle_state.size_hint())
}
@ -581,14 +560,6 @@ mod tests {
todo!()
}
fn set_tip(&mut self, _tip: BlockNumber) {
todo!()
}
fn set_prune_modes(&mut self, _prune_modes: PruneModes) {
todo!()
}
fn size_hint(&self) -> Option<usize> {
None
}

View File

@ -1,11 +1,9 @@
//! A no operation block executor implementation.
use alloy_primitives::BlockNumber;
use core::fmt::Display;
use reth_execution_errors::BlockExecutionError;
use reth_execution_types::{BlockExecutionOutput, ExecutionOutcome};
use reth_primitives::{NodePrimitives, RecoveredBlock};
use reth_prune_types::PruneModes;
use reth_storage_errors::provider::ProviderError;
use revm::State;
use revm_primitives::db::Database;
@ -89,10 +87,6 @@ impl<DB, P: NodePrimitives> BatchExecutor<DB> for NoopBlockExecutorProvider<P> {
unreachable!()
}
fn set_tip(&mut self, _: BlockNumber) {}
fn set_prune_modes(&mut self, _: PruneModes) {}
fn size_hint(&self) -> Option<usize> {
None
}

View File

@ -8,12 +8,10 @@ use crate::{
system_calls::OnStateHook,
};
use alloy_eips::eip7685::Requests;
use alloy_primitives::BlockNumber;
use parking_lot::Mutex;
use reth_execution_errors::BlockExecutionError;
use reth_execution_types::ExecutionOutcome;
use reth_primitives::{EthPrimitives, NodePrimitives, Receipt, Receipts, RecoveredBlock};
use reth_prune_types::PruneModes;
use reth_storage_errors::provider::ProviderError;
use revm::State;
use revm_primitives::db::Database;
@ -109,10 +107,6 @@ impl<DB> BatchExecutor<DB> for MockExecutorProvider {
self.exec_results.lock().pop().unwrap()
}
fn set_tip(&mut self, _: BlockNumber) {}
fn set_prune_modes(&mut self, _: PruneModes) {}
fn size_hint(&self) -> Option<usize> {
None
}