@@ -2,16 +2,20 @@ use alloy_evm::{FromRecoveredTx, FromTxWithEncoded};
22use alloy_primitives:: { Address , Bytes , U256 } ;
33use ev_primitives:: { Call , EvTxEnvelope } ;
44use reth_evm:: TransactionEnv ;
5- use reth_revm:: revm:: context:: TxEnv ;
6- use reth_revm:: revm:: context_interface:: either:: Either ;
7- use reth_revm:: revm:: context_interface:: transaction:: {
8- AccessList , AccessListItem , RecoveredAuthorization , SignedAuthorization ,
9- Transaction as RevmTransaction ,
5+ use reth_revm:: revm:: {
6+ context:: TxEnv ,
7+ context_interface:: {
8+ either:: Either ,
9+ transaction:: {
10+ AccessList , AccessListItem , RecoveredAuthorization , SignedAuthorization ,
11+ Transaction as RevmTransaction ,
12+ } ,
13+ } ,
14+ handler:: SystemCallTx ,
15+ primitives:: { Address as RevmAddress , Bytes as RevmBytes , TxKind , B256 } ,
1016} ;
11- use reth_revm:: revm:: handler:: SystemCallTx ;
12- use reth_revm:: revm:: primitives:: { Address as RevmAddress , Bytes as RevmBytes , TxKind , B256 } ;
1317
14- /// Transaction environment wrapper that supports EvTxEnvelope conversions.
18+ /// Transaction environment wrapper that supports ` EvTxEnvelope` conversions.
1519#[ derive( Clone , Debug , Default , PartialEq , Eq ) ]
1620pub struct EvTxEnv {
1721 inner : TxEnv ,
@@ -23,14 +27,13 @@ pub struct EvTxEnv {
2327
2428impl EvTxEnv {
2529 /// Wrap a `TxEnv` with EV-specific metadata.
26- pub fn new ( inner : TxEnv ) -> Self {
27- let batch_value = inner. value ;
30+ pub const fn new ( inner : TxEnv ) -> Self {
2831 Self {
32+ batch_value : inner. value ,
2933 inner,
3034 sponsor : None ,
3135 sponsor_signature_invalid : false ,
3236 calls : Vec :: new ( ) ,
33- batch_value,
3437 }
3538 }
3639
@@ -198,16 +201,16 @@ impl TransactionEnv for EvTxEnv {
198201 }
199202}
200203
201- impl alloy_evm:: ToTxEnv < EvTxEnv > for EvTxEnv {
202- fn to_tx_env ( & self ) -> EvTxEnv {
204+ impl alloy_evm:: ToTxEnv < Self > for EvTxEnv {
205+ fn to_tx_env ( & self ) -> Self {
203206 self . clone ( )
204207 }
205208}
206209
207210impl FromRecoveredTx < EvTxEnvelope > for EvTxEnv {
208211 fn from_recovered_tx ( tx : & EvTxEnvelope , sender : Address ) -> Self {
209212 match tx {
210- EvTxEnvelope :: Ethereum ( inner) => EvTxEnv :: new ( TxEnv :: from_recovered_tx ( inner, sender) ) ,
213+ EvTxEnvelope :: Ethereum ( inner) => Self :: new ( TxEnv :: from_recovered_tx ( inner, sender) ) ,
211214 EvTxEnvelope :: EvNode ( ev) => {
212215 let ( sponsor, sponsor_signature_invalid) =
213216 if let Some ( signature) = ev. tx ( ) . fee_payer_signature . as_ref ( ) {
@@ -222,29 +225,32 @@ impl FromRecoveredTx<EvTxEnvelope> for EvTxEnv {
222225 let batch_value = calls
223226 . iter ( )
224227 . fold ( U256 :: ZERO , |acc, call| acc. saturating_add ( call. value ) ) ;
225- let mut env = TxEnv :: default ( ) ;
226- env. caller = sender;
227- env. gas_limit = ev. tx ( ) . gas_limit ;
228- env. gas_price = ev. tx ( ) . max_fee_per_gas ;
229- env. kind = ev
230- . tx ( )
231- . calls
232- . first ( )
233- . map ( |call| call. to )
234- . unwrap_or ( TxKind :: Create ) ;
235- env. value = batch_value;
236- env. data = ev
237- . tx ( )
238- . calls
239- . first ( )
240- . map ( |call| call. input . clone ( ) )
241- . unwrap_or_default ( ) ;
242- let mut tx_env = EvTxEnv :: new ( env) ;
243- tx_env. sponsor = sponsor;
244- tx_env. sponsor_signature_invalid = sponsor_signature_invalid;
245- tx_env. calls = calls;
246- tx_env. batch_value = batch_value;
247- tx_env
228+ let env = TxEnv {
229+ caller : sender,
230+ gas_limit : ev. tx ( ) . gas_limit ,
231+ gas_price : ev. tx ( ) . max_fee_per_gas ,
232+ kind : ev
233+ . tx ( )
234+ . calls
235+ . first ( )
236+ . map ( |call| call. to )
237+ . unwrap_or ( TxKind :: Create ) ,
238+ value : batch_value,
239+ data : ev
240+ . tx ( )
241+ . calls
242+ . first ( )
243+ . map ( |call| call. input . clone ( ) )
244+ . unwrap_or_default ( ) ,
245+ ..Default :: default ( )
246+ } ;
247+ Self {
248+ inner : env,
249+ sponsor,
250+ sponsor_signature_invalid,
251+ calls,
252+ batch_value,
253+ }
248254 }
249255 }
250256 }
@@ -262,7 +268,7 @@ impl SystemCallTx for EvTxEnv {
262268 system_contract_address : Address ,
263269 data : Bytes ,
264270 ) -> Self {
265- EvTxEnv :: new (
271+ Self :: new (
266272 TxEnv :: builder ( )
267273 . caller ( caller)
268274 . data ( data)
0 commit comments