Skip to content

Commit 8e71e17

Browse files
authored
fix(state): cap NextBlocks batch against ClickHouse limiter max (#82)
NextBlocks only capped against chainHead, allowing blocks past the beacon chain execution payload limit to be enqueued. Fetch limiter max once at batch start and break the forwards-mode loop when exceeded.
1 parent fc8a21f commit 8e71e17

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/state/manager.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,16 @@ func (s *Manager) NextBlocks(
299299
return []*big.Int{}, nil
300300
}
301301

302+
// Get limiter max for forwards mode capping
303+
var limiterMax *big.Int
304+
305+
if s.limiterEnabled && mode != tracker.BACKWARDS_MODE {
306+
if maxAllowed, err := s.getLimiterMaxBlock(ctx, network); err == nil {
307+
limiterMax = maxAllowed
308+
}
309+
// On error, proceed without limiter cap (same resilience pattern as NextBlock)
310+
}
311+
302312
// Generate sequential block numbers
303313
blocks := make([]*big.Int, 0, count)
304314
blocks = append(blocks, firstBlock)
@@ -319,6 +329,10 @@ func (s *Manager) NextBlocks(
319329
if chainHead != nil && nextBlock.Cmp(chainHead) > 0 {
320330
break
321331
}
332+
// Don't exceed limiter max (beacon chain execution payload limit)
333+
if limiterMax != nil && nextBlock.Cmp(limiterMax) > 0 {
334+
break
335+
}
322336
}
323337

324338
blocks = append(blocks, nextBlock)

0 commit comments

Comments
 (0)