@@ -34,7 +34,10 @@ use alloy_consensus::{
34
34
transaction:: { Recovered , eip4844:: TxEip4844Variant } ,
35
35
} ;
36
36
use alloy_dyn_abi:: TypedData ;
37
- use alloy_eips:: eip2718:: Encodable2718 ;
37
+ use alloy_eips:: {
38
+ eip2718:: Encodable2718 ,
39
+ eip7910:: { EthConfig , EthForkConfig } ,
40
+ } ;
38
41
use alloy_evm:: overrides:: { OverrideBlockHashes , apply_state_overrides} ;
39
42
use alloy_network:: {
40
43
AnyRpcBlock , AnyRpcTransaction , BlockResponse , Ethereum , NetworkWallet , TransactionBuilder ,
@@ -313,6 +316,7 @@ impl EthApi {
313
316
EthRequest :: EthGetLogs ( filter) => self . logs ( filter) . await . to_rpc_result ( ) ,
314
317
EthRequest :: EthGetWork ( _) => self . work ( ) . to_rpc_result ( ) ,
315
318
EthRequest :: EthSyncing ( _) => self . syncing ( ) . to_rpc_result ( ) ,
319
+ EthRequest :: EthConfig ( _) => self . config ( ) . to_rpc_result ( ) ,
316
320
EthRequest :: EthSubmitWork ( nonce, pow, digest) => {
317
321
self . submit_work ( nonce, pow, digest) . to_rpc_result ( )
318
322
}
@@ -762,12 +766,31 @@ impl EthApi {
762
766
}
763
767
764
768
/// Returns the account information including balance, nonce, code and storage
769
+ ///
770
+ /// Note: This isn't support by all providers
765
771
pub async fn get_account_info (
766
772
& self ,
767
773
address : Address ,
768
774
block_number : Option < BlockId > ,
769
775
) -> Result < alloy_rpc_types:: eth:: AccountInfo > {
770
776
node_info ! ( "eth_getAccountInfo" ) ;
777
+
778
+ if let Some ( fork) = self . get_fork ( ) {
779
+ // check if the number predates the fork, if in fork mode
780
+ if let BlockRequest :: Number ( number) = self . block_request ( block_number) . await ?
781
+ && fork. predates_fork ( number)
782
+ {
783
+ // if this predates the fork we need to fetch balance, nonce, code individually
784
+ // because the provider might not support this endpoint
785
+ let balance = self . balance ( address, Some ( number. into ( ) ) ) ;
786
+ let code = self . get_code ( address, Some ( number. into ( ) ) ) ;
787
+ let nonce = self . get_transaction_count ( address, Some ( number. into ( ) ) ) ;
788
+ let ( balance, code, nonce) = try_join ! ( balance, code, nonce) ?;
789
+
790
+ return Ok ( alloy_rpc_types:: eth:: AccountInfo { balance, nonce, code } ) ;
791
+ }
792
+ }
793
+
771
794
let account = self . get_account ( address, block_number) ;
772
795
let code = self . get_code ( address, block_number) ;
773
796
let ( account, code) = try_join ! ( account, code) ?;
@@ -1472,6 +1495,32 @@ impl EthApi {
1472
1495
Ok ( false )
1473
1496
}
1474
1497
1498
+ /// Returns the current configuration of the chain.
1499
+ /// This is useful for finding out what precompiles and system contracts are available.
1500
+ ///
1501
+ /// Note: the activation timestamp is always 0 as the configuration is set at genesis.
1502
+ /// Note: the `fork_id` is always `0x00000000` as this node does not participate in any forking
1503
+ /// on the network.
1504
+ /// Note: the `next` and `last` fields are always `null` as this node does not participate in
1505
+ /// any forking on the network.
1506
+ ///
1507
+ /// Handler for ETH RPC call: `eth_config`
1508
+ pub fn config ( & self ) -> Result < EthConfig > {
1509
+ node_info ! ( "eth_config" ) ;
1510
+ Ok ( EthConfig {
1511
+ current : EthForkConfig {
1512
+ activation_time : 0 ,
1513
+ blob_schedule : self . backend . blob_params ( ) ,
1514
+ chain_id : self . backend . env ( ) . read ( ) . evm_env . cfg_env . chain_id ,
1515
+ fork_id : Bytes :: from_static ( & [ 0 ; 4 ] ) ,
1516
+ precompiles : self . backend . precompiles ( ) ,
1517
+ system_contracts : self . backend . system_contracts ( ) ,
1518
+ } ,
1519
+ next : None ,
1520
+ last : None ,
1521
+ } )
1522
+ }
1523
+
1475
1524
/// Used for submitting a proof-of-work solution.
1476
1525
///
1477
1526
/// Handler for ETH RPC call: `eth_submitWork`
0 commit comments