Skip to content

Commit

Permalink
db: Wrap errors in db.fetchAncestor to better identify unmarshalling …
Browse files Browse the repository at this point in the history
…issues (#11342)

* db: Wrap errors in db.fetchAncestor to better identify unmarshalling issues. See #11327

* Wrap genesis state fetch, just in case

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
prestonvanloon and prylabs-bulldozer[bot] authored Aug 29, 2022
1 parent b5039e9 commit 57b7e0b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions beacon-chain/state/stategen/getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 57b7e0b

Please sign in to comment.