Log a warning if attempting to save a nil state (#4779)

* Log a warning if attempting to save a nil state
* Log a warning if attempting to save a nil state
This commit is contained in:
Preston Van Loon
2020-02-06 09:22:44 -08:00
committed by GitHub
parent a9f1de354b
commit 3a9c8eb8b1

View File

@@ -275,6 +275,11 @@ func (s *Service) saveInitState(ctx context.Context, state *stateTrie.BeaconStat
cpt := state.FinalizedCheckpoint()
finalizedRoot := bytesutil.ToBytes32(cpt.Root)
fs := s.initSyncState[finalizedRoot]
if fs == nil {
// This might happen if the client was in sync and is now re-syncing for whatever reason.
log.Warn("Initial sync cache did not have finalized state root cached")
return nil
}
if err := s.beaconDB.SaveState(ctx, fs, finalizedRoot); err != nil {
return errors.Wrap(err, "could not save state")