From e70055733fc63cebf8a628882b571cd10682d5d6 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Mon, 11 Apr 2022 09:51:49 -0700 Subject: [PATCH] Save state to DB after proposer boost (#10509) --- beacon-chain/blockchain/process_block.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index bff01f197..2ce93c956 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -127,8 +127,8 @@ func (s *Service) onBlock(ctx context.Context, signed block.SignedBeaconBlock, b } } - if err := s.savePostStateInfo(ctx, blockRoot, signed, postState, false /* reg sync */); err != nil { - return err + if err := s.insertBlockAndAttestationsToForkChoiceStore(ctx, signed.Block(), blockRoot, postState); err != nil { + return errors.Wrapf(err, "could not insert block %d to fork choice store", signed.Block().Slot()) } if isValidPayload { if err := s.cfg.ForkChoiceStore.SetOptimisticToValid(ctx, blockRoot); err != nil { @@ -148,6 +148,9 @@ func (s *Service) onBlock(ctx context.Context, signed block.SignedBeaconBlock, b return err } + if err := s.savePostStateInfo(ctx, blockRoot, signed, postState, false /* reg sync */); err != nil { + return err + } // If slasher is configured, forward the attestations in the block via // an event feed for processing. if features.Get().EnableSlasher { @@ -609,9 +612,6 @@ func (s *Service) savePostStateInfo(ctx context.Context, r [32]byte, b block.Sig if err := s.cfg.StateGen.SaveState(ctx, r, st); err != nil { return errors.Wrap(err, "could not save state") } - if err := s.insertBlockAndAttestationsToForkChoiceStore(ctx, b.Block(), r, st); err != nil { - return errors.Wrapf(err, "could not insert block %d to fork choice store", b.Block().Slot()) - } return nil }