Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Short circuit genesis condition for new state mgmt #5223

Merged
merged 4 commits into from Mar 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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