Skip to content

Commit

Permalink
core/tracker: add participation counter (#1175)
Browse files Browse the repository at this point in the history
Adds participation counter metric.
Fixes unexpected event logic for `DutyPrepareAggreagtor`.
Updates simnet dashboard.

category: feature
ticket: #1109
  • Loading branch information
corverroos committed Sep 27, 2022
1 parent 13d081b commit af27f95
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 267 deletions.
9 changes: 8 additions & 1 deletion core/tracker/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ var (
Help: "Set to 1 if peer participated successfully for the given duty or else 0",
}, []string{"duty", "peer"})

participationCounter = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "core",
Subsystem: "tracker",
Name: "participation_total",
Help: "Total number of successful participations by peer and duty type",
}, []string{"duty", "peer"})

failedCounter = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "core",
Subsystem: "tracker",
Name: "failed_duties_total",
Help: "Total number of failed duties by component",
Help: "Total number of failed duties by type and component",
}, []string{"duty", "component"})

unexpectedEventsCounter = promauto.NewCounterVec(prometheus.CounterOpts{
Expand Down
15 changes: 12 additions & 3 deletions core/tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func analyseFetcherFailed(duty core.Duty, allEvents map[core.Duty][]event) (bool
// and "failed fetching aggregated attestation from BN".
//
// Assume no aggregators for slot as this is very common.
return false, zero, ""
return false, fetcher, ""
}

return true, fetcher, msg
Expand Down Expand Up @@ -393,6 +393,15 @@ func isParSigEventExpected(duty core.Duty, pubkey core.PubKey, allEvents map[cor
}
}

if duty.Type == core.DutyPrepareAggregator {
// Check that if we got DutyAttester event from scheduler.
for _, e := range allEvents[core.NewAttesterDuty(duty.Slot)] {
if e.component == scheduler && e.pubkey == pubkey {
return true
}
}
}

// For all other duties check for scheduler event.
for _, e := range allEvents[duty] {
if e.component == scheduler && e.pubkey == pubkey {
Expand All @@ -414,9 +423,9 @@ func newParticipationReporter(peers []p2p.Peer) func(context.Context, core.Duty,
for _, peer := range peers {
if participatedShares[peer.ShareIdx()] {
participationGauge.WithLabelValues(duty.Type.String(), peer.Name).Set(1)
participationCounter.WithLabelValues(duty.Type.String(), peer.Name).Inc()
} else if unexpectedShares[peer.ShareIdx()] {
// TODO(corver): Enable with https://github.com/ObolNetwork/charon/issues/993
// log.Warn(ctx, "Unexpected event found", nil, z.Str("peer", peer.Name), z.Str("duty", duty.String()))
log.Warn(ctx, "Unexpected event found", nil, z.Str("peer", peer.Name), z.Str("duty", duty.String()))
unexpectedEventsCounter.WithLabelValues(peer.Name).Inc()
} else {
absentPeers = append(absentPeers, peer.Name)
Expand Down
7 changes: 7 additions & 0 deletions testutil/compose/compose/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ func newNewCmd() *cobra.Command {
splitKeys := cmd.Flags().String("split-keys-dir", conf.SplitKeysDir, "Directory containing keys to split for keygen==create, or empty not to split.")
featureSet := cmd.Flags().String("feature-set", conf.FeatureSet, "Minimum feature set to enable: alpha, beta, stable")
numVals := cmd.Flags().Int("num-validators", conf.NumValidators, "Number of distributed validators.")
vcTypes := cmd.Flags().StringSlice("validator-types", conf.VCStrings(), "Validator types to include.")

cmd.RunE = func(cmd *cobra.Command, _ []string) error {
conf.KeyGen = compose.KeyGen(*keygen)
Expand All @@ -292,6 +293,12 @@ func newNewCmd() *cobra.Command {
conf.ExternalBootnode = *extBootnode
conf.NumValidators = *numVals

var vcs []compose.VCType
for _, vc := range *vcTypes {
vcs = append(vcs, compose.VCType(vc))
}
conf.VCs = vcs

ctx := log.WithTopic(cmd.Context(), "new")
if err := compose.New(ctx, *dir, conf); err != nil {
log.Error(ctx, "Fatal error", err)
Expand Down
10 changes: 10 additions & 0 deletions testutil/compose/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ type Config struct {
DisableLoki bool `json:"disable_loki"`
}

// VCStrings returns the VCs field as a slice of strings.
func (c Config) VCStrings() []string {
var resp []string
for _, vc := range c.VCs {
resp = append(resp, string(vc))
}

return resp
}

// entrypoint returns the path to the charon binary based on the BuildLocal field.
func (c Config) entrypoint() string {
if c.BuildBinary || c.PrebuiltBinary {
Expand Down
Loading

0 comments on commit af27f95

Please sign in to comment.