Skip to content

Commit

Permalink
lock before saving the poststate to db (#12612)
Browse files Browse the repository at this point in the history
  • Loading branch information
potuz authored Jul 11, 2023
1 parent cec32cb commit 58df1f1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions beacon-chain/blockchain/receive_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ func (s *Service) ReceiveBlock(ctx context.Context, block interfaces.ReadOnlySig
if err != nil {
return errors.Wrap(err, "could not notify the engine of the new payload")
}
if err := s.savePostStateInfo(ctx, blockRoot, blockCopy, postState); err != nil {
return errors.Wrap(err, "could not save post state info")
}
// The rest of block processing takes a lock on forkchoice.
s.cfg.ForkChoiceStore.Lock()
defer s.cfg.ForkChoiceStore.Unlock()
if err := s.savePostStateInfo(ctx, blockRoot, blockCopy, postState); err != nil {
return errors.Wrap(err, "could not save post state info")
}

// Apply state transition on the new block.
if err := s.postBlockProcess(ctx, blockCopy, blockRoot, postState, isValidPayload); err != nil {
err := errors.Wrap(err, "could not process block")
Expand Down

0 comments on commit 58df1f1

Please sign in to comment.