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
3f7933d2
Unverified
Commit
3f7933d2
authored
Aug 18, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Only play game specified with --game-address when specified
parent
cbedb215
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
7 deletions
+38
-7
monitor.go
op-challenger/fault/monitor.go
+7
-1
monitor_test.go
op-challenger/fault/monitor_test.go
+29
-4
service.go
op-challenger/fault/service.go
+2
-2
No files found.
op-challenger/fault/monitor.go
View file @
3f7933d2
...
@@ -27,15 +27,17 @@ type gameMonitor struct {
...
@@ -27,15 +27,17 @@ type gameMonitor struct {
source
gameSource
source
gameSource
createGame
gameCreator
createGame
gameCreator
fetchBlockNumber
blockNumberFetcher
fetchBlockNumber
blockNumberFetcher
allowedGame
common
.
Address
games
map
[
common
.
Address
]
gameAgent
games
map
[
common
.
Address
]
gameAgent
}
}
func
newGameMonitor
(
logger
log
.
Logger
,
fetchBlockNumber
blockNumberFetcher
,
source
gameSource
,
createGame
gameCreator
)
*
gameMonitor
{
func
newGameMonitor
(
logger
log
.
Logger
,
fetchBlockNumber
blockNumberFetcher
,
allowedGame
common
.
Address
,
source
gameSource
,
createGame
gameCreator
)
*
gameMonitor
{
return
&
gameMonitor
{
return
&
gameMonitor
{
logger
:
logger
,
logger
:
logger
,
source
:
source
,
source
:
source
,
createGame
:
createGame
,
createGame
:
createGame
,
fetchBlockNumber
:
fetchBlockNumber
,
fetchBlockNumber
:
fetchBlockNumber
,
allowedGame
:
allowedGame
,
games
:
make
(
map
[
common
.
Address
]
gameAgent
),
games
:
make
(
map
[
common
.
Address
]
gameAgent
),
}
}
}
}
...
@@ -50,6 +52,10 @@ func (m *gameMonitor) progressGames(ctx context.Context) error {
...
@@ -50,6 +52,10 @@ func (m *gameMonitor) progressGames(ctx context.Context) error {
return
fmt
.
Errorf
(
"failed to load games: %w"
,
err
)
return
fmt
.
Errorf
(
"failed to load games: %w"
,
err
)
}
}
for
_
,
game
:=
range
games
{
for
_
,
game
:=
range
games
{
if
m
.
allowedGame
!=
(
common
.
Address
{})
&&
m
.
allowedGame
!=
game
.
Proxy
{
m
.
logger
.
Debug
(
"Skipping game not on allow list"
,
"game"
,
game
.
Proxy
)
continue
}
if
err
:=
m
.
progressGame
(
ctx
,
game
);
err
!=
nil
{
if
err
:=
m
.
progressGame
(
ctx
,
game
);
err
!=
nil
{
m
.
logger
.
Error
(
"Error while progressing game"
,
"game"
,
game
.
Proxy
,
"err"
,
err
)
m
.
logger
.
Error
(
"Error while progressing game"
,
"game"
,
game
.
Proxy
,
"err"
,
err
)
}
}
...
...
op-challenger/fault/monitor_test.go
View file @
3f7933d2
...
@@ -13,7 +13,7 @@ import (
...
@@ -13,7 +13,7 @@ import (
)
)
func
TestMonitorExitsWhenContextDone
(
t
*
testing
.
T
)
{
func
TestMonitorExitsWhenContextDone
(
t
*
testing
.
T
)
{
monitor
,
_
,
_
:=
setupMonitorTest
(
t
)
monitor
,
_
,
_
:=
setupMonitorTest
(
t
,
common
.
Address
{}
)
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
cancel
()
cancel
()
err
:=
monitor
.
MonitorGames
(
ctx
)
err
:=
monitor
.
MonitorGames
(
ctx
)
...
@@ -21,7 +21,7 @@ func TestMonitorExitsWhenContextDone(t *testing.T) {
...
@@ -21,7 +21,7 @@ func TestMonitorExitsWhenContextDone(t *testing.T) {
}
}
func
TestMonitorCreateAndProgressGameAgents
(
t
*
testing
.
T
)
{
func
TestMonitorCreateAndProgressGameAgents
(
t
*
testing
.
T
)
{
monitor
,
source
,
games
:=
setupMonitorTest
(
t
)
monitor
,
source
,
games
:=
setupMonitorTest
(
t
,
common
.
Address
{}
)
addr1
:=
common
.
Address
{
0xaa
}
addr1
:=
common
.
Address
{
0xaa
}
addr2
:=
common
.
Address
{
0xbb
}
addr2
:=
common
.
Address
{
0xbb
}
...
@@ -51,7 +51,32 @@ func TestMonitorCreateAndProgressGameAgents(t *testing.T) {
...
@@ -51,7 +51,32 @@ func TestMonitorCreateAndProgressGameAgents(t *testing.T) {
require
.
Equal
(
t
,
2
,
games
.
created
[
addr2
]
.
progressCount
)
require
.
Equal
(
t
,
2
,
games
.
created
[
addr2
]
.
progressCount
)
}
}
func
setupMonitorTest
(
t
*
testing
.
T
)
(
*
gameMonitor
,
*
stubGameSource
,
*
createdGames
)
{
func
TestMonitorOnlyCreateSpecifiedGame
(
t
*
testing
.
T
)
{
addr1
:=
common
.
Address
{
0xaa
}
addr2
:=
common
.
Address
{
0xbb
}
monitor
,
source
,
games
:=
setupMonitorTest
(
t
,
addr2
)
source
.
games
=
[]
FaultDisputeGame
{
{
Proxy
:
addr1
,
Timestamp
:
big
.
NewInt
(
9999
),
},
{
Proxy
:
addr2
,
Timestamp
:
big
.
NewInt
(
9999
),
},
}
err
:=
monitor
.
progressGames
(
context
.
Background
())
require
.
NoError
(
t
,
err
)
require
.
Len
(
t
,
games
.
created
,
1
,
"should only create allowed game"
)
require
.
Contains
(
t
,
games
.
created
,
addr2
)
require
.
NotContains
(
t
,
games
.
created
,
addr1
)
require
.
Equal
(
t
,
1
,
games
.
created
[
addr2
]
.
progressCount
)
}
func
setupMonitorTest
(
t
*
testing
.
T
,
allowedGame
common
.
Address
)
(
*
gameMonitor
,
*
stubGameSource
,
*
createdGames
)
{
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlDebug
)
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlDebug
)
source
:=
&
stubGameSource
{}
source
:=
&
stubGameSource
{}
games
:=
&
createdGames
{
games
:=
&
createdGames
{
...
@@ -61,7 +86,7 @@ func setupMonitorTest(t *testing.T) (*gameMonitor, *stubGameSource, *createdGame
...
@@ -61,7 +86,7 @@ func setupMonitorTest(t *testing.T) (*gameMonitor, *stubGameSource, *createdGame
fetchBlockNum
:=
func
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
fetchBlockNum
:=
func
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
return
1234
,
nil
return
1234
,
nil
}
}
monitor
:=
newGameMonitor
(
logger
,
fetchBlockNum
,
source
,
games
.
CreateGame
)
monitor
:=
newGameMonitor
(
logger
,
fetchBlockNum
,
allowedGame
,
source
,
games
.
CreateGame
)
return
monitor
,
source
,
games
return
monitor
,
source
,
games
}
}
...
...
op-challenger/fault/service.go
View file @
3f7933d2
...
@@ -46,7 +46,7 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*se
...
@@ -46,7 +46,7 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*se
}
}
loader
:=
NewGameLoader
(
factory
)
loader
:=
NewGameLoader
(
factory
)
monitor
:=
newGameMonitor
(
logger
,
client
.
BlockNumber
,
loader
,
func
(
addr
common
.
Address
)
(
gameAgent
,
error
)
{
monitor
:=
newGameMonitor
(
logger
,
client
.
BlockNumber
,
cfg
.
GameAddress
,
loader
,
func
(
addr
common
.
Address
)
(
gameAgent
,
error
)
{
return
NewGame
(
ctx
,
logger
,
cfg
,
addr
,
txMgr
,
client
)
return
NewGame
(
ctx
,
logger
,
cfg
,
addr
,
txMgr
,
client
)
})
})
return
&
service
{
return
&
service
{
...
@@ -74,5 +74,5 @@ func ValidateAbsolutePrestate(ctx context.Context, trace types.TraceProvider, lo
...
@@ -74,5 +74,5 @@ func ValidateAbsolutePrestate(ctx context.Context, trace types.TraceProvider, lo
// MonitorGame monitors the fault dispute game and attempts to progress it.
// MonitorGame monitors the fault dispute game and attempts to progress it.
func
(
s
*
service
)
MonitorGame
(
ctx
context
.
Context
)
error
{
func
(
s
*
service
)
MonitorGame
(
ctx
context
.
Context
)
error
{
return
s
.
monitor
.
MonitorGames
(
ctx
)
// TODO MonitorGame(ctx, s.logger, s.agreeWithProposedOutput, s.agent, s.caller)
return
s
.
monitor
.
MonitorGames
(
ctx
)
}
}
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