Skip to content

Commit 69139c0

Browse files
committed
do not poll more than the configured amount when filling gaps
1 parent c5c27eb commit 69139c0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/orchestrator/committer.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,20 @@ func (c *Committer) handleGap(expectedStartBlockNumber *big.Int, actualFirstBloc
177177
// record the first missed block number in prometheus
178178
metrics.MissedBlockNumbers.Set(float64(expectedStartBlockNumber.Int64()))
179179

180+
poller := NewBoundlessPoller(c.rpc, c.storage)
181+
180182
missingBlockCount := new(big.Int).Sub(actualFirstBlock.Number, expectedStartBlockNumber).Int64()
183+
log.Debug().Msgf("Detected %d missing blocks between blocks %s and %s", missingBlockCount, expectedStartBlockNumber.String(), actualFirstBlock.Number.String())
184+
if missingBlockCount > poller.blocksPerPoll {
185+
log.Debug().Msgf("Limiting polling missing blocks to %d blocks due to config", poller.blocksPerPoll)
186+
missingBlockCount = poller.blocksPerPoll
187+
}
181188
missingBlockNumbers := make([]*big.Int, missingBlockCount)
182189
for i := int64(0); i < missingBlockCount; i++ {
183190
missingBlockNumber := new(big.Int).Add(expectedStartBlockNumber, big.NewInt(i))
184191
missingBlockNumbers[i] = missingBlockNumber
185192
}
186-
log.Debug().Msgf("Detected %d missing blocks between blocks %s and %s", missingBlockCount, expectedStartBlockNumber.String(), actualFirstBlock.Number.String())
187193

188-
poller := NewBoundlessPoller(c.rpc, c.storage)
189194
log.Debug().Msgf("Polling %d blocks while handling gap: %v", len(missingBlockNumbers), missingBlockNumbers)
190195
poller.Poll(missingBlockNumbers)
191196
return fmt.Errorf("first block number (%s) in commit batch does not match expected (%s)", actualFirstBlock.Number.String(), expectedStartBlockNumber.String())

0 commit comments

Comments
 (0)