@@ -174,13 +174,22 @@ where
174174 tx_hash = %tx_hash
175175 ) ;
176176
177+ // Check canonical chain first to avoid race condition where flashblocks
178+ // state hasn't been cleared yet after canonical block commit
179+ if let Some ( canonical_receipt) =
180+ EthTransactions :: transaction_receipt ( & self . eth_api , tx_hash) . await ?
181+ {
182+ return Ok ( Some ( canonical_receipt) ) ;
183+ }
184+
185+ // Fall back to flashblocks for pending transactions
177186 let pending_blocks = self . flashblocks_state . get_pending_blocks ( ) ;
178187 if let Some ( fb_receipt) = pending_blocks. get_transaction_receipt ( tx_hash) {
179188 self . metrics . get_transaction_receipt . increment ( 1 ) ;
180189 return Ok ( Some ( fb_receipt) ) ;
181190 }
182191
183- EthTransactions :: transaction_receipt ( & self . eth_api , tx_hash ) . await . map_err ( Into :: into )
192+ Ok ( None )
184193 }
185194
186195 async fn get_balance (
@@ -241,17 +250,24 @@ where
241250 tx_hash = %tx_hash
242251 ) ;
243252
244- let pending_blocks = self . flashblocks_state . get_pending_blocks ( ) ;
253+ // Check canonical chain first to avoid race condition where flashblocks
254+ // state hasn't been cleared yet after canonical block commit
255+ if let Some ( canonical_tx) = EthTransactions :: transaction_by_hash ( & self . eth_api , tx_hash)
256+ . await ?
257+ . map ( |tx| tx. into_transaction ( self . eth_api . tx_resp_builder ( ) ) )
258+ . transpose ( ) ?
259+ {
260+ return Ok ( Some ( canonical_tx) ) ;
261+ }
245262
263+ // Fall back to flashblocks for pending transactions
264+ let pending_blocks = self . flashblocks_state . get_pending_blocks ( ) ;
246265 if let Some ( fb_transaction) = pending_blocks. get_transaction_by_hash ( tx_hash) {
247- self . metrics . get_transaction_receipt . increment ( 1 ) ;
266+ self . metrics . get_transaction_by_hash . increment ( 1 ) ;
248267 return Ok ( Some ( fb_transaction) ) ;
249268 }
250269
251- Ok ( EthTransactions :: transaction_by_hash ( & self . eth_api , tx_hash)
252- . await ?
253- . map ( |tx| tx. into_transaction ( self . eth_api . tx_resp_builder ( ) ) )
254- . transpose ( ) ?)
270+ Ok ( None )
255271 }
256272
257273 async fn send_raw_transaction_sync (
0 commit comments