From d62387f3f0320dd6b20dbccda4ba17f0e0271c9c Mon Sep 17 00:00:00 2001 From: Matija Martinic Date: Tue, 5 Jul 2022 22:45:56 +0200 Subject: [PATCH] fix for evm main --- chain/evm/client.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/chain/evm/client.go b/chain/evm/client.go index d93963b2..5577a617 100644 --- a/chain/evm/client.go +++ b/chain/evm/client.go @@ -276,6 +276,18 @@ type ethClientToFilterLogs interface { HeaderByNumber(ctx context.Context, number *big.Int) (*etherumtypes.Header, error) } +func shouldDoBinarySearchFromError(err error) bool { + + switch { + case strings.Contains(err.Error(), "query returned more than 10000 results"): + return true + case strings.Contains(err.Error(), "eth_getLogs and eth_newFilter are limited to a 10,000 blocks range"): + return true + } + + return false +} + func filterLogs( ctx context.Context, ethClient ethClientToFilterLogs, @@ -309,7 +321,7 @@ func filterLogs( return true, nil } return fn(logs), nil - case err.Error() == "query returned more than 10000 results": + case shouldDoBinarySearchFromError(err): // this appears to be ropsten specifict, but keepeing the logic here just in case mid := big.NewInt(0).Sub( fq.ToBlock,