Skip to content

Commit

Permalink
Forkchoice start using proper root (#6062)
Browse files Browse the repository at this point in the history
* Skip update head if justiifed root is zero hashes

* Start with genesis root instead

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
terencechain and prylabs-bulldozer[bot] committed Jun 1, 2020
1 parent 6e514b9 commit 6598c38
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion beacon-chain/blockchain/head.go
Expand Up @@ -42,7 +42,13 @@ func (s *Service) updateHead(ctx context.Context, balances []uint64) error {
// Get head from the fork choice service.
f := s.finalizedCheckpt
j := s.justifiedCheckpt
headRoot, err := s.forkChoiceStore.Head(ctx, j.Epoch, bytesutil.ToBytes32(j.Root), balances, f.Epoch)
// To get head before the first justified epoch, the fork choice will start with genesis root
// instead of zero hashes.
headStartRoot := bytesutil.ToBytes32(j.Root)
if headStartRoot == params.BeaconConfig().ZeroHash {
headStartRoot = s.genesisRoot
}
headRoot, err := s.forkChoiceStore.Head(ctx, j.Epoch, headStartRoot, balances, f.Epoch)
if err != nil {
return err
}
Expand Down

0 comments on commit 6598c38

Please sign in to comment.