@@ -710,7 +710,7 @@ impl EthereumAdapter {
710
710
711
711
// Hit the database and fetch all failed transactions in the block range.
712
712
// TODO: handle this Result/expect
713
- let transaction_statuses_in_block_range = chain_store
713
+ let mut transaction_statuses_in_block_range = chain_store
714
714
. transaction_statuses_in_block_range ( & ( from..to) )
715
715
. expect ( "failed to fetch failed transactions in the database" ) ;
716
716
@@ -720,8 +720,12 @@ impl EthereumAdapter {
720
720
eth. trace_stream ( & logger, subgraph_metrics, from, to, addresses)
721
721
. filter ( move |trace| {
722
722
// TODO: handle this Result/expect
723
- trace_transaction_succeeded ( & trace, & eth2, & transaction_statuses_in_block_range)
724
- . expect ( "failed to determine if trace's transaction has failed" )
723
+ trace_transaction_succeeded (
724
+ & trace,
725
+ & eth2,
726
+ & mut transaction_statuses_in_block_range,
727
+ )
728
+ . expect ( "failed to determine if trace's transaction has failed" )
725
729
} )
726
730
. filter_map ( |trace| EthereumCall :: try_from_trace ( & trace) )
727
731
. filter ( move |call| {
@@ -1668,7 +1672,7 @@ pub(crate) fn parse_block_triggers(
1668
1672
fn trace_transaction_succeeded (
1669
1673
trace : & Trace ,
1670
1674
eth : & EthereumAdapter ,
1671
- failed_transactions : & HashMap < H256 , bool > ,
1675
+ failed_transactions : & mut HashMap < H256 , bool > ,
1672
1676
) -> anyhow:: Result < bool > {
1673
1677
let transaction_hash = trace
1674
1678
. transaction_hash
@@ -1693,10 +1697,15 @@ fn trace_transaction_succeeded(
1693
1697
. ok_or ( anyhow:: anyhow!( "Running in light client mode" ) ) ?
1694
1698
>= transaction. gas
1695
1699
{
1700
+ // update our source of truth to prevent future api calls for the same transaction
1701
+ failed_transactions. insert ( transaction_hash, false ) ;
1696
1702
return Ok ( false ) ;
1697
1703
}
1698
1704
1699
- Ok ( matches ! ( receipt. status, Some ( x) if x == web3:: types:: U64 :: from( 1 ) ) )
1705
+ let status = matches ! ( receipt. status, Some ( x) if x == web3:: types:: U64 :: from( 1 ) ) ;
1706
+ // update our source of truth to prevent future api calls for the same transaction
1707
+ failed_transactions. insert ( transaction_hash, status) ;
1708
+ Ok ( status)
1700
1709
}
1701
1710
1702
1711
async fn fetch_transaction_and_receipt_from_ethereum_client (
0 commit comments