ethereum: avoid large trace filter requests
@@ -697,7 +697,7 @@ impl EthereumAdapter {
) -> Box<dyn Stream<Item = EthereumCall, Error = Error> + Send + 'a> {
let eth = self.clone();
- let addresses: Vec<H160> = call_filter
+ let mut addresses: Vec<H160> = call_filter
.contract_addresses_function_signatures
.iter()
.filter(|(_addr, (start_block, _fsigs))| start_block <= &to)
@@ -712,6 +712,12 @@ impl EthereumAdapter {
return Box::new(stream::empty());
}
+ if addresses.len() > 100 {
+ // If the address list is large, request all traces, this avoids generating huge
+ // requests and potentially getting 413 errors.
+ addresses = vec![];
+ }
+
Box::new(
eth.trace_stream(&logger, subgraph_metrics, from, to, addresses)
.filter_map(|trace| EthereumCall::try_from_trace(&trace))
