Skip to content

Commit

Permalink
Revert retry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcauchi committed Jan 24, 2025
1 parent a704a49 commit 095d997
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions lib/blockchain/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"sync"
"time"

"github.com/avast/retry-go"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -1362,29 +1361,12 @@ func (e *EthereumClient) startHeaderPolling() error {
e.l.Error().Int64("Chain Id", e.GetChainID().Int64()).Uint64("BlockNumber", blockNum).Msg("blockNum exceeds the maximum value for int64")
continue
}
var header *SafeEVMHeader
var fetchErr error

// Retry logic for fetching the block header
retryErr := retry.Do(
func() error {
blockCtx, blockCancel := context.WithTimeout(context.Background(), e.NetworkConfig.Timeout.Duration)
defer blockCancel()

header, fetchErr = e.HeaderByNumber(blockCtx, big.NewInt(int64(blockNum)))
if fetchErr != nil {
e.l.Warn().Int64("Chain Id", e.GetChainID().Int64()).Err(fetchErr).Uint64("BlockNumber", blockNum).Msg("Retry fetching header")
}
return fetchErr
},
retry.Attempts(5),
retry.Delay(2*time.Second),
retry.MaxDelay(10*time.Second),
retry.DelayType(retry.BackOffDelay),
)

if retryErr != nil {
e.l.Error().Int64("Chain Id", e.GetChainID().Int64()).Err(fetchErr).Uint64("BlockNumber", blockNum).Msg("Failed to fetch header after retries. Skipping header.")
// Create a new context with timeout for each HeaderByNumber call
blockCtx, blockCancel := context.WithTimeout(context.Background(), e.NetworkConfig.Timeout.Duration)
header, err := e.HeaderByNumber(blockCtx, big.NewInt(int64(blockNum)))
blockCancel()
if err != nil {
e.l.Error().Int64("Chain Id", e.GetChainID().Int64()).Err(err).Uint64("BlockNumber", blockNum).Msg("Error fetching header during range processing")
continue
}

Expand Down

0 comments on commit 095d997

Please sign in to comment.