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

refetch duties after metadata update #1470

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eth/eventhandler/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"errors"
"fmt"

"github.com/ssvlabs/ssv/exporter/convert"

"github.com/attestantio/go-eth2-client/spec/phase0"
Expand Down
5 changes: 4 additions & 1 deletion operator/duties/attester.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ func (h *AttesterHandler) HandleDuties(ctx context.Context) {

h.fetchNextEpoch = true

next := h.ticker.Next()
for {
select {
case <-ctx.Done():
return

case <-h.ticker.Next():
case <-next:
slot := h.ticker.Slot()
next = h.ticker.Next()
currentEpoch := h.network.Beacon.EstimatedEpochAtSlot(slot)
buildStr := fmt.Sprintf("e%v-s%v-#%v", currentEpoch, slot, slot%32+1)
h.logger.Debug("🛠 ticker event", zap.String("epoch_slot_pos", buildStr))
Expand Down Expand Up @@ -203,6 +205,7 @@ func (h *AttesterHandler) fetchAndProcessDuties(ctx context.Context, epoch phase
indices := indicesFromShares(h.validatorProvider.SelfParticipatingValidators(epoch))

if len(indices) == 0 {
h.logger.Debug("no active validators for epoch", fields.Epoch(epoch))
return nil
}

Expand Down
4 changes: 3 additions & 1 deletion operator/duties/committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ func (h *CommitteeHandler) HandleDuties(ctx context.Context) {
h.logger.Info("starting duty handler")
defer h.logger.Info("duty handler exited")

next := h.ticker.Next()
for {
select {
case <-ctx.Done():
return

case <-h.ticker.Next():
case <-next:
slot := h.ticker.Slot()
next = h.ticker.Next()
epoch := h.network.Beacon.EstimatedEpochAtSlot(slot)
period := h.network.Beacon.EstimatedSyncCommitteePeriodAtEpoch(epoch)
buildStr := fmt.Sprintf("p%v-e%v-s%v-#%v", period, epoch, slot, slot%32+1)
Expand Down
5 changes: 4 additions & 1 deletion operator/duties/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ func (h *ProposerHandler) HandleDuties(ctx context.Context) {
h.logger.Info("starting duty handler")
defer h.logger.Info("duty handler exited")

next := h.ticker.Next()
for {
select {
case <-ctx.Done():
return

case <-h.ticker.Next():
case <-next:
slot := h.ticker.Slot()
next = h.ticker.Next()
currentEpoch := h.network.Beacon.EstimatedEpochAtSlot(slot)
buildStr := fmt.Sprintf("e%v-s%v-#%v", currentEpoch, slot, slot%32+1)
h.logger.Debug("🛠 ticker event", zap.String("epoch_slot_pos", buildStr))
Expand Down Expand Up @@ -147,6 +149,7 @@ func (h *ProposerHandler) fetchAndProcessDuties(ctx context.Context, epoch phase

allIndices := indicesFromShares(h.validatorProvider.ParticipatingValidators(epoch))
if len(allIndices) == 0 {
h.logger.Debug("no active validators for epoch", fields.Epoch(epoch))
return nil
}

Expand Down
5 changes: 4 additions & 1 deletion operator/duties/sync_committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ func (h *SyncCommitteeHandler) HandleDuties(ctx context.Context) {
h.fetchNextPeriod = true
}

next := h.ticker.Next()
for {
select {
case <-ctx.Done():
return

case <-h.ticker.Next():
case <-next:
slot := h.ticker.Slot()
next = h.ticker.Next()
epoch := h.network.Beacon.EstimatedEpochAtSlot(slot)
period := h.network.Beacon.EstimatedSyncCommitteePeriodAtEpoch(epoch)
buildStr := fmt.Sprintf("p%v-e%v-s%v-#%v", period, epoch, slot, slot%32+1)
Expand Down Expand Up @@ -200,6 +202,7 @@ func (h *SyncCommitteeHandler) fetchAndProcessDuties(ctx context.Context, period

allActiveIndices := h.validatorController.AllActiveIndices(firstEpoch, waitForInitial)
if len(allActiveIndices) == 0 {
h.logger.Debug("no active validators for period", fields.Epoch(currentEpoch), zap.Uint64("period", period))
return nil
}

Expand Down
4 changes: 3 additions & 1 deletion operator/duties/validatorregistration.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ func (h *ValidatorRegistrationHandler) HandleDuties(ctx context.Context) {
// should be registered within validatorRegistrationEpochInterval epochs time in a corresponding slot
registrationSlotInterval := h.network.SlotsPerEpoch() * validatorRegistrationEpochInterval

next := h.ticker.Next()
for {
select {
case <-ctx.Done():
return

case <-h.ticker.Next():
case <-next:
slot := h.ticker.Slot()
next = h.ticker.Next()
epoch := h.network.Beacon.EstimatedEpochAtSlot(slot)
shares := h.validatorProvider.SelfParticipatingValidators(epoch + phase0.Epoch(validatorRegistrationEpochInterval))

Expand Down
4 changes: 3 additions & 1 deletion operator/duties/voluntary_exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ func (h *VoluntaryExitHandler) HandleDuties(ctx context.Context) {
h.logger.Info("starting duty handler")
defer h.logger.Info("duty handler exited")

next := h.ticker.Next()
for {
select {
case <-ctx.Done():
return

case <-h.ticker.Next():
case <-next:
currentSlot := h.ticker.Slot()
next = h.ticker.Next()

h.logger.Debug("🛠 ticker event", fields.Slot(currentSlot))

Expand Down
Loading
Loading