From 3a9c8eb8b149c86b3d5fb94d3cbeb5ffc50b4e6e Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Thu, 6 Feb 2020 09:22:44 -0800 Subject: [PATCH] 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 --- beacon-chain/blockchain/process_block_helpers.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/beacon-chain/blockchain/process_block_helpers.go b/beacon-chain/blockchain/process_block_helpers.go index e665751cce..475b6b6936 100644 --- a/beacon-chain/blockchain/process_block_helpers.go +++ b/beacon-chain/blockchain/process_block_helpers.go @@ -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")