Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only update head at 10 seconds when validating #13570

Merged
merged 2 commits into from Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions beacon-chain/blockchain/chain_info.go
Expand Up @@ -571,3 +571,9 @@ func (s *Service) inRegularSync() bool {
}
return fc.HighestReceivedBlockDelay() < params.BeaconConfig().SlotsPerEpoch
}

// validating returns true if the beacon is tracking some validators that have
// registered for proposing.
func (s *Service) validating() bool {
return s.cfg.TrackedValidatorsCache.Validating()
}
4 changes: 3 additions & 1 deletion beacon-chain/blockchain/receive_attestation.go
Expand Up @@ -95,7 +95,9 @@ func (s *Service) spawnProcessAttestationsRoutine() {
return
case slotInterval := <-ticker.C():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ticker is also triggered at 0s, so either it's a bug or we need to update the PR title and description

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm. I see the if slotInterval.Interval > 0 { below

if slotInterval.Interval > 0 {
s.UpdateHead(s.ctx, slotInterval.Slot+1)
if s.validating() {
s.UpdateHead(s.ctx, slotInterval.Slot+1)
}
} else {
s.cfg.ForkChoiceStore.Lock()
if err := s.cfg.ForkChoiceStore.NewSlot(s.ctx, slotInterval.Slot); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions beacon-chain/cache/tracked_validators.go
Expand Up @@ -41,3 +41,9 @@ func (t *TrackedValidatorsCache) Prune() {
defer t.Unlock()
t.trackedValidators = make(map[primitives.ValidatorIndex]TrackedValidator)
}

func (t *TrackedValidatorsCache) Validating() bool {
t.Lock()
defer t.Unlock()
return len(t.trackedValidators) > 0
}
2 changes: 2 additions & 0 deletions beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go
Expand Up @@ -2703,8 +2703,10 @@ func TestProposer_PrepareBeaconProposer(t *testing.T) {
return
}
require.NoError(t, err)
require.Equal(t, false, proposerServer.TrackedValidatorsCache.Validating())
val, tracked := proposerServer.TrackedValidatorsCache.Validator(1)
require.Equal(t, true, tracked)
require.Equal(t, true, proposerServer.TrackedValidatorsCache.Validating())
require.Equal(t, primitives.ExecutionAddress(tt.args.request.Recipients[0].FeeRecipient), val.FeeRecipient)

})
Expand Down