Compare commits

...

2 Commits

Author SHA1 Message Date
terence tsao
97cb9528de Add isNewHead to override 2023-03-18 10:19:53 -07:00
terence tsao
9f7aaa2309 Ensure we call fcu with attribute when head is not new but next slot proposer 2023-03-18 10:09:34 -07:00

View File

@@ -51,11 +51,11 @@ func (s *Service) getStateAndBlock(ctx context.Context, r [32]byte) (state.Beaco
// fockchoiceUpdateWithExecution is a wrapper around notifyForkchoiceUpdate. It decides whether a new call to FCU should be made.
func (s *Service) forkchoiceUpdateWithExecution(ctx context.Context, newHeadRoot [32]byte, proposingSlot primitives.Slot) error {
isNewHead := s.isNewHead(newHeadRoot)
if !isNewHead {
isNewProposer := s.isNewProposer(proposingSlot)
if !isNewHead && !isNewProposer {
return nil
}
isNewProposer := s.isNewProposer(proposingSlot)
if isNewProposer && !features.Get().DisableReorgLateBlocks {
if isNewHead && isNewProposer && !features.Get().DisableReorgLateBlocks {
if s.shouldOverrideFCU(newHeadRoot, proposingSlot) {
return nil
}
@@ -75,6 +75,11 @@ func (s *Service) forkchoiceUpdateWithExecution(ctx context.Context, newHeadRoot
return errors.Wrap(err, "could not notify forkchoice update")
}
// Don't need to save head info and prune canonical block operations if the head is not new.
if !isNewHead {
return nil
}
if err := s.saveHead(ctx, newHeadRoot, headBlock, headState); err != nil {
log.WithError(err).Error("could not save head")
}