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
951e46e9
Unverified
Commit
951e46e9
authored
Mar 12, 2024
by
Adrian Sutton
Committed by
GitHub
Mar 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Allow claim bonds from games in the allow list (#9822)
parent
ce4c8ba6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
18 deletions
+19
-18
monitor.go
op-challenger/game/monitor.go
+3
-3
monitor_test.go
op-challenger/game/monitor_test.go
+16
-15
No files found.
op-challenger/game/monitor.go
View file @
951e46e9
...
...
@@ -124,9 +124,6 @@ func (m *gameMonitor) progressGames(ctx context.Context, blockHash common.Hash,
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to load games: %w"
,
err
)
}
if
err
:=
m
.
claimer
.
Schedule
(
blockNumber
,
games
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to schedule bond claims: %w"
,
err
)
}
var
gamesToPlay
[]
types
.
GameMetadata
for
_
,
game
:=
range
games
{
if
!
m
.
allowedGame
(
game
.
Proxy
)
{
...
...
@@ -135,6 +132,9 @@ func (m *gameMonitor) progressGames(ctx context.Context, blockHash common.Hash,
}
gamesToPlay
=
append
(
gamesToPlay
,
game
)
}
if
err
:=
m
.
claimer
.
Schedule
(
blockNumber
,
gamesToPlay
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to schedule bond claims: %w"
,
err
)
}
if
err
:=
m
.
scheduler
.
Schedule
(
gamesToPlay
,
blockNumber
);
errors
.
Is
(
err
,
scheduler
.
ErrBusy
)
{
m
.
logger
.
Info
(
"Scheduler still busy with previous update"
)
}
else
if
err
!=
nil
{
...
...
op-challenger/game/monitor_test.go
View file @
951e46e9
...
...
@@ -24,13 +24,13 @@ func TestMonitorMinGameTimestamp(t *testing.T) {
t
.
Parallel
()
t
.
Run
(
"zero game window returns zero"
,
func
(
t
*
testing
.
T
)
{
monitor
,
_
,
_
,
_
,
_
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
monitor
,
_
,
_
,
_
,
_
,
_
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
monitor
.
gameWindow
=
time
.
Duration
(
0
)
require
.
Equal
(
t
,
monitor
.
minGameTimestamp
(),
uint64
(
0
))
})
t
.
Run
(
"non-zero game window with zero clock"
,
func
(
t
*
testing
.
T
)
{
monitor
,
_
,
_
,
_
,
_
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
monitor
,
_
,
_
,
_
,
_
,
_
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
monitor
.
gameWindow
=
time
.
Minute
monitor
.
clock
=
clock
.
NewSimpleClock
()
monitor
.
clock
.
SetTime
(
0
)
...
...
@@ -38,7 +38,7 @@ func TestMonitorMinGameTimestamp(t *testing.T) {
})
t
.
Run
(
"minimum computed correctly"
,
func
(
t
*
testing
.
T
)
{
monitor
,
_
,
_
,
_
,
_
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
monitor
,
_
,
_
,
_
,
_
,
_
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
monitor
.
gameWindow
=
time
.
Minute
monitor
.
clock
=
clock
.
NewSimpleClock
()
frozen
:=
uint64
(
time
.
Hour
.
Seconds
())
...
...
@@ -54,7 +54,7 @@ func TestMonitorGames(t *testing.T) {
t
.
Run
(
"Schedules games"
,
func
(
t
*
testing
.
T
)
{
addr1
:=
common
.
Address
{
0xaa
}
addr2
:=
common
.
Address
{
0xbb
}
monitor
,
source
,
sched
,
mockHeadSource
,
preimages
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
monitor
,
source
,
sched
,
mockHeadSource
,
preimages
,
_
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
source
.
games
=
[]
types
.
GameMetadata
{
newFDG
(
addr1
,
9999
),
newFDG
(
addr2
,
9999
)}
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
...
...
@@ -99,7 +99,7 @@ func TestMonitorGames(t *testing.T) {
t
.
Run
(
"Resubscribes on error"
,
func
(
t
*
testing
.
T
)
{
addr1
:=
common
.
Address
{
0xaa
}
addr2
:=
common
.
Address
{
0xbb
}
monitor
,
source
,
sched
,
mockHeadSource
,
preimages
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
monitor
,
source
,
sched
,
mockHeadSource
,
preimages
,
_
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
source
.
games
=
[]
types
.
GameMetadata
{
newFDG
(
addr1
,
9999
),
newFDG
(
addr2
,
9999
)}
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
...
...
@@ -146,7 +146,7 @@ func TestMonitorGames(t *testing.T) {
}
func
TestMonitorCreateAndProgressGameAgents
(
t
*
testing
.
T
)
{
monitor
,
source
,
sched
,
_
,
_
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
monitor
,
source
,
sched
,
_
,
_
,
_
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
addr1
:=
common
.
Address
{
0xaa
}
addr2
:=
common
.
Address
{
0xbb
}
...
...
@@ -161,13 +161,14 @@ func TestMonitorCreateAndProgressGameAgents(t *testing.T) {
func
TestMonitorOnlyScheduleSpecifiedGame
(
t
*
testing
.
T
)
{
addr1
:=
common
.
Address
{
0xaa
}
addr2
:=
common
.
Address
{
0xbb
}
monitor
,
source
,
sched
,
_
,
_
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{
addr2
})
monitor
,
source
,
sched
,
_
,
_
,
stubClaimer
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{
addr2
})
source
.
games
=
[]
types
.
GameMetadata
{
newFDG
(
addr1
,
9999
),
newFDG
(
addr2
,
9999
)}
require
.
NoError
(
t
,
monitor
.
progressGames
(
context
.
Background
(),
common
.
Hash
{
0x01
},
0
))
require
.
Len
(
t
,
sched
.
Scheduled
(),
1
)
require
.
Equal
(
t
,
[]
common
.
Address
{
addr2
},
sched
.
Scheduled
()[
0
])
require
.
Equal
(
t
,
1
,
stubClaimer
.
scheduledGames
)
}
func
newFDG
(
proxy
common
.
Address
,
timestamp
uint64
)
types
.
GameMetadata
{
...
...
@@ -180,7 +181,7 @@ func newFDG(proxy common.Address, timestamp uint64) types.GameMetadata {
func
setupMonitorTest
(
t
*
testing
.
T
,
allowedGames
[]
common
.
Address
,
)
(
*
gameMonitor
,
*
stubGameSource
,
*
stubScheduler
,
*
mockNewHeadSource
,
*
stubPreimageScheduler
)
{
)
(
*
gameMonitor
,
*
stubGameSource
,
*
stubScheduler
,
*
mockNewHeadSource
,
*
stubPreimageScheduler
,
*
mockScheduler
)
{
logger
:=
testlog
.
Logger
(
t
,
log
.
LevelDebug
)
source
:=
&
stubGameSource
{}
i
:=
uint64
(
1
)
...
...
@@ -191,7 +192,7 @@ func setupMonitorTest(
sched
:=
&
stubScheduler
{}
preimages
:=
&
stubPreimageScheduler
{}
mockHeadSource
:=
&
mockNewHeadSource
{}
mockSchedul
er
:=
&
mockScheduler
{}
stubClaim
er
:=
&
mockScheduler
{}
monitor
:=
newGameMonitor
(
logger
,
clock
.
NewSimpleClock
(),
...
...
@@ -199,12 +200,12 @@ func setupMonitorTest(
sched
,
preimages
,
time
.
Duration
(
0
),
mockSchedul
er
,
stubClaim
er
,
fetchBlockNum
,
allowedGames
,
mockHeadSource
,
)
return
monitor
,
source
,
sched
,
mockHeadSource
,
preimages
return
monitor
,
source
,
sched
,
mockHeadSource
,
preimages
,
stubClaimer
}
type
mockNewHeadSource
struct
{
...
...
@@ -247,12 +248,12 @@ func (m *mockNewHeadSource) EthSubscribe(
}
type
mockScheduler
struct
{
scheduleErr
error
schedule
Call
s
int
scheduleErr
error
schedule
dGame
s
int
}
func
(
m
*
mockScheduler
)
Schedule
(
uint64
,
[]
types
.
GameMetadata
)
error
{
m
.
schedule
Calls
++
func
(
m
*
mockScheduler
)
Schedule
(
_
uint64
,
games
[]
types
.
GameMetadata
)
error
{
m
.
schedule
dGames
+=
len
(
games
)
return
m
.
scheduleErr
}
...
...
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