Commit 100f526e authored by Ian L's avatar Ian L Committed by GitHub

[op-dispute-mon] Track the latest proposed L2 block number from games w/ a...

[op-dispute-mon] Track the latest proposed L2 block number from games w/ a valid root claim (#11238)

We'd like to know the latest valid block number associated with a valid dispute game.
This would be the equivalent of getting the latest block number from `L2OutputOracle` in pre-FDG.
We could look into the `AnchorStateRegistry`, but this does not give us quick enough feedback
to know if we are keeping up with "proposing" correct root hashes for the most recent L2 blocks,
as dispute games resolves approximately 3.5 days (assuming happy path).

There can be many dispute games at any given time, and they may be valid or invalid.
This metric captures only valid block numbers from dispute games that we "agree" with.
parent 3c719a10
...@@ -173,6 +173,8 @@ type Metricer interface { ...@@ -173,6 +173,8 @@ type Metricer interface {
RecordGameAgreement(status GameAgreementStatus, count int) RecordGameAgreement(status GameAgreementStatus, count int)
RecordLatestValidProposalL2Block(latestValid uint64)
RecordLatestProposals(latestValid, latestInvalid uint64) RecordLatestProposals(latestValid, latestInvalid uint64)
RecordIgnoredGames(count int) RecordIgnoredGames(count int)
...@@ -216,6 +218,7 @@ type Metrics struct { ...@@ -216,6 +218,7 @@ type Metrics struct {
lastOutputFetch prometheus.Gauge lastOutputFetch prometheus.Gauge
gamesAgreement prometheus.GaugeVec gamesAgreement prometheus.GaugeVec
latestValidProposalL2Block prometheus.Gauge
latestProposals prometheus.GaugeVec latestProposals prometheus.GaugeVec
ignoredGames prometheus.Gauge ignoredGames prometheus.Gauge
failedGames prometheus.Gauge failedGames prometheus.Gauge
...@@ -333,6 +336,11 @@ func NewMetrics() *Metrics { ...@@ -333,6 +336,11 @@ func NewMetrics() *Metrics {
"result_correctness", "result_correctness",
"root_agreement", "root_agreement",
}), }),
latestValidProposalL2Block: factory.NewGauge(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "latest_valid_proposal_l2_block",
Help: "L2 block number proposed by the latest game with a valid root claim",
}),
latestProposals: *factory.NewGaugeVec(prometheus.GaugeOpts{ latestProposals: *factory.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace, Namespace: Namespace,
Name: "latest_proposal", Name: "latest_proposal",
...@@ -495,6 +503,10 @@ func (m *Metrics) RecordGameAgreement(status GameAgreementStatus, count int) { ...@@ -495,6 +503,10 @@ func (m *Metrics) RecordGameAgreement(status GameAgreementStatus, count int) {
m.gamesAgreement.WithLabelValues(labelValuesFor(status)...).Set(float64(count)) m.gamesAgreement.WithLabelValues(labelValuesFor(status)...).Set(float64(count))
} }
func (m *Metrics) RecordLatestValidProposalL2Block(latestValid uint64) {
m.latestValidProposalL2Block.Set(float64(latestValid))
}
func (m *Metrics) RecordLatestProposals(latestValid, latestInvalid uint64) { func (m *Metrics) RecordLatestProposals(latestValid, latestInvalid uint64) {
m.latestProposals.WithLabelValues("agree").Set(float64(latestValid)) m.latestProposals.WithLabelValues("agree").Set(float64(latestValid))
m.latestProposals.WithLabelValues("disagree").Set(float64(latestInvalid)) m.latestProposals.WithLabelValues("disagree").Set(float64(latestInvalid))
......
...@@ -38,6 +38,8 @@ func (*NoopMetricsImpl) RecordOutputFetchTime(_ float64) {} ...@@ -38,6 +38,8 @@ func (*NoopMetricsImpl) RecordOutputFetchTime(_ float64) {}
func (*NoopMetricsImpl) RecordGameAgreement(_ GameAgreementStatus, _ int) {} func (*NoopMetricsImpl) RecordGameAgreement(_ GameAgreementStatus, _ int) {}
func (*NoopMetricsImpl) RecordLatestValidProposalL2Block(_ uint64) {}
func (*NoopMetricsImpl) RecordLatestProposals(_, _ uint64) {} func (*NoopMetricsImpl) RecordLatestProposals(_, _ uint64) {}
func (*NoopMetricsImpl) RecordIgnoredGames(_ int) {} func (*NoopMetricsImpl) RecordIgnoredGames(_ int) {}
......
...@@ -16,6 +16,7 @@ var ( ...@@ -16,6 +16,7 @@ var (
type ForecastMetrics interface { type ForecastMetrics interface {
RecordGameAgreement(status metrics.GameAgreementStatus, count int) RecordGameAgreement(status metrics.GameAgreementStatus, count int)
RecordLatestValidProposalL2Block(validL2Block uint64)
RecordLatestProposals(validTimestamp, invalidTimestamp uint64) RecordLatestProposals(validTimestamp, invalidTimestamp uint64)
RecordIgnoredGames(count int) RecordIgnoredGames(count int)
RecordFailedGames(count int) RecordFailedGames(count int)
...@@ -32,6 +33,7 @@ type forecastBatch struct { ...@@ -32,6 +33,7 @@ type forecastBatch struct {
AgreeChallengerWins int AgreeChallengerWins int
DisagreeChallengerWins int DisagreeChallengerWins int
LatestValidProposalL2Block uint64
LatestInvalidProposal uint64 LatestInvalidProposal uint64
LatestValidProposal uint64 LatestValidProposal uint64
} }
...@@ -69,6 +71,7 @@ func (f *Forecast) recordBatch(batch forecastBatch, ignoredCount, failedCount in ...@@ -69,6 +71,7 @@ func (f *Forecast) recordBatch(batch forecastBatch, ignoredCount, failedCount in
f.metrics.RecordGameAgreement(metrics.AgreeDefenderAhead, batch.AgreeDefenderAhead) f.metrics.RecordGameAgreement(metrics.AgreeDefenderAhead, batch.AgreeDefenderAhead)
f.metrics.RecordGameAgreement(metrics.DisagreeDefenderAhead, batch.DisagreeDefenderAhead) f.metrics.RecordGameAgreement(metrics.DisagreeDefenderAhead, batch.DisagreeDefenderAhead)
f.metrics.RecordLatestValidProposalL2Block(batch.LatestValidProposalL2Block)
f.metrics.RecordLatestProposals(batch.LatestValidProposal, batch.LatestInvalidProposal) f.metrics.RecordLatestProposals(batch.LatestValidProposal, batch.LatestInvalidProposal)
f.metrics.RecordIgnoredGames(ignoredCount) f.metrics.RecordIgnoredGames(ignoredCount)
...@@ -90,6 +93,9 @@ func (f *Forecast) forecastGame(game *monTypes.EnrichedGameData, metrics *foreca ...@@ -90,6 +93,9 @@ func (f *Forecast) forecastGame(game *monTypes.EnrichedGameData, metrics *foreca
if metrics.LatestValidProposal < game.Timestamp { if metrics.LatestValidProposal < game.Timestamp {
metrics.LatestValidProposal = game.Timestamp metrics.LatestValidProposal = game.Timestamp
} }
if metrics.LatestValidProposalL2Block < game.L2BlockNumber {
metrics.LatestValidProposalL2Block = game.L2BlockNumber
}
} }
if game.Status != types.GameStatusInProgress { if game.Status != types.GameStatusInProgress {
......
...@@ -272,6 +272,7 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) { ...@@ -272,6 +272,7 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) {
Status: gameStatus[i], Status: gameStatus[i],
Claims: claims[i], Claims: claims[i],
RootClaim: rootClaims[i], RootClaim: rootClaims[i],
L2BlockNumber: uint64(i),
GameMetadata: types.GameMetadata{ GameMetadata: types.GameMetadata{
Timestamp: uint64(i), Timestamp: uint64(i),
}, },
...@@ -292,6 +293,7 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) { ...@@ -292,6 +293,7 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) {
require.Equal(t, expectedMetrics, m.gameAgreement) require.Equal(t, expectedMetrics, m.gameAgreement)
require.Equal(t, 3, m.ignoredGames) require.Equal(t, 3, m.ignoredGames)
require.Equal(t, 4, m.contractCreationFails) require.Equal(t, 4, m.contractCreationFails)
require.EqualValues(t, 8, m.latestValidProposalL2Block)
require.EqualValues(t, 7, m.latestInvalidProposal) require.EqualValues(t, 7, m.latestInvalidProposal)
require.EqualValues(t, 8, m.latestValidProposal) require.EqualValues(t, 8, m.latestValidProposal)
} }
...@@ -320,6 +322,7 @@ func zeroGameAgreement() map[metrics.GameAgreementStatus]int { ...@@ -320,6 +322,7 @@ func zeroGameAgreement() map[metrics.GameAgreementStatus]int {
type mockForecastMetrics struct { type mockForecastMetrics struct {
gameAgreement map[metrics.GameAgreementStatus]int gameAgreement map[metrics.GameAgreementStatus]int
ignoredGames int ignoredGames int
latestValidProposalL2Block uint64
latestInvalidProposal uint64 latestInvalidProposal uint64
latestValidProposal uint64 latestValidProposal uint64
contractCreationFails int contractCreationFails int
...@@ -333,6 +336,10 @@ func (m *mockForecastMetrics) RecordGameAgreement(status metrics.GameAgreementSt ...@@ -333,6 +336,10 @@ func (m *mockForecastMetrics) RecordGameAgreement(status metrics.GameAgreementSt
m.gameAgreement[status] = count m.gameAgreement[status] = count
} }
func (m *mockForecastMetrics) RecordLatestValidProposalL2Block(valid uint64) {
m.latestValidProposalL2Block = valid
}
func (m *mockForecastMetrics) RecordLatestProposals(valid, invalid uint64) { func (m *mockForecastMetrics) RecordLatestProposals(valid, invalid uint64) {
m.latestValidProposal = valid m.latestValidProposal = valid
m.latestInvalidProposal = invalid m.latestInvalidProposal = invalid
......
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