Commit 853842d1 authored by refcell's avatar refcell Committed by GitHub

fix(op-dispute-mon): export forecast to keep exporting consistent (#10430)

parent 89a3a5f3
......@@ -42,21 +42,21 @@ type forecastBatch struct {
LatestInvalidProposal uint64
}
type forecast struct {
type Forecast struct {
logger log.Logger
metrics ForecastMetrics
validator OutputValidator
}
func newForecast(logger log.Logger, metrics ForecastMetrics, validator OutputValidator) *forecast {
return &forecast{
func NewForecast(logger log.Logger, metrics ForecastMetrics, validator OutputValidator) *Forecast {
return &Forecast{
logger: logger,
metrics: metrics,
validator: validator,
}
}
func (f *forecast) Forecast(ctx context.Context, games []*monTypes.EnrichedGameData, ignoredCount int) {
func (f *Forecast) Forecast(ctx context.Context, games []*monTypes.EnrichedGameData, ignoredCount int) {
batch := forecastBatch{}
for _, game := range games {
if err := f.forecastGame(ctx, game, &batch); err != nil {
......@@ -66,7 +66,7 @@ func (f *forecast) Forecast(ctx context.Context, games []*monTypes.EnrichedGameD
f.recordBatch(batch, ignoredCount)
}
func (f *forecast) recordBatch(batch forecastBatch, ignoredCount int) {
func (f *Forecast) recordBatch(batch forecastBatch, ignoredCount int) {
f.metrics.RecordGameAgreement(metrics.AgreeDefenderWins, batch.AgreeDefenderWins)
f.metrics.RecordGameAgreement(metrics.DisagreeDefenderWins, batch.DisagreeDefenderWins)
f.metrics.RecordGameAgreement(metrics.AgreeChallengerWins, batch.AgreeChallengerWins)
......@@ -82,7 +82,7 @@ func (f *forecast) recordBatch(batch forecastBatch, ignoredCount int) {
f.metrics.RecordIgnoredGames(ignoredCount)
}
func (f *forecast) forecastGame(ctx context.Context, game *monTypes.EnrichedGameData, metrics *forecastBatch) error {
func (f *Forecast) forecastGame(ctx context.Context, game *monTypes.EnrichedGameData, metrics *forecastBatch) error {
// Check the root agreement.
agreement, expected, err := f.validator.CheckRootAgreement(ctx, game.L1HeadNum, game.L2BlockNumber, game.RootClaim)
if err != nil {
......
......@@ -266,13 +266,13 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) {
require.EqualValues(t, 7, m.latestInvalidProposal)
}
func setupForecastTest(t *testing.T) (*forecast, *mockForecastMetrics, *stubOutputValidator, *testlog.CapturingHandler) {
func setupForecastTest(t *testing.T) (*Forecast, *mockForecastMetrics, *stubOutputValidator, *testlog.CapturingHandler) {
logger, capturedLogs := testlog.CaptureLogger(t, log.LvlDebug)
validator := &stubOutputValidator{}
m := &mockForecastMetrics{
gameAgreement: zeroGameAgreement(),
}
return newForecast(logger, m, validator), m, validator, capturedLogs
return NewForecast(logger, m, validator), m, validator, capturedLogs
}
func zeroGameAgreement() map[metrics.GameAgreementStatus]int {
......
......@@ -13,7 +13,7 @@ import (
"github.com/ethereum/go-ethereum/log"
)
type Forecast func(ctx context.Context, games []*types.EnrichedGameData, ignoredCount int)
type ForecastResolution func(ctx context.Context, games []*types.EnrichedGameData, ignoredCount int)
type Bonds func(games []*types.EnrichedGameData)
type Resolutions func(games []*types.EnrichedGameData)
type MonitorClaims func(games []*types.EnrichedGameData)
......@@ -33,7 +33,7 @@ type gameMonitor struct {
gameWindow time.Duration
monitorInterval time.Duration
forecast Forecast
forecast ForecastResolution
bonds Bonds
resolutions Resolutions
claims MonitorClaims
......@@ -49,7 +49,7 @@ func newGameMonitor(
cl clock.Clock,
monitorInterval time.Duration,
gameWindow time.Duration,
forecast Forecast,
forecast ForecastResolution,
bonds Bonds,
resolutions Resolutions,
claims MonitorClaims,
......
......@@ -37,7 +37,7 @@ type Service struct {
cl clock.Clock
extractor *extract.Extractor
forecast *forecast
forecast *Forecast
bonds *bonds.Bonds
game *extract.GameCallerCreator
resolutions *ResolutionMonitor
......@@ -142,7 +142,7 @@ func (s *Service) initExtractor(cfg *config.Config) {
}
func (s *Service) initForecast(cfg *config.Config) {
s.forecast = newForecast(s.logger, s.metrics, s.validator)
s.forecast = NewForecast(s.logger, s.metrics, s.validator)
}
func (s *Service) initBonds() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment