Compare commits

...

3 Commits

Author SHA1 Message Date
terencechain
2fa646e7c5 Merge branch 'develop' into new-slot-before-propose 2022-05-20 06:54:01 -07:00
terence tsao
90df2e4d00 Add new slot lock 2022-05-19 13:41:39 -07:00
terence tsao
c43ad9d561 Call NewSlot before propose block 2022-05-19 11:37:56 -07:00
5 changed files with 13 additions and 1 deletions

View File

@@ -32,8 +32,9 @@ type ChainInfoFetcher interface {
}
// HeadUpdater defines a common interface for methods in blockchain service
// which allow to update the head info
// which allow to update the head info and update propose boost score and justified check point via on_tick.
type HeadUpdater interface {
NewSlot(ctx context.Context, slot types.Slot) error
UpdateHead(context.Context) error
}

View File

@@ -30,6 +30,8 @@ import (
// if ancestor_at_finalized_slot == store.finalized_checkpoint.root:
// store.justified_checkpoint = store.best_justified_checkpoint
func (s *Service) NewSlot(ctx context.Context, slot types.Slot) error {
s.newSlotLock.Lock()
defer s.newSlotLock.Unlock()
// Reset proposer boost root in fork choice.
if err := s.cfg.ForkChoiceStore.ResetBoostedProposerRoot(ctx); err != nil {

View File

@@ -66,6 +66,7 @@ type Service struct {
wsVerifier *WeakSubjectivityVerifier
store *store.Store
processAttestationsLock sync.Mutex
newSlotLock sync.Mutex
}
// config options for the service.

View File

@@ -456,3 +456,8 @@ func (s *ChainService) UpdateHead(_ context.Context) error { return nil }
// ReceiveAttesterSlashing mocks the same method in the chain service.
func (s *ChainService) ReceiveAttesterSlashing(context.Context, *ethpb.AttesterSlashing) {}
// NewSlot mocks the same method in the chain service.
func (s *ChainService) NewSlot(context.Context, types.Slot) error {
return nil
}

View File

@@ -82,6 +82,9 @@ func (vs *Server) buildPhase0BlockData(ctx context.Context, req *ethpb.BlockRequ
return nil, fmt.Errorf("syncing to latest head, not ready to respond")
}
if err := vs.HeadUpdater.NewSlot(ctx, req.Slot); err != nil {
log.WithError(err).Error("Could not update propose boost score")
}
if err := vs.HeadUpdater.UpdateHead(ctx); err != nil {
log.WithError(err).Error("Could not process attestations and update head")
}