Skip to content

Commit cb0a898

Browse files
authored
ethereum: avoid large trace filter requests (#3733)
1 parent 1e41f88 commit cb0a898

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

chain/ethereum/src/ethereum_adapter.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ impl EthereumAdapter {
697697
) -> Box<dyn Stream<Item = EthereumCall, Error = Error> + Send + 'a> {
698698
let eth = self.clone();
699699

700-
let addresses: Vec<H160> = call_filter
700+
let mut addresses: Vec<H160> = call_filter
701701
.contract_addresses_function_signatures
702702
.iter()
703703
.filter(|(_addr, (start_block, _fsigs))| start_block <= &to)
@@ -712,6 +712,12 @@ impl EthereumAdapter {
712712
return Box::new(stream::empty());
713713
}
714714

715+
if addresses.len() > 100 {
716+
// If the address list is large, request all traces, this avoids generating huge
717+
// requests and potentially getting 413 errors.
718+
addresses = vec![];
719+
}
720+
715721
Box::new(
716722
eth.trace_stream(&logger, subgraph_metrics, from, to, addresses)
717723
.filter_map(|trace| EthereumCall::try_from_trace(&trace))

0 commit comments

Comments
 (0)