diff --git a/beacon-chain/state/stategen/getter.go b/beacon-chain/state/stategen/getter.go index b2c55fff6..4f53f717b 100644 --- a/beacon-chain/state/stategen/getter.go +++ b/beacon-chain/state/stategen/getter.go @@ -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" ) @@ -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")