Skip to content

Commit

Permalink
Short circuit genesis condition for new state mgmt (#5223)
Browse files Browse the repository at this point in the history
* Fixed a regression. Genesis case for state gen

* Comment

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
terencechain and prylabs-bulldozer[bot] committed Mar 26, 2020
1 parent 93e68db commit 5e2faf1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions beacon-chain/state/stategen/getter.go
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
"github.com/prysmaticlabs/prysm/shared/params"
"go.opencensus.io/trace"
)

Expand All @@ -15,6 +16,11 @@ func (s *State) StateByRoot(ctx context.Context, blockRoot [32]byte) (*state.Bea
ctx, span := trace.StartSpan(ctx, "stateGen.StateByRoot")
defer span.End()

// Genesis case. If block root is zero hash, short circuit to use genesis state stored in DB.
if blockRoot == params.BeaconConfig().ZeroHash {
return s.beaconDB.State(ctx, blockRoot)
}

slot, err := s.blockRootSlot(ctx, blockRoot)
if err != nil {
return nil, errors.Wrap(err, "could not get state summary")
Expand Down

0 comments on commit 5e2faf1

Please sign in to comment.