Skip to content

Commit

Permalink
Fix Overflow Bugs Introduced (#7579)
Browse files Browse the repository at this point in the history
  • Loading branch information
nisdas authored Oct 20, 2020
1 parent 816eb94 commit 81b553a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions beacon-chain/powchain/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,6 @@ func (s *Service) initPOWService() {
s.retryETH1Node(err)
continue
}
s.cacheHeadersForEth1DataVote(ctx)

s.latestEth1Data.BlockHeight = header.Number.Uint64()
s.latestEth1Data.BlockHash = header.Hash().Bytes()
Expand All @@ -660,6 +659,8 @@ func (s *Service) initPOWService() {
s.retryETH1Node(err)
continue
}
// Cache eth1 headers from our voting period.
s.cacheHeadersForEth1DataVote(ctx)
return
}
}
Expand Down Expand Up @@ -739,12 +740,10 @@ func (s *Service) cacheHeadersForEth1DataVote(ctx context.Context) {
log.Errorf("Unable to fetch height of follow block: %v", err)
}

var start uint64
// We fetch twice the number of headers just to be safe.
if end-2*blocksPerVotingPeriod >= 0 {
start := uint64(0)
if end >= 2*blocksPerVotingPeriod {
start = end - 2*blocksPerVotingPeriod
} else {
start = 0
}
// We call batchRequestHeaders for its header caching side-effect, so we don't need the return value.
_, err = s.batchRequestHeaders(start, end)
Expand Down

0 comments on commit 81b553a

Please sign in to comment.