Node/EVM: Another blocktime query retry reason (#3583)
This commit is contained in:
parent
af3a8bf414
commit
d09dc13918
|
@ -323,7 +323,7 @@ func (b *BatchPollConnector) getBlockRange(ctx context.Context, logger *zap.Logg
|
||||||
var n big.Int
|
var n big.Int
|
||||||
m := &result.result
|
m := &result.result
|
||||||
if m.Number == nil {
|
if m.Number == nil {
|
||||||
logger.Debug("number is nil, treating as zero", zap.Stringer("finality", finality), zap.String("tag", b.batchData[idx].tag))
|
logger.Debug("number is nil, treating as zero", zap.Stringer("finality", finality))
|
||||||
} else {
|
} else {
|
||||||
n = big.Int(*m.Number)
|
n = big.Int(*m.Number)
|
||||||
}
|
}
|
||||||
|
|
|
@ -488,7 +488,7 @@ func (w *Watcher) Run(parentCtx context.Context) error {
|
||||||
blockTime, err := w.getBlockTime(ctx, ev.Raw.BlockHash)
|
blockTime, err := w.getBlockTime(ctx, ev.Raw.BlockHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ethConnectionErrors.WithLabelValues(w.networkName, "block_by_number_error").Inc()
|
ethConnectionErrors.WithLabelValues(w.networkName, "block_by_number_error").Inc()
|
||||||
if err == ethereum.NotFound {
|
if canRetryGetBlockTime(err) {
|
||||||
go w.waitForBlockTime(ctx, logger, errC, ev)
|
go w.waitForBlockTime(ctx, logger, errC, ev)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -931,6 +931,11 @@ func (w *Watcher) postMessage(logger *zap.Logger, ev *ethabi.AbiLogMessagePublis
|
||||||
w.pendingMu.Unlock()
|
w.pendingMu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// canRetryGetBlockTime returns true if the error returned by getBlockTime warrants doing a retry.
|
||||||
|
func canRetryGetBlockTime(err error) bool {
|
||||||
|
return err == ethereum.NotFound /* go-ethereum */ || err.Error() == "cannot query unfinalized data" /* avalanche */
|
||||||
|
}
|
||||||
|
|
||||||
// waitForBlockTime is a go routine that repeatedly attempts to read the block time for a single log event. It is used when the initial attempt to read
|
// waitForBlockTime is a go routine that repeatedly attempts to read the block time for a single log event. It is used when the initial attempt to read
|
||||||
// the block time fails. If it is finally able to read the block time, it posts the event for processing. Otherwise, it will eventually give up.
|
// the block time fails. If it is finally able to read the block time, it posts the event for processing. Otherwise, it will eventually give up.
|
||||||
func (w *Watcher) waitForBlockTime(ctx context.Context, logger *zap.Logger, errC chan error, ev *ethabi.AbiLogMessagePublished) {
|
func (w *Watcher) waitForBlockTime(ctx context.Context, logger *zap.Logger, errC chan error, ev *ethabi.AbiLogMessagePublished) {
|
||||||
|
@ -973,7 +978,7 @@ func (w *Watcher) waitForBlockTime(ctx context.Context, logger *zap.Logger, errC
|
||||||
}
|
}
|
||||||
|
|
||||||
ethConnectionErrors.WithLabelValues(w.networkName, "block_by_number_error").Inc()
|
ethConnectionErrors.WithLabelValues(w.networkName, "block_by_number_error").Inc()
|
||||||
if err != ethereum.NotFound {
|
if !canRetryGetBlockTime(err) {
|
||||||
p2p.DefaultRegistry.AddErrorCount(w.chainID, 1)
|
p2p.DefaultRegistry.AddErrorCount(w.chainID, 1)
|
||||||
errC <- fmt.Errorf("failed to request timestamp for block %d, hash %s: %w", ev.Raw.BlockNumber, ev.Raw.BlockHash.String(), err)
|
errC <- fmt.Errorf("failed to request timestamp for block %d, hash %s: %w", ev.Raw.BlockNumber, ev.Raw.BlockHash.String(), err)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue