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
853842d1
Unverified
Commit
853842d1
authored
May 07, 2024
by
refcell
Committed by
GitHub
May 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(op-dispute-mon): export forecast to keep exporting consistent (#10430)
parent
89a3a5f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
13 deletions
+13
-13
forecast.go
op-dispute-mon/mon/forecast.go
+6
-6
forecast_test.go
op-dispute-mon/mon/forecast_test.go
+2
-2
monitor.go
op-dispute-mon/mon/monitor.go
+3
-3
service.go
op-dispute-mon/mon/service.go
+2
-2
No files found.
op-dispute-mon/mon/forecast.go
View file @
853842d1
...
...
@@ -42,21 +42,21 @@ type forecastBatch struct {
LatestInvalidProposal
uint64
}
type
f
orecast
struct
{
type
F
orecast
struct
{
logger
log
.
Logger
metrics
ForecastMetrics
validator
OutputValidator
}
func
newForecast
(
logger
log
.
Logger
,
metrics
ForecastMetrics
,
validator
OutputValidator
)
*
f
orecast
{
return
&
f
orecast
{
func
NewForecast
(
logger
log
.
Logger
,
metrics
ForecastMetrics
,
validator
OutputValidator
)
*
F
orecast
{
return
&
F
orecast
{
logger
:
logger
,
metrics
:
metrics
,
validator
:
validator
,
}
}
func
(
f
*
f
orecast
)
Forecast
(
ctx
context
.
Context
,
games
[]
*
monTypes
.
EnrichedGameData
,
ignoredCount
int
)
{
func
(
f
*
F
orecast
)
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
*
f
orecast
)
recordBatch
(
batch
forecastBatch
,
ignoredCount
int
)
{
func
(
f
*
F
orecast
)
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
*
f
orecast
)
forecastGame
(
ctx
context
.
Context
,
game
*
monTypes
.
EnrichedGameData
,
metrics
*
forecastBatch
)
error
{
func
(
f
*
F
orecast
)
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
{
...
...
op-dispute-mon/mon/forecast_test.go
View file @
853842d1
...
...
@@ -266,13 +266,13 @@ func TestForecast_Forecast_MultipleGames(t *testing.T) {
require
.
EqualValues
(
t
,
7
,
m
.
latestInvalidProposal
)
}
func
setupForecastTest
(
t
*
testing
.
T
)
(
*
f
orecast
,
*
mockForecastMetrics
,
*
stubOutputValidator
,
*
testlog
.
CapturingHandler
)
{
func
setupForecastTest
(
t
*
testing
.
T
)
(
*
F
orecast
,
*
mockForecastMetrics
,
*
stubOutputValidator
,
*
testlog
.
CapturingHandler
)
{
logger
,
capturedLogs
:=
testlog
.
CaptureLogger
(
t
,
log
.
LvlDebug
)
validator
:=
&
stubOutputValidator
{}
m
:=
&
mockForecastMetrics
{
gameAgreement
:
zeroGameAgreement
(),
}
return
n
ewForecast
(
logger
,
m
,
validator
),
m
,
validator
,
capturedLogs
return
N
ewForecast
(
logger
,
m
,
validator
),
m
,
validator
,
capturedLogs
}
func
zeroGameAgreement
()
map
[
metrics
.
GameAgreementStatus
]
int
{
...
...
op-dispute-mon/mon/monitor.go
View file @
853842d1
...
...
@@ -13,7 +13,7 @@ import (
"github.com/ethereum/go-ethereum/log"
)
type
Forecast
func
(
ctx
context
.
Context
,
games
[]
*
types
.
EnrichedGameData
,
ignoredCount
int
)
type
Forecast
Resolution
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
Forecast
Resolution
bonds
Bonds
resolutions
Resolutions
claims
MonitorClaims
...
...
@@ -49,7 +49,7 @@ func newGameMonitor(
cl
clock
.
Clock
,
monitorInterval
time
.
Duration
,
gameWindow
time
.
Duration
,
forecast
Forecast
,
forecast
Forecast
Resolution
,
bonds
Bonds
,
resolutions
Resolutions
,
claims
MonitorClaims
,
...
...
op-dispute-mon/mon/service.go
View file @
853842d1
...
...
@@ -37,7 +37,7 @@ type Service struct {
cl
clock
.
Clock
extractor
*
extract
.
Extractor
forecast
*
f
orecast
forecast
*
F
orecast
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
=
n
ewForecast
(
s
.
logger
,
s
.
metrics
,
s
.
validator
)
s
.
forecast
=
N
ewForecast
(
s
.
logger
,
s
.
metrics
,
s
.
validator
)
}
func
(
s
*
Service
)
initBonds
()
{
...
...
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