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
dc5cf529
Unverified
Commit
dc5cf529
authored
Sep 10, 2024
by
Adrian Sutton
Committed by
GitHub
Sep 10, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Release agent resources once game is complete (#11820)
parent
21161265
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
player.go
op-challenger/game/fault/player.go
+9
-3
player_test.go
op-challenger/game/fault/player_test.go
+5
-0
No files found.
op-challenger/game/fault/player.go
View file @
dc5cf529
...
...
@@ -64,6 +64,10 @@ type GameContract interface {
GetL1Head
(
ctx
context
.
Context
)
(
common
.
Hash
,
error
)
}
var
actNoop
=
func
(
ctx
context
.
Context
)
error
{
return
nil
}
type
resourceCreator
func
(
ctx
context
.
Context
,
logger
log
.
Logger
,
gameDepth
types
.
Depth
,
dir
string
)
(
types
.
TraceAccessor
,
error
)
func
NewGamePlayer
(
...
...
@@ -98,9 +102,7 @@ func NewGamePlayer(
prestateValidators
:
validators
,
status
:
status
,
// Act function does nothing because the game is already complete
act
:
func
(
ctx
context
.
Context
)
error
{
return
nil
},
act
:
actNoop
,
},
nil
}
...
...
@@ -195,6 +197,10 @@ func (g *GamePlayer) ProgressGame(ctx context.Context) gameTypes.GameStatus {
}
g
.
logGameStatus
(
ctx
,
status
)
g
.
status
=
status
if
status
!=
gameTypes
.
GameStatusInProgress
{
// Release the agent as we will no longer need to act on this game.
g
.
act
=
actNoop
}
return
status
}
...
...
op-challenger/game/fault/player_test.go
View file @
dc5cf529
...
...
@@ -90,6 +90,11 @@ func TestDoNotActOnCompleteGame(t *testing.T) {
fetched
=
game
.
ProgressGame
(
context
.
Background
())
require
.
Equal
(
t
,
1
,
gameState
.
callCount
,
"does not act after game is complete"
)
require
.
Equal
(
t
,
status
,
fetched
)
// Should have replaced the act function with a noop so callCount doesn't update even when called directly
// This allows the agent resources to be GC'd
require
.
NoError
(
t
,
game
.
act
(
context
.
Background
()))
require
.
Equal
(
t
,
1
,
gameState
.
callCount
)
})
}
}
...
...
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