Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
a5e34735
Unverified
Commit
a5e34735
authored
May 03, 2024
by
Adrian Sutton
Committed by
GitHub
May 03, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-dispute-mon: Add metric to report timestamp of last invalid proposal (#10373)
parent
8ed6612b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
22 deletions
+54
-22
metrics.go
op-dispute-mon/metrics/metrics.go
+14
-2
noop.go
op-dispute-mon/metrics/noop.go
+2
-0
forecast.go
op-dispute-mon/mon/forecast.go
+23
-3
forecast_test.go
op-dispute-mon/mon/forecast_test.go
+15
-5
types.go
op-dispute-mon/mon/types/types.go
+0
-12
No files found.
op-dispute-mon/metrics/metrics.go
View file @
a5e34735
...
...
@@ -92,6 +92,8 @@ type Metricer interface {
RecordGameAgreement
(
status
GameAgreementStatus
,
count
int
)
RecordLatestInvalidProposal
(
timestamp
uint64
)
RecordIgnoredGames
(
count
int
)
RecordBondCollateral
(
addr
common
.
Address
,
required
*
big
.
Int
,
available
*
big
.
Int
)
...
...
@@ -127,8 +129,9 @@ type Metrics struct {
lastOutputFetch
prometheus
.
Gauge
gamesAgreement
prometheus
.
GaugeVec
ignoredGames
prometheus
.
Gauge
gamesAgreement
prometheus
.
GaugeVec
latestInvalidProposal
prometheus
.
Gauge
ignoredGames
prometheus
.
Gauge
requiredCollateral
prometheus
.
GaugeVec
availableCollateral
prometheus
.
GaugeVec
...
...
@@ -228,6 +231,11 @@ func NewMetrics() *Metrics {
"result_correctness"
,
"root_agreement"
,
}),
latestInvalidProposal
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
Namespace
,
Name
:
"latest_invalid_proposal"
,
Help
:
"Timestamp of the most recent game with an invalid root claim in unix seconds"
,
}),
ignoredGames
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
Namespace
,
Name
:
"ignored_games"
,
...
...
@@ -370,6 +378,10 @@ func (m *Metrics) RecordGameAgreement(status GameAgreementStatus, count int) {
m
.
gamesAgreement
.
WithLabelValues
(
labelValuesFor
(
status
)
...
)
.
Set
(
float64
(
count
))
}
func
(
m
*
Metrics
)
RecordLatestInvalidProposal
(
timestamp
uint64
)
{
m
.
latestInvalidProposal
.
Set
(
float64
(
timestamp
))
}
func
(
m
*
Metrics
)
RecordIgnoredGames
(
count
int
)
{
m
.
ignoredGames
.
Set
(
float64
(
count
))
}
...
...
op-dispute-mon/metrics/noop.go
View file @
a5e34735
...
...
@@ -33,6 +33,8 @@ func (*NoopMetricsImpl) RecordOutputFetchTime(_ float64) {}
func
(
*
NoopMetricsImpl
)
RecordGameAgreement
(
_
GameAgreementStatus
,
_
int
)
{}
func
(
*
NoopMetricsImpl
)
RecordLatestInvalidProposal
(
_
uint64
)
{}
func
(
*
NoopMetricsImpl
)
RecordIgnoredGames
(
_
int
)
{}
func
(
i
*
NoopMetricsImpl
)
RecordBondCollateral
(
_
common
.
Address
,
_
*
big
.
Int
,
_
*
big
.
Int
)
{}
op-dispute-mon/mon/forecast.go
View file @
a5e34735
...
...
@@ -24,9 +24,24 @@ type OutputValidator interface {
type
ForecastMetrics
interface
{
RecordGameAgreement
(
status
metrics
.
GameAgreementStatus
,
count
int
)
RecordLatestInvalidProposal
(
timestamp
uint64
)
RecordIgnoredGames
(
count
int
)
}
type
forecastBatch
struct
{
AgreeDefenderAhead
int
DisagreeDefenderAhead
int
AgreeChallengerAhead
int
DisagreeChallengerAhead
int
AgreeDefenderWins
int
DisagreeDefenderWins
int
AgreeChallengerWins
int
DisagreeChallengerWins
int
LatestInvalidProposal
uint64
}
type
forecast
struct
{
logger
log
.
Logger
metrics
ForecastMetrics
...
...
@@ -42,7 +57,7 @@ func newForecast(logger log.Logger, metrics ForecastMetrics, validator OutputVal
}
func
(
f
*
forecast
)
Forecast
(
ctx
context
.
Context
,
games
[]
*
monTypes
.
EnrichedGameData
,
ignoredCount
int
)
{
batch
:=
monTypes
.
F
orecastBatch
{}
batch
:=
f
orecastBatch
{}
for
_
,
game
:=
range
games
{
if
err
:=
f
.
forecastGame
(
ctx
,
game
,
&
batch
);
err
!=
nil
{
f
.
logger
.
Error
(
"Failed to forecast game"
,
"err"
,
err
)
...
...
@@ -51,7 +66,7 @@ func (f *forecast) Forecast(ctx context.Context, games []*monTypes.EnrichedGameD
f
.
recordBatch
(
batch
,
ignoredCount
)
}
func
(
f
*
forecast
)
recordBatch
(
batch
monTypes
.
F
orecastBatch
,
ignoredCount
int
)
{
func
(
f
*
forecast
)
recordBatch
(
batch
f
orecastBatch
,
ignoredCount
int
)
{
f
.
metrics
.
RecordGameAgreement
(
metrics
.
AgreeDefenderWins
,
batch
.
AgreeDefenderWins
)
f
.
metrics
.
RecordGameAgreement
(
metrics
.
DisagreeDefenderWins
,
batch
.
DisagreeDefenderWins
)
f
.
metrics
.
RecordGameAgreement
(
metrics
.
AgreeChallengerWins
,
batch
.
AgreeChallengerWins
)
...
...
@@ -62,10 +77,12 @@ func (f *forecast) recordBatch(batch monTypes.ForecastBatch, ignoredCount int) {
f
.
metrics
.
RecordGameAgreement
(
metrics
.
AgreeDefenderAhead
,
batch
.
AgreeDefenderAhead
)
f
.
metrics
.
RecordGameAgreement
(
metrics
.
DisagreeDefenderAhead
,
batch
.
DisagreeDefenderAhead
)
f
.
metrics
.
RecordLatestInvalidProposal
(
batch
.
LatestInvalidProposal
)
f
.
metrics
.
RecordIgnoredGames
(
ignoredCount
)
}
func
(
f
*
forecast
)
forecastGame
(
ctx
context
.
Context
,
game
*
monTypes
.
EnrichedGameData
,
metrics
*
monTypes
.
F
orecastBatch
)
error
{
func
(
f
*
forecast
)
forecastGame
(
ctx
context
.
Context
,
game
*
monTypes
.
EnrichedGameData
,
metrics
*
f
orecastBatch
)
error
{
// Check the root agreement.
agreement
,
expected
,
err
:=
f
.
validator
.
CheckRootAgreement
(
ctx
,
game
.
L1HeadNum
,
game
.
L2BlockNumber
,
game
.
RootClaim
)
if
err
!=
nil
{
...
...
@@ -75,6 +92,9 @@ func (f *forecast) forecastGame(ctx context.Context, game *monTypes.EnrichedGame
expectedResult
:=
types
.
GameStatusDefenderWon
if
!
agreement
{
expectedResult
=
types
.
GameStatusChallengerWon
if
metrics
.
LatestInvalidProposal
<
game
.
Timestamp
{
metrics
.
LatestInvalidProposal
=
game
.
Timestamp
}
}
if
game
.
Status
!=
types
.
GameStatusInProgress
{
...
...
op-dispute-mon/mon/forecast_test.go
View file @
a5e34735
...
...
@@ -236,8 +236,8 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) {
{},
mockRootClaim
,
{},
{},
{}
,
{},
// Expected latest invalid proposal (will have timestamp 7)
mockRootClaim
,
}
games
:=
make
([]
*
monTypes
.
EnrichedGameData
,
9
)
for
i
:=
range
games
{
...
...
@@ -245,6 +245,9 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) {
Status
:
gameStatus
[
i
],
Claims
:
claims
[
i
],
RootClaim
:
rootClaims
[
i
],
GameMetadata
:
types
.
GameMetadata
{
Timestamp
:
uint64
(
i
),
},
}
}
forecast
.
Forecast
(
context
.
Background
(),
games
,
3
)
...
...
@@ -255,10 +258,12 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) {
expectedMetrics
[
metrics
.
DisagreeChallengerAhead
]
=
1
expectedMetrics
[
metrics
.
AgreeDefenderAhead
]
=
1
expectedMetrics
[
metrics
.
DisagreeDefenderAhead
]
=
1
expectedMetrics
[
metrics
.
AgreeChallengerWins
]
=
1
expectedMetrics
[
metrics
.
DisagreeDefenderWins
]
=
2
expectedMetrics
[
metrics
.
DisagreeChallengerWins
]
=
3
expectedMetrics
[
metrics
.
DisagreeChallengerWins
]
=
2
require
.
Equal
(
t
,
expectedMetrics
,
m
.
gameAgreement
)
require
.
Equal
(
t
,
3
,
m
.
ignoredGames
)
require
.
EqualValues
(
t
,
7
,
m
.
latestInvalidProposal
)
}
func
setupForecastTest
(
t
*
testing
.
T
)
(
*
forecast
,
*
mockForecastMetrics
,
*
stubOutputValidator
,
*
testlog
.
CapturingHandler
)
{
...
...
@@ -284,14 +289,19 @@ func zeroGameAgreement() map[metrics.GameAgreementStatus]int {
}
type
mockForecastMetrics
struct
{
gameAgreement
map
[
metrics
.
GameAgreementStatus
]
int
ignoredGames
int
gameAgreement
map
[
metrics
.
GameAgreementStatus
]
int
ignoredGames
int
latestInvalidProposal
uint64
}
func
(
m
*
mockForecastMetrics
)
RecordGameAgreement
(
status
metrics
.
GameAgreementStatus
,
count
int
)
{
m
.
gameAgreement
[
status
]
=
count
}
func
(
m
*
mockForecastMetrics
)
RecordLatestInvalidProposal
(
timestamp
uint64
)
{
m
.
latestInvalidProposal
=
timestamp
}
func
(
m
*
mockForecastMetrics
)
RecordIgnoredGames
(
count
int
)
{
m
.
ignoredGames
=
count
}
...
...
op-dispute-mon/mon/types/types.go
View file @
a5e34735
...
...
@@ -54,15 +54,3 @@ type BidirectionalClaim struct {
Claim
*
faultTypes
.
Claim
Children
[]
*
BidirectionalClaim
}
type
ForecastBatch
struct
{
AgreeDefenderAhead
int
DisagreeDefenderAhead
int
AgreeChallengerAhead
int
DisagreeChallengerAhead
int
AgreeDefenderWins
int
DisagreeDefenderWins
int
AgreeChallengerWins
int
DisagreeChallengerWins
int
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment