Compare commits

...

1 Commits

Author SHA1 Message Date
terence tsao
ab41335404 Capture time when >50% of beacon attestation arrive 2024-06-04 20:00:58 -07:00
3 changed files with 38 additions and 0 deletions

View File

@@ -150,6 +150,12 @@ var (
Help: "Time to verify gossiped blob sidecars",
},
)
beaconAttestationReachHalfSummary = promauto.NewSummary(
prometheus.SummaryOpts{
Name: "attestation_reach_half_milliseconds",
Help: "Time for attestations to reach half",
},
)
pendingAttCount = promauto.NewCounter(prometheus.CounterOpts{
Name: "gossip_pending_attestations_total",
Help: "increased when receiving a new pending attestation",

View File

@@ -158,6 +158,7 @@ type Service struct {
newBlobVerifier verification.NewBlobVerifier
availableBlocker coverage.AvailableBlocker
ctxMap ContextByteVersions
attReceived chan struct{}
}
// NewService initializes new regular sync service.
@@ -173,6 +174,7 @@ func NewService(ctx context.Context, opts ...Option) *Service {
seenPendingBlocks: make(map[[32]byte]bool),
blkRootToPendingAtts: make(map[[32]byte][]*ethpb.SignedAggregateAttestationAndProof),
signatureChan: make(chan *signatureVerifier, verifierLimit),
attReceived: make(chan struct{}),
}
for _, opt := range opts {
if err := opt(r); err != nil {
@@ -237,6 +239,8 @@ func (s *Service) Start() {
s.maintainPeerStatuses()
s.resyncIfBehind()
go s.beaconAttestationWatcher()
// Update sync metrics.
async.RunEvery(s.ctx, syncMetricsInterval, s.updateMetrics)
}

View File

@@ -33,6 +33,8 @@ func (s *Service) committeeIndexBeaconAttestationSubscriber(_ context.Context, m
return nil
}
s.attReceived <- struct{}{}
return s.cfg.attPool.SaveUnaggregatedAttestation(a)
}
@@ -59,3 +61,29 @@ func (_ *Service) attesterSubnetIndices(currentSlot primitives.Slot) []uint64 {
}
return slice.SetUint64(commIds)
}
func (s *Service) beaconAttestationWatcher() {
slotTicker := slots.NewSlotTicker(s.cfg.chain.GenesisTime(), params.BeaconConfig().SecondsPerSlot)
count := 0
for {
select {
case currSlot := <-slotTicker.C():
log.Infof("Beacon Attestation Watcher: Clearing Slot: %d, Total received: %d", currSlot, count)
count = 0
case <-s.attReceived:
count++
// 1014657 / 32 / 2 =15854
if count == 15854 {
t := uint64(s.cfg.chain.GenesisTime().Unix())
d := slots.TimeIntoSlot(t)
currentSlot := slots.CurrentSlot(t)
duration := d.Milliseconds() - 4000
beaconAttestationReachHalfSummary.Observe(float64(duration))
log.Infof("Beacon Attestation Watcher: Receive enough attestation for slot: %d and it took time %d", currentSlot, duration)
}
case <-s.ctx.Done():
slotTicker.Done()
return
}
}
}