Skip to content

Commit 2eede27

Browse files
committed
chain: Filter call triggers from unsuccessful transactions
1 parent 2c3f90c commit 2eede27

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

chain/ethereum/src/ethereum_adapter.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ pub(crate) async fn blocks_with_triggers(
14901490
triggers_by_block.entry(to).or_insert(Vec::new());
14911491

14921492
let mut blocks = adapter
1493-
.load_blocks(logger1, chain_store, block_hashes)
1493+
.load_blocks(logger1, chain_store.clone(), block_hashes)
14941494
.and_then(
14951495
move |block| match triggers_by_block.remove(&(block.number() as BlockNumber)) {
14961496
Some(triggers) => Ok(BlockWithTriggers::new(
@@ -1503,11 +1503,17 @@ pub(crate) async fn blocks_with_triggers(
15031503
)),
15041504
},
15051505
)
1506-
// .map(|x| filter_call_triggers_from_unsuccessful_transactions(x))
15071506
.collect()
15081507
.compat()
15091508
.await?;
15101509

1510+
let section =
1511+
stopwatch_metrics.start_section("filter_call_triggers_from_unsuccessful_transactions");
1512+
for mut block in blocks.iter_mut() {
1513+
filter_call_triggers_from_unsuccessful_transactions(&mut block, &eth, &chain_store).await?;
1514+
}
1515+
section.end();
1516+
15111517
blocks.sort_by_key(|block| block.ptr().number);
15121518

15131519
// Sanity check that the returned blocks are in the correct range.
@@ -1660,10 +1666,10 @@ async fn fetch_receipt_from_ethereum_client(
16601666
}
16611667

16621668
async fn filter_call_triggers_from_unsuccessful_transactions(
1663-
mut block: BlockWithTriggers<crate::Chain>,
1664-
chain_store: Arc<dyn ChainStore>,
1665-
) -> anyhow::Result<BlockWithTriggers<crate::Chain>> {
1669+
block: &mut BlockWithTriggers<crate::Chain>,
16661670
eth: &EthereumAdapter,
1671+
chain_store: &Arc<dyn ChainStore>,
1672+
) -> anyhow::Result<()> {
16671673
// First, we separate call triggers from other trigger types
16681674
let calls: Vec<&Arc<EthereumCall>> = block
16691675
.trigger_data
@@ -1685,7 +1691,7 @@ async fn filter_call_triggers_from_unsuccessful_transactions(
16851691

16861692
// And obtain all Transaction values for the calls in this block.
16871693
let transactions: Vec<&Transaction> = {
1688-
match block.block {
1694+
match &block.block {
16891695
BlockFinality::Final(_block) => {
16901696
unreachable!("this function should not be called for dealing with final blocks")
16911697
}
@@ -1758,7 +1764,7 @@ async fn filter_call_triggers_from_unsuccessful_transactions(
17581764
true
17591765
}
17601766
});
1761-
Ok(block)
1767+
Ok(())
17621768
}
17631769

17641770
fn is_transaction_successful(

0 commit comments

Comments
 (0)