1- use alloy_consensus:: private:: alloy_eips:: { BlockId , BlockNumberOrTag } ;
2- use alloy_consensus:: { Transaction , Typed2718 , constants:: KECCAK_EMPTY , transaction:: Recovered } ;
3- use alloy_primitives:: { Address , B256 , U256 } ;
4- use alloy_provider:: { Provider , RootProvider } ;
5- use async_trait:: async_trait;
1+ use alloy_consensus:: { Transaction , constants:: KECCAK_EMPTY , transaction:: Recovered } ;
2+ use alloy_primitives:: { B256 , U256 } ;
63use jsonrpsee:: core:: RpcResult ;
74use op_alloy_consensus:: interop:: CROSS_L2_INBOX_ADDRESS ;
8- use op_alloy_network:: Optimism ;
95use op_revm:: { OpSpecId , l1block:: L1BlockInfo } ;
10- use reth_optimism_evm:: extract_l1_info_from_tx;
11- use reth_rpc_eth_types:: { EthApiError , RpcInvalidTransactionError , SignError } ;
6+ use reth_rpc_eth_types:: { EthApiError , RpcInvalidTransactionError } ;
127use tracing:: warn;
138
149/// Account info for a given address
@@ -18,64 +13,6 @@ pub struct AccountInfo {
1813 pub code_hash : B256 ,
1914}
2015
21- /// Interface for fetching account info for a given address
22- #[ async_trait]
23- pub trait AccountInfoLookup : Send + Sync {
24- async fn fetch_account_info ( & self , address : Address ) -> RpcResult < AccountInfo > ;
25- }
26-
27- /// Implementation of the `AccountInfoLookup` trait for the `RootProvider`
28- #[ async_trait]
29- impl AccountInfoLookup for RootProvider < Optimism > {
30- async fn fetch_account_info ( & self , address : Address ) -> RpcResult < AccountInfo > {
31- let account = self
32- . get_account ( address)
33- . await
34- . map_err ( |_| EthApiError :: Signing ( SignError :: NoAccount ) ) ?;
35- Ok ( AccountInfo {
36- balance : account. balance ,
37- nonce : account. nonce ,
38- code_hash : account. code_hash ,
39- } )
40- }
41- }
42-
43- /// Interface for fetching L1 block info for a given block number
44- #[ async_trait]
45- pub trait L1BlockInfoLookup : Send + Sync {
46- async fn fetch_l1_block_info ( & self ) -> RpcResult < L1BlockInfo > ;
47- }
48-
49- /// Implementation of the `L1BlockInfoLookup` trait for the `RootProvider`
50- #[ async_trait]
51- impl L1BlockInfoLookup for RootProvider < Optimism > {
52- async fn fetch_l1_block_info ( & self ) -> RpcResult < L1BlockInfo > {
53- let block = self
54- . get_block ( BlockId :: Number ( BlockNumberOrTag :: Latest ) )
55- . full ( )
56- . await
57- . map_err ( |e| {
58- warn ! ( message = "failed to fetch latest block" , err = %e) ;
59- EthApiError :: InternalEthError . into_rpc_err ( )
60- } ) ?
61- . ok_or_else ( || {
62- warn ! ( message = "empty latest block returned" ) ;
63- EthApiError :: InternalEthError . into_rpc_err ( )
64- } ) ?;
65-
66- let txs = block. transactions . clone ( ) ;
67- let first_tx = txs. first_transaction ( ) . ok_or_else ( || {
68- warn ! ( message = "block contains no transactions" ) ;
69- EthApiError :: InternalEthError . into_rpc_err ( )
70- } ) ?;
71-
72- Ok ( extract_l1_info_from_tx ( & first_tx. clone ( ) ) . map_err ( |e| {
73- warn ! ( message = "failed to extract l1_info from tx" , err = %e) ;
74- EthApiError :: InternalEthError . into_rpc_err ( )
75- } ) ?)
76- }
77- }
78-
7916/// Helper function to validate a transaction. A valid transaction must satisfy the following criteria:
8017/// - If the transaction is not EIP-4844
8118/// - If the transaction is not a cross chain tx
@@ -164,6 +101,7 @@ mod tests {
164101 use alloy_consensus:: SignableTransaction ;
165102 use alloy_consensus:: { Transaction , constants:: KECCAK_EMPTY , transaction:: SignerRecoverable } ;
166103 use alloy_consensus:: { TxEip1559 , TxEip4844 , TxEip7702 } ;
104+ use alloy_primitives:: Address ;
167105 use alloy_primitives:: { bytes, keccak256} ;
168106 use alloy_signer_local:: PrivateKeySigner ;
169107 use op_alloy_consensus:: OpTxEnvelope ;
0 commit comments