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
d8526825
Unverified
Commit
d8526825
authored
Aug 29, 2023
by
OptimismBot
Committed by
GitHub
Aug 29, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7044 from ethereum-optimism/aj/challenger-resolved-game
op-challenger: Detect already resolved games at startup
parents
0f0d85ba
77b994fa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
player.go
op-challenger/game/fault/player.go
+24
-6
player_test.go
op-challenger/game/fault/player_test.go
+1
-1
No files found.
op-challenger/game/fault/player.go
View file @
d8526825
...
...
@@ -18,9 +18,7 @@ import (
"github.com/ethereum/go-ethereum/log"
)
type
Actor
interface
{
Act
(
ctx
context
.
Context
)
error
}
type
actor
func
(
ctx
context
.
Context
)
error
type
GameInfo
interface
{
GetGameStatus
(
context
.
Context
)
(
types
.
GameStatus
,
error
)
...
...
@@ -28,7 +26,7 @@ type GameInfo interface {
}
type
GamePlayer
struct
{
a
gent
A
ctor
a
ct
a
ctor
agreeWithProposedOutput
bool
loader
GameInfo
logger
log
.
Logger
...
...
@@ -53,6 +51,25 @@ func NewGamePlayer(
loader
:=
NewLoader
(
contract
)
status
,
err
:=
loader
.
GetGameStatus
(
ctx
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to fetch game status: %w"
,
err
)
}
if
status
!=
types
.
GameStatusInProgress
{
logger
.
Info
(
"Game already resolved"
,
"status"
,
status
)
// Game is already complete so skip creating the trace provider, loading game inputs etc.
return
&
GamePlayer
{
logger
:
logger
,
loader
:
loader
,
agreeWithProposedOutput
:
cfg
.
AgreeWithProposedOutput
,
completed
:
true
,
// Act function does nothing because the game is already complete
act
:
func
(
ctx
context
.
Context
)
error
{
return
nil
},
},
nil
}
gameDepth
,
err
:=
loader
.
FetchGameDepth
(
ctx
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to fetch the game depth: %w"
,
err
)
...
...
@@ -88,10 +105,11 @@ func NewGamePlayer(
}
return
&
GamePlayer
{
a
gent
:
NewAgent
(
loader
,
int
(
gameDepth
),
provider
,
responder
,
updater
,
cfg
.
AgreeWithProposedOutput
,
logger
)
,
a
ct
:
NewAgent
(
loader
,
int
(
gameDepth
),
provider
,
responder
,
updater
,
cfg
.
AgreeWithProposedOutput
,
logger
)
.
Act
,
agreeWithProposedOutput
:
cfg
.
AgreeWithProposedOutput
,
loader
:
loader
,
logger
:
logger
,
completed
:
status
!=
types
.
GameStatusInProgress
,
},
nil
}
...
...
@@ -102,7 +120,7 @@ func (g *GamePlayer) ProgressGame(ctx context.Context) bool {
return
true
}
g
.
logger
.
Trace
(
"Checking if actions are required"
)
if
err
:=
g
.
a
gent
.
A
ct
(
ctx
);
err
!=
nil
{
if
err
:=
g
.
act
(
ctx
);
err
!=
nil
{
g
.
logger
.
Error
(
"Error when acting on game"
,
"err"
,
err
)
}
if
status
,
err
:=
g
.
loader
.
GetGameStatus
(
ctx
);
err
!=
nil
{
...
...
op-challenger/game/fault/player_test.go
View file @
d8526825
...
...
@@ -157,7 +157,7 @@ func setupProgressGameTest(t *testing.T, agreeWithProposedRoot bool) (*testlog.C
logger
.
SetHandler
(
handler
)
gameState
:=
&
stubGameState
{
claimCount
:
1
}
game
:=
&
GamePlayer
{
a
gent
:
gameState
,
a
ct
:
gameState
.
Act
,
agreeWithProposedOutput
:
agreeWithProposedRoot
,
loader
:
gameState
,
logger
:
logger
,
...
...
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