Skip to content

Commit

Permalink
Fix Batch Requesting Of Headers (#11982)
Browse files Browse the repository at this point in the history
* fix bug

* remove
  • Loading branch information
nisdas authored Feb 11, 2023
1 parent e136e10 commit 63186c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions beacon-chain/execution/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,12 @@ func (s *Service) cacheBlockHeaders(start, end uint64) error {
for i := start; i < end; i += batchSize {
startReq := i
endReq := i + batchSize
if endReq > 0 {
// Reduce the end request by one
// to prevent total batch size from exceeding
// the allotted limit.
endReq -= 1
}
if endReq > end {
endReq = end
}
Expand Down
3 changes: 3 additions & 0 deletions beacon-chain/execution/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,9 @@ func TestService_CacheBlockHeaders(t *testing.T) {
assert.Equal(t, 1, rClient.numOfCalls)
// Reset Num of Calls
rClient.numOfCalls = 0
// Increase header request limit to trigger the batch limiting
// code path.
s.cfg.eth1HeaderReqLimit = 1001

assert.NoError(t, s.cacheBlockHeaders(1000, 3000))
// 1000 - 2000 would be 1001 headers which is higher than our request limit, it
Expand Down

0 comments on commit 63186c8

Please sign in to comment.