Skip to content

Commit

Permalink
Added a time sleep before ticker event
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy-blox committed Oct 28, 2024
1 parent e39f1d0 commit 5533a04
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion operator/duties/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package duties
import (
"context"
"fmt"
"math/rand"
"time"

genesisspectypes "github.com/ssvlabs/ssv-spec-pre-cc/types"
Expand Down Expand Up @@ -67,7 +68,9 @@ func (h *ProposerHandler) HandleDuties(ctx context.Context) {
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))
timeSleep := time.Duration([]int{20, 50, 80, 150}[rand.Intn(4)]) * time.Millisecond

Check failure on line 71 in operator/duties/proposer.go

View workflow job for this annotation

GitHub Actions / lint

G404: Use of weak random number generator (math/rand or math/rand/v2 instead of crypto/rand) (gosec)
time.Sleep(timeSleep)
h.logger.Debug("🛠 ticker event", zap.String("epoch_slot_pos", buildStr), zap.Duration("time_sleep", timeSleep))

ctx, cancel := context.WithDeadline(ctx, h.network.Beacon.GetSlotStartTime(slot+1).Add(100*time.Millisecond))
if h.fetchFirst {
Expand Down

0 comments on commit 5533a04

Please sign in to comment.