@@ -19,7 +19,6 @@ import (
1919 "sync"
2020 "time"
2121
22- "github.com/avast/retry-go"
2322 "github.com/ethereum/go-ethereum"
2423 "github.com/ethereum/go-ethereum/accounts/abi"
2524 "github.com/ethereum/go-ethereum/accounts/abi/bind"
@@ -1362,29 +1361,12 @@ func (e *EthereumClient) startHeaderPolling() error {
13621361 e .l .Error ().Int64 ("Chain Id" , e .GetChainID ().Int64 ()).Uint64 ("BlockNumber" , blockNum ).Msg ("blockNum exceeds the maximum value for int64" )
13631362 continue
13641363 }
1365- var header * SafeEVMHeader
1366- var fetchErr error
1367-
1368- // Retry logic for fetching the block header
1369- retryErr := retry .Do (
1370- func () error {
1371- blockCtx , blockCancel := context .WithTimeout (context .Background (), e .NetworkConfig .Timeout .Duration )
1372- defer blockCancel ()
1373-
1374- header , fetchErr = e .HeaderByNumber (blockCtx , big .NewInt (int64 (blockNum )))
1375- if fetchErr != nil {
1376- e .l .Warn ().Int64 ("Chain Id" , e .GetChainID ().Int64 ()).Err (fetchErr ).Uint64 ("BlockNumber" , blockNum ).Msg ("Retry fetching header" )
1377- }
1378- return fetchErr
1379- },
1380- retry .Attempts (5 ),
1381- retry .Delay (2 * time .Second ),
1382- retry .MaxDelay (10 * time .Second ),
1383- retry .DelayType (retry .BackOffDelay ),
1384- )
1385-
1386- if retryErr != nil {
1387- e .l .Error ().Int64 ("Chain Id" , e .GetChainID ().Int64 ()).Err (fetchErr ).Uint64 ("BlockNumber" , blockNum ).Msg ("Failed to fetch header after retries. Skipping header." )
1364+ // Create a new context with timeout for each HeaderByNumber call
1365+ blockCtx , blockCancel := context .WithTimeout (context .Background (), e .NetworkConfig .Timeout .Duration )
1366+ header , err := e .HeaderByNumber (blockCtx , big .NewInt (int64 (blockNum )))
1367+ blockCancel ()
1368+ if err != nil {
1369+ e .l .Error ().Int64 ("Chain Id" , e .GetChainID ().Int64 ()).Err (err ).Uint64 ("BlockNumber" , blockNum ).Msg ("Error fetching header during range processing" )
13881370 continue
13891371 }
13901372
0 commit comments