@@ -51,49 +51,9 @@ impl<N: NetworkSpec, R: ExecutionRpc<N>, A: VerifiableApi<N>> VerifiableMethods<
5151 . ok_or ( ExecutionError :: BlockNotFound ( tag) ) ?;
5252 let block_id = BlockId :: number ( block. header ( ) . number ( ) ) ;
5353
54- let AccountResponse {
55- account,
56- code,
57- account_proof,
58- storage_proof,
59- } = self . api . get_account ( address, slots, Some ( block_id) ) . await ?;
54+ let account_response = self . api . get_account ( address, slots, Some ( block_id) ) . await ?;
6055
61- // Verify the account proof
62- let proof = EIP1186AccountProofResponse {
63- address,
64- balance : account. balance ,
65- code_hash : account. code_hash ,
66- nonce : account. nonce ,
67- storage_hash : account. storage_root ,
68- account_proof,
69- storage_proof,
70- } ;
71- verify_account_proof ( & proof, block. header ( ) . state_root ( ) ) ?;
72- // Verify the storage proofs, collecting the slot values
73- let slot_map = verify_storage_proof ( & proof) ?;
74- // Verify the code hash
75- let code = if proof. code_hash == KECCAK_EMPTY || proof. code_hash == B256 :: ZERO {
76- Vec :: new ( )
77- } else {
78- let code_hash = keccak256 ( & code) ;
79-
80- if proof. code_hash != code_hash {
81- return Err (
82- ExecutionError :: CodeHashMismatch ( address, code_hash, proof. code_hash ) . into ( ) ,
83- ) ;
84- }
85-
86- code. into ( )
87- } ;
88-
89- Ok ( Account {
90- balance : account. balance ,
91- nonce : account. nonce ,
92- code_hash : account. code_hash ,
93- code,
94- storage_hash : account. storage_root ,
95- slots : slot_map,
96- } )
56+ self . verify_account_response ( address, account_response, & block)
9757 }
9858
9959 async fn get_transaction_receipt ( & self , tx_hash : B256 ) -> Result < Option < N :: ReceiptResponse > > {
@@ -161,9 +121,83 @@ impl<N: NetworkSpec, R: ExecutionRpc<N>, A: VerifiableApi<N>> VerifiableMethods<
161121
162122 Ok ( logs)
163123 }
124+
125+ async fn create_access_list (
126+ & self ,
127+ tx : & N :: TransactionRequest ,
128+ block : Option < BlockId > ,
129+ ) -> Result < HashMap < Address , Account > > {
130+ let block_id = block. unwrap_or ( BlockId :: latest ( ) ) ;
131+ let tag = BlockTag :: try_from ( block_id) ?;
132+ let block = self
133+ . state
134+ . get_block ( tag)
135+ . await
136+ . ok_or ( ExecutionError :: BlockNotFound ( tag) ) ?;
137+ let block_id = BlockId :: Number ( block. header ( ) . number ( ) . into ( ) ) ;
138+
139+ let AccessListResponse { accounts } = self
140+ . api
141+ . create_access_list ( tx. clone ( ) , Some ( block_id) )
142+ . await ?;
143+
144+ let account_map = accounts
145+ . into_iter ( )
146+ . map ( |( address, account_response) | {
147+ self . verify_account_response ( address, account_response, & block)
148+ . map ( |account| ( address, account) )
149+ } )
150+ . collect :: < Result < HashMap < _ , _ > > > ( ) ?;
151+
152+ Ok ( account_map)
153+ }
164154}
165155
166156impl < N : NetworkSpec , R : ExecutionRpc < N > , A : VerifiableApi < N > > VerifiableMethodsApi < N , R , A > {
157+ fn verify_account_response (
158+ & self ,
159+ address : Address ,
160+ account : AccountResponse ,
161+ block : & N :: BlockResponse ,
162+ ) -> Result < Account > {
163+ let proof = EIP1186AccountProofResponse {
164+ address,
165+ balance : account. account . balance ,
166+ code_hash : account. account . code_hash ,
167+ nonce : account. account . nonce ,
168+ storage_hash : account. account . storage_root ,
169+ account_proof : account. account_proof ,
170+ storage_proof : account. storage_proof ,
171+ } ;
172+ // Verify the account proof
173+ verify_account_proof ( & proof, block. header ( ) . state_root ( ) ) ?;
174+ // Verify the storage proofs, collecting the slot values
175+ let slot_map = verify_storage_proof ( & proof) ?;
176+ // Verify the code hash
177+ let code = if proof. code_hash == KECCAK_EMPTY || proof. code_hash == B256 :: ZERO {
178+ Vec :: new ( )
179+ } else {
180+ let code_hash = keccak256 ( & account. code ) ;
181+
182+ if proof. code_hash != code_hash {
183+ return Err (
184+ ExecutionError :: CodeHashMismatch ( address, code_hash, proof. code_hash ) . into ( ) ,
185+ ) ;
186+ }
187+
188+ account. code . into ( )
189+ } ;
190+
191+ Ok ( Account {
192+ balance : proof. balance ,
193+ nonce : proof. nonce ,
194+ code_hash : proof. code_hash ,
195+ code,
196+ storage_hash : proof. storage_hash ,
197+ slots : slot_map,
198+ } )
199+ }
200+
167201 async fn verify_logs_and_receipts (
168202 & self ,
169203 logs : & [ Log ] ,
0 commit comments