@@ -7,8 +7,10 @@ use alloy::{
77 signers:: SignerSync ,
88} ;
99use alloy_network:: { TransactionBuilder , TransactionBuilder7702 } ;
10- use alloy_rpc_types:: { BlockNumberOrTag , EIP1186AccountProofResponse , TransactionRequest } ;
10+ use alloy_rpc_types:: { Block , BlockNumberOrTag , EIP1186AccountProofResponse , TransactionRequest } ;
1111use alloy_signer_local:: PrivateKeySigner ;
12+ use reth_primitives_traits:: Account ;
13+ use reth_trie_common:: { AccountProof , StorageProof } ;
1214use url:: Url ;
1315
1416static REPLICA_RPC : LazyLock < Url > = LazyLock :: new ( || {
@@ -130,51 +132,58 @@ async fn test_new_wallet_api() -> Result<(), Box<dyn std::error::Error>> {
130132
131133#[ tokio:: test]
132134async fn test_withdrawal_proof_with_fallback ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
133- if !ci_info:: is_ci ( ) {
134- return Ok ( ( ) ) ;
135- }
136-
137- #[ derive( Debug , Clone , serde:: Serialize ) ]
138- struct ProofParams {
139- address : Address ,
140- keys : Vec < B256 > ,
141- block : BlockNumberOrTag ,
142- }
135+ // if !ci_info::is_ci() {
136+ // return Ok(());
137+ // }
143138
144139 let provider = ProviderBuilder :: new ( ) . on_http ( REPLICA_RPC . clone ( ) ) ;
145- let signer = PrivateKeySigner :: from_bytes ( & b256 ! (
146- "59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
147- ) ) ?;
140+ let block: Block = provider
141+ . client ( )
142+ . request ( "eth_getBlockByNumber" , ( BlockNumberOrTag :: Latest , false ) )
143+ . await ?;
144+ let block_number = BlockNumberOrTag :: Number ( block. header . number ) ;
148145
149146 // Withdrawal contract will return an empty account proof, since it only handles storage proofs
150147 let withdrawal_contract_response: EIP1186AccountProofResponse = provider
151148 . client ( )
152149 . request (
153150 "eth_getProof" ,
154- ProofParams {
155- address : odyssey_common:: WITHDRAWAL_CONTRACT ,
156- keys : vec ! [ B256 :: ZERO ] ,
157- block : BlockNumberOrTag :: Latest ,
158- } ,
151+ ( odyssey_common:: WITHDRAWAL_CONTRACT , vec ! [ B256 :: ZERO ] , block_number) ,
159152 )
160153 . await ?;
154+
161155 assert ! ( withdrawal_contract_response. account_proof. is_empty( ) ) ;
162156 assert ! ( !withdrawal_contract_response. storage_proof. is_empty( ) ) ;
163157
158+ let storage_root = withdrawal_contract_response. storage_hash ;
159+ for proof in withdrawal_contract_response. storage_proof {
160+ StorageProof :: new ( proof. key . as_b256 ( ) ) . with_proof ( proof. proof ) . verify ( storage_root) ?
161+ }
162+
164163 // If not targeting the withdrawal contract, it defaults back to the standard getProof
165164 // implementation
165+ let signer = PrivateKeySigner :: from_bytes ( & b256 ! (
166+ "59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
167+ ) ) ?;
168+
166169 let eoa_response: EIP1186AccountProofResponse = provider
167170 . client ( )
168- . request (
169- "eth_getProof" ,
170- ProofParams {
171- address : signer. address ( ) ,
172- keys : vec ! [ ] ,
173- block : BlockNumberOrTag :: Latest ,
174- } ,
175- )
176- . await ?;
171+ . request ( "eth_getProof" , ( signer. address ( ) , [ 0 ; 0 ] , block_number) )
172+ . await
173+ . unwrap ( ) ;
174+
177175 assert ! ( !eoa_response. account_proof. is_empty( ) ) ;
176+ AccountProof {
177+ address : signer. address ( ) ,
178+ info : Some ( Account {
179+ nonce : eoa_response. nonce ,
180+ balance : eoa_response. balance ,
181+ bytecode_hash : None ,
182+ } ) ,
183+ proof : eoa_response. account_proof ,
184+ ..Default :: default ( )
185+ }
186+ . verify ( block. header . state_root ) ?;
178187
179188 Ok ( ( ) )
180189}
0 commit comments