mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 11:32:09 +00:00
Remove the getPayloadAttribute call from updateForkchoiceWithExecution (#13402)
* Remove the getPayloadAttribute call from updateForkchoiceWithExecution * Move log
This commit is contained in:
parent
8c1e180dd1
commit
31c72672d7
@ -8,7 +8,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
doublylinkedtree "github.com/prysmaticlabs/prysm/v4/beacon-chain/forkchoice/doubly-linked-tree"
|
||||
"github.com/prysmaticlabs/prysm/v4/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v4/config/features"
|
||||
"github.com/prysmaticlabs/prysm/v4/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/interfaces"
|
||||
payloadattribute "github.com/prysmaticlabs/prysm/v4/consensus-types/payload-attribute"
|
||||
@ -59,19 +58,7 @@ func (s *Service) forkchoiceUpdateWithExecution(ctx context.Context, args *fcuCo
|
||||
defer span.End()
|
||||
// Note: Use the service context here to avoid the parent context being ended during a forkchoice update.
|
||||
ctx = trace.NewContext(s.ctx, span)
|
||||
fcuArgs := &fcuConfig{
|
||||
headState: args.headState,
|
||||
headRoot: args.headRoot,
|
||||
headBlock: args.headBlock,
|
||||
}
|
||||
_, tracked := s.trackedProposer(args.headState, args.proposingSlot)
|
||||
if tracked && !features.Get().DisableReorgLateBlocks {
|
||||
if s.shouldOverrideFCU(args.headRoot, args.proposingSlot) {
|
||||
return nil
|
||||
}
|
||||
fcuArgs.attributes = s.getPayloadAttribute(ctx, args.headState, args.proposingSlot, args.headRoot[:])
|
||||
}
|
||||
_, err := s.notifyForkchoiceUpdate(ctx, fcuArgs)
|
||||
_, err := s.notifyForkchoiceUpdate(ctx, args)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not notify forkchoice update")
|
||||
}
|
||||
|
@ -74,6 +74,8 @@ func (s *Service) postBlockProcess(ctx context.Context, signed interfaces.ReadOn
|
||||
log.WithError(err).Warn("Could not update head")
|
||||
}
|
||||
newBlockHeadElapsedTime.Observe(float64(time.Since(start).Milliseconds()))
|
||||
proposingSlot := s.CurrentSlot() + 1
|
||||
var fcuArgs *fcuConfig
|
||||
if blockRoot != headRoot {
|
||||
receivedWeight, err := s.cfg.ForkChoiceStore.Weight(blockRoot)
|
||||
if err != nil {
|
||||
@ -89,23 +91,16 @@ func (s *Service) postBlockProcess(ctx context.Context, signed interfaces.ReadOn
|
||||
"headRoot": fmt.Sprintf("%#x", headRoot),
|
||||
"headWeight": headWeight,
|
||||
}).Debug("Head block is not the received block")
|
||||
if s.isNewHead(headRoot) {
|
||||
headState, headBlock, err := s.getStateAndBlock(ctx, headRoot)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not get forkchoice update argument")
|
||||
return nil
|
||||
}
|
||||
// verify conditions for FCU, notifies FCU, and saves the new head.
|
||||
// This function also prunes attestations, other similar operations happen in prunePostBlockOperationPools.
|
||||
args := &fcuConfig{
|
||||
fcuArgs = &fcuConfig{
|
||||
headState: headState,
|
||||
headBlock: headBlock,
|
||||
headRoot: headRoot,
|
||||
proposingSlot: s.CurrentSlot() + 1,
|
||||
}
|
||||
if err := s.forkchoiceUpdateWithExecution(ctx, args); err != nil {
|
||||
return err
|
||||
}
|
||||
proposingSlot: proposingSlot,
|
||||
}
|
||||
} else {
|
||||
// Updating next slot state cache can happen in the background
|
||||
@ -132,16 +127,26 @@ func (s *Service) postBlockProcess(ctx context.Context, signed interfaces.ReadOn
|
||||
}
|
||||
// verify conditions for FCU, notifies FCU, and saves the new head.
|
||||
// This function also prunes attestations, other similar operations happen in prunePostBlockOperationPools.
|
||||
args := &fcuConfig{
|
||||
fcuArgs = &fcuConfig{
|
||||
headState: postState,
|
||||
headBlock: signed,
|
||||
headRoot: headRoot,
|
||||
proposingSlot: s.CurrentSlot() + 1,
|
||||
proposingSlot: proposingSlot,
|
||||
}
|
||||
if err := s.forkchoiceUpdateWithExecution(ctx, args); err != nil {
|
||||
}
|
||||
if s.isNewHead(headRoot) {
|
||||
shouldOverrideFCU := false
|
||||
_, tracked := s.trackedProposer(fcuArgs.headState, proposingSlot)
|
||||
if tracked && !features.Get().DisableReorgLateBlocks {
|
||||
shouldOverrideFCU = s.shouldOverrideFCU(headRoot, proposingSlot)
|
||||
fcuArgs.attributes = s.getPayloadAttribute(ctx, fcuArgs.headState, proposingSlot, headRoot[:])
|
||||
}
|
||||
if !shouldOverrideFCU {
|
||||
if err := s.forkchoiceUpdateWithExecution(ctx, fcuArgs); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
optimistic, err := s.cfg.ForkChoiceStore.IsOptimistic(blockRoot)
|
||||
if err != nil {
|
||||
log.WithError(err).Debug("Could not check if block is optimistic")
|
||||
|
@ -139,22 +139,29 @@ func (s *Service) UpdateHead(ctx context.Context, proposingSlot primitives.Slot)
|
||||
if !s.isNewHead(newHeadRoot) {
|
||||
return
|
||||
}
|
||||
log.WithField("newHeadRoot", fmt.Sprintf("%#x", newHeadRoot)).Debug("Head changed due to attestations")
|
||||
headState, headBlock, err := s.getStateAndBlock(ctx, newHeadRoot)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("could not get head block")
|
||||
return
|
||||
}
|
||||
newAttHeadElapsedTime.Observe(float64(time.Since(start).Milliseconds()))
|
||||
args := &fcuConfig{
|
||||
fcuArgs := &fcuConfig{
|
||||
headState: headState,
|
||||
headRoot: newHeadRoot,
|
||||
headBlock: headBlock,
|
||||
proposingSlot: proposingSlot,
|
||||
}
|
||||
if err := s.forkchoiceUpdateWithExecution(s.ctx, args); err != nil {
|
||||
_, tracked := s.trackedProposer(headState, proposingSlot)
|
||||
if tracked && !features.Get().DisableReorgLateBlocks {
|
||||
if s.shouldOverrideFCU(newHeadRoot, proposingSlot) {
|
||||
return
|
||||
}
|
||||
fcuArgs.attributes = s.getPayloadAttribute(ctx, headState, proposingSlot, newHeadRoot[:])
|
||||
}
|
||||
if err := s.forkchoiceUpdateWithExecution(s.ctx, fcuArgs); err != nil {
|
||||
log.WithError(err).Error("could not update forkchoice")
|
||||
}
|
||||
log.WithField("newHeadRoot", fmt.Sprintf("%#x", newHeadRoot)).Debug("Head changed due to attestations")
|
||||
}
|
||||
|
||||
// This processes fork choice attestations from the pool to account for validator votes and fork choice.
|
||||
|
Loading…
Reference in New Issue
Block a user