@@ -21,6 +21,14 @@ import (
21
21
"github.com/onflow/flow-go/utils/logging"
22
22
)
23
23
24
+ const (
25
+ // maxIndexBlockDiff is the maximum difference between the highest indexed block height and the
26
+ // provided start height to allow when starting a new stream.
27
+ // this is used to account for small delays indexing or requests made to different ANs behind a
28
+ // load balancer. The diff will result in the stream waiting a few blocks before starting.
29
+ maxIndexBlockDiff = 30
30
+ )
31
+
24
32
// ExecutionDataTracker is an interface for tracking the highest consecutive block height for which we have received a
25
33
// new Execution Data notification
26
34
type ExecutionDataTracker interface {
@@ -273,8 +281,11 @@ func (e *ExecutionDataTrackerImpl) checkStartHeight(height uint64) (uint64, erro
273
281
return 0 , status .Errorf (codes .InvalidArgument , "start height %d is lower than lowest indexed height %d" , height , lowestHeight )
274
282
}
275
283
276
- if height > highestHeight {
277
- return 0 , status .Errorf (codes .InvalidArgument , "start height %d is higher than highest indexed height %d" , height , highestHeight )
284
+ // allow for a small difference between the highest indexed height and the provided height to
285
+ // account for small delays indexing or requests made to different ANs behind a load balancer.
286
+ // this will just result in the stream waiting a few blocks before starting.
287
+ if height > highestHeight + maxIndexBlockDiff {
288
+ return 0 , status .Errorf (codes .InvalidArgument , "start height %d is higher than highest indexed height %d (maxIndexBlockDiff: %d)" , height , highestHeight , maxIndexBlockDiff )
278
289
}
279
290
280
291
return height , nil
0 commit comments