@@ -10,17 +10,20 @@ use op_revm::{OpSpecId, l1block::L1BlockInfo};
1010use reth_optimism_evm:: extract_l1_info_from_tx;
1111use reth_rpc_eth_types:: { EthApiError , RpcInvalidTransactionError } ;
1212
13+ /// Account info for a given address
1314pub struct AccountInfo {
1415 pub balance : U256 ,
1516 pub nonce : u64 ,
1617 pub code_hash : B256 ,
1718}
1819
20+ /// Interface for fetching account info for a given address
1921#[ async_trait]
2022pub trait AccountInfoLookup : Send + Sync {
2123 async fn fetch_account_info ( & self , address : Address ) -> Result < AccountInfo > ;
2224}
2325
26+ /// Implementation of the `AccountInfoLookup` trait for the `RootProvider`
2427#[ async_trait]
2528impl AccountInfoLookup for RootProvider < Optimism > {
2629 async fn fetch_account_info ( & self , address : Address ) -> Result < AccountInfo > {
@@ -33,11 +36,13 @@ impl AccountInfoLookup for RootProvider<Optimism> {
3336 }
3437}
3538
39+ /// Interface for fetching L1 block info for a given block number
3640#[ async_trait]
3741pub trait L1BlockInfoLookup : Send + Sync {
3842 async fn fetch_l1_block_info ( & self ) -> Result < L1BlockInfo > ;
3943}
4044
45+ /// Implementation of the `L1BlockInfoLookup` trait for the `RootProvider`
4146#[ async_trait]
4247impl L1BlockInfoLookup for RootProvider < Optimism > {
4348 async fn fetch_l1_block_info ( & self ) -> Result < L1BlockInfo > {
@@ -62,6 +67,13 @@ impl L1BlockInfoLookup for RootProvider<Optimism> {
6267 }
6368}
6469
70+ /// Helper function to validate a transaction. A valid transaction must satisfy the following criteria:
71+ /// - If the transaction is not EIP-4844
72+ /// - If the transaction is not a cross chain tx
73+ /// - If the transaction is a 7702 tx, then the account is a 7702 account
74+ /// - If the transaction's nonce is the latest
75+ /// - If the transaction's execution cost is less than the account's balance
76+ /// - If the transaction's L1 gas cost is less than the account's balance
6577pub async fn validate_tx < T : Transaction > (
6678 account : AccountInfo ,
6779 txn : & Recovered < T > ,
0 commit comments