Compare commits

...

3 Commits

Author SHA1 Message Date
prylabs-bulldozer[bot]
33b213750f Merge refs/heads/develop into wrap-fetch-errors 2022-08-29 15:48:28 +00:00
prestonvanloon
9164c32702 Wrap genesis state fetch, just in case 2022-08-29 10:47:25 -05:00
prestonvanloon
bf2e130b5e db: Wrap errors in db.fetchAncestor to better identify unmarshalling issues. See #11327 2022-08-29 10:45:45 -05:00

View File

@@ -239,7 +239,8 @@ func (s *State) latestAncestor(ctx context.Context, blockRoot [32]byte) (state.B
// Is the state the genesis state.
parentRoot := bytesutil.ToBytes32(b.Block().ParentRoot())
if parentRoot == params.BeaconConfig().ZeroHash {
return s.beaconDB.GenesisState(ctx)
s, err := s.beaconDB.GenesisState(ctx)
return s, errors.Wrap(err, "could not get genesis state")
}
// Return an error if slot hasn't been covered by checkpoint sync.
@@ -268,12 +269,13 @@ func (s *State) latestAncestor(ctx context.Context, blockRoot [32]byte) (state.B
// Does the state exists in DB.
if s.beaconDB.HasState(ctx, parentRoot) {
return s.beaconDB.State(ctx, parentRoot)
s, err := s.beaconDB.State(ctx, parentRoot)
return s, errors.Wrap(err, "failed to retrieve state from db")
}
b, err = s.beaconDB.Block(ctx, parentRoot)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to retrieve block from db")
}
if b == nil || b.IsNil() {
return nil, errUnknownBlock