feat: rm txmeta associated type (#8138)

This commit is contained in:
Matthias Seitz
2024-05-07 17:28:53 +02:00
committed by GitHub
parent bcb0bff382
commit 05e434eae3
7 changed files with 29 additions and 70 deletions

View File

@ -9,15 +9,15 @@ use reth_evm::{
BatchBlockExecutionOutput, BatchExecutor, BlockExecutionInput, BlockExecutionOutput,
BlockExecutorProvider, Executor,
},
ConfigureEvm, ConfigureEvmEnv,
ConfigureEvm,
};
use reth_interfaces::{
executor::{BlockExecutionError, BlockValidationError},
provider::ProviderError,
};
use reth_primitives::{
BlockNumber, BlockWithSenders, Bytes, ChainSpec, GotExpected, Hardfork, Header, PruneModes,
Receipt, Receipts, TxType, Withdrawals, U256,
BlockNumber, BlockWithSenders, ChainSpec, GotExpected, Hardfork, Header, PruneModes, Receipt,
Receipts, TxType, Withdrawals, U256,
};
use reth_revm::{
batch::{BlockBatchRecord, BlockExecutorStats},
@ -56,7 +56,6 @@ impl<EvmConfig> OpExecutorProvider<EvmConfig> {
impl<EvmConfig> OpExecutorProvider<EvmConfig>
where
EvmConfig: ConfigureEvm,
EvmConfig: ConfigureEvmEnv<TxMeta = Bytes>,
{
fn op_executor<DB>(&self, db: DB) -> OpBlockExecutor<EvmConfig, DB>
where
@ -73,7 +72,6 @@ where
impl<EvmConfig> BlockExecutorProvider for OpExecutorProvider<EvmConfig>
where
EvmConfig: ConfigureEvm,
EvmConfig: ConfigureEvmEnv<TxMeta = Bytes>,
{
type Executor<DB: Database<Error = ProviderError>> = OpBlockExecutor<EvmConfig, DB>;
@ -110,7 +108,6 @@ struct OpEvmExecutor<EvmConfig> {
impl<EvmConfig> OpEvmExecutor<EvmConfig>
where
EvmConfig: ConfigureEvm,
EvmConfig: ConfigureEvmEnv<TxMeta = Bytes>,
{
/// Executes the transactions in the block and returns the receipts.
///
@ -182,9 +179,7 @@ where
.transpose()
.map_err(|_| OptimismBlockExecutionError::AccountLoadFailed(*sender))?;
let mut buf = Vec::with_capacity(transaction.length_without_header());
transaction.encode_enveloped(&mut buf);
EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender, buf.into());
EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender);
// Execute transaction.
let ResultAndState { result, state } = evm.transact().map_err(move |err| {
@ -274,8 +269,6 @@ impl<EvmConfig, DB> OpBlockExecutor<EvmConfig, DB> {
impl<EvmConfig, DB> OpBlockExecutor<EvmConfig, DB>
where
EvmConfig: ConfigureEvm,
// TODO(mattsse): get rid of this
EvmConfig: ConfigureEvmEnv<TxMeta = Bytes>,
DB: Database<Error = ProviderError>,
{
/// Configures a new evm configuration and block environment for the given block.
@ -375,7 +368,6 @@ where
impl<EvmConfig, DB> Executor<DB> for OpBlockExecutor<EvmConfig, DB>
where
EvmConfig: ConfigureEvm,
EvmConfig: ConfigureEvmEnv<TxMeta = Bytes>,
DB: Database<Error = ProviderError>,
{
type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>;
@ -428,8 +420,6 @@ impl<EvmConfig, DB> OpBatchExecutor<EvmConfig, DB> {
impl<EvmConfig, DB> BatchExecutor<DB> for OpBatchExecutor<EvmConfig, DB>
where
EvmConfig: ConfigureEvm,
// TODO: get rid of this
EvmConfig: ConfigureEvmEnv<TxMeta = Bytes>,
DB: Database<Error = ProviderError>,
{
type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>;

View File

@ -13,7 +13,7 @@ use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
use reth_primitives::{
revm::{config::revm_spec, env::fill_op_tx_env},
revm_primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv},
Address, Bytes, ChainSpec, Head, Header, Transaction, U256,
Address, ChainSpec, Head, Header, TransactionSigned, U256,
};
use reth_revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector};
@ -32,13 +32,10 @@ pub use error::OptimismBlockExecutionError;
pub struct OptimismEvmConfig;
impl ConfigureEvmEnv for OptimismEvmConfig {
type TxMeta = Bytes;
fn fill_tx_env<T>(tx_env: &mut TxEnv, transaction: T, sender: Address, meta: Bytes)
where
T: AsRef<Transaction>,
{
fill_op_tx_env(tx_env, transaction, sender, meta);
fn fill_tx_env(tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) {
let mut buf = Vec::with_capacity(transaction.length_without_header());
transaction.encode_enveloped(&mut buf);
fill_op_tx_env(tx_env, transaction, sender, buf.into());
}
fn fill_cfg_env(