Skip to content

Commit

Permalink
add metrics for time it took to aggregate a single attestation (#12390)
Browse files Browse the repository at this point in the history
Co-authored-by: shota.silagadze <[email protected]>
  • Loading branch information
shotasilagadze and shotasilagadzetaal authored Oct 22, 2024
1 parent 21562b6 commit e7cb625
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cl/monitor/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var (
activeValidatorsCount = metrics.GetOrCreateGauge("active_validators_count")
currentSlot = metrics.GetOrCreateGauge("current_slot")
currentEpoch = metrics.GetOrCreateGauge("current_epoch")
aggregateAttestation = metrics.GetOrCreateGauge("aggregate_attestation")

// Libp2p metrics
totalInBytes = metrics.GetOrCreateGauge("total_in_bytes")
Expand Down Expand Up @@ -131,6 +132,11 @@ func ObserveProcessJustificationBitsAndFinalityTime(startTime time.Time) {
processJustificationBitsAndFinalityTime.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveAggregateAttestation sets the time it took add new attestation to aggregateAndProof
func ObserveAggregateAttestation(startTime time.Time) {
aggregateAttestation.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveProcessRewardsAndPenaltiesTime sets ProcessRewardsAndPenalties time
func ObserveProcessRewardsAndPenaltiesTime(startTime time.Time) {
processRewardsAndPenaltiesTime.Set(float64(time.Since(startTime).Microseconds()))
Expand Down
3 changes: 3 additions & 0 deletions cl/phase1/network/services/attestation_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/erigontech/erigon/cl/clparams"
"github.com/erigontech/erigon/cl/cltypes/solid"
"github.com/erigontech/erigon/cl/fork"
"github.com/erigontech/erigon/cl/monitor"
"github.com/erigontech/erigon/cl/phase1/core/state/lru"
"github.com/erigontech/erigon/cl/phase1/forkchoice"
"github.com/erigontech/erigon/cl/phase1/network/subnets"
Expand Down Expand Up @@ -244,6 +245,8 @@ func (s *attestationService) ProcessMessage(ctx context.Context, subnet *uint64,
Pks: [][]byte{pubKey[:]},
GossipData: att.GossipData,
F: func() {
start := time.Now()
defer monitor.ObserveAggregateAttestation(start)
err = s.committeeSubscribe.AggregateAttestation(att.Attestation)
if errors.Is(err, aggregation.ErrIsSuperset) {
return
Expand Down

0 comments on commit e7cb625

Please sign in to comment.