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

core/tracker2: add tracker2 package #1666

Merged
merged 3 commits into from
Jan 24, 2023
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
2 changes: 2 additions & 0 deletions core/consensus/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ func (c *Component) propose(ctx context.Context, duty core.Duty, value proto.Mes

if !decided {
consensusTimeout.WithLabelValues(duty.Type.String()).Inc()

return errors.New("consensus timeout", z.Str("duty", duty.String()))
}

return nil
Expand Down
24 changes: 24 additions & 0 deletions core/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,30 @@ type Broadcaster interface {
Broadcast(context.Context, Duty, PubKey, SignedData) error
}

// Tracker sends core component events for further analysis and instrumentation.
type Tracker interface {
// FetcherFetched sends Fetcher component's events to tracker.
FetcherFetched(context.Context, Duty, DutyDefinitionSet, error)

// ConsensusProposed sends Consensus component's events to tracker.
ConsensusProposed(context.Context, Duty, UnsignedDataSet, error)

// DutyDBStored sends DutyDB component's store events to tracker.
DutyDBStored(context.Context, Duty, UnsignedDataSet, error)

// ParSigDBStoredInternal sends ParSigDB component's store internal events to tracker.
ParSigDBStoredInternal(context.Context, Duty, ParSignedDataSet, error)

// ParSigDBStoredExternal sends ParSigDB component's store external events to tracker.
ParSigDBStoredExternal(context.Context, Duty, ParSignedDataSet, error)

// SigAggAggregated sends SigAgg component's events to tracker.
SigAggAggregated(context.Context, Duty, PubKey, []ParSignedData, error)

// BroadcasterBroadcast sends Broadcaster component's broadcast events to tracker.
BroadcasterBroadcast(context.Context, Duty, PubKey, SignedData, error)
}

// wireFuncs defines the core workflow components as a list of input and output functions
// instead as interfaces, since functions are easier to wrap than interfaces.
type wireFuncs struct {
Expand Down
2 changes: 2 additions & 0 deletions core/sigagg/sigagg.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func (a *Aggregator) Subscribe(fn func(context.Context, core.Duty, core.PubKey,

// Aggregate aggregates the partially signed duty data for the DV.
func (a *Aggregator) Aggregate(ctx context.Context, duty core.Duty, pubkey core.PubKey, parSigs []core.ParSignedData) error {
ctx = log.WithTopic(ctx, "sigagg")

if len(parSigs) < a.threshold {
return errors.New("require threshold signatures")
} else if a.threshold == 0 {
Expand Down
59 changes: 59 additions & 0 deletions core/tracker/tracker2/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright © 2022 Obol Labs Inc.
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.

package tracker2

import (
"github.com/prometheus/client_golang/prometheus"

"github.com/obolnetwork/charon/app/promauto"
)

var (
participationGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can create duplicate metrics, suggest only moving metrics here once they are "enabled" in v2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tracker2 in metrics naming to avoid duplication, v2 will be behind a featureflag until we are confident. These metrics were needed since I copy pasted most of the code and metrics was also part of it.
Will address this in my next PR to wire and add tests.

Namespace: "core",
Subsystem: "tracker2",
Name: "participation",
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: "tracker2",
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: "tracker2",
Name: "failed_duties_total",
Help: "Total number of failed duties by type",
}, []string{"duty"})

unexpectedEventsCounter = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "core",
Subsystem: "tracker2",
Name: "unexpected_events_total",
Help: "Total number of unexpected events by peer",
}, []string{"peer"})

inconsistentCounter = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "core",
Subsystem: "tracker2",
Name: "inconsistent_parsigs_total",
Help: "Total number of duties that contained inconsistent partial signed data by duty type",
}, []string{"duty"})
)
Loading