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
4349d08f
Unverified
Commit
4349d08f
authored
Aug 22, 2023
by
OptimismBot
Committed by
GitHub
Aug 22, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6965 from ethereum-optimism/aj/delete-trace-files
op-challenger: Delete game files when complete
parents
ffcff575
e18a86cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
4 deletions
+41
-4
monitor.go
op-challenger/fault/monitor.go
+10
-1
monitor_test.go
op-challenger/fault/monitor_test.go
+31
-3
No files found.
op-challenger/fault/monitor.go
View file @
4349d08f
...
...
@@ -13,6 +13,7 @@ import (
type
gamePlayer
interface
{
ProgressGame
(
ctx
context
.
Context
)
bool
Cleanup
()
error
}
type
playerCreator
func
(
address
common
.
Address
)
(
gamePlayer
,
error
)
...
...
@@ -92,7 +93,15 @@ func (m *gameMonitor) progressGames(ctx context.Context) error {
m
.
logger
.
Error
(
"Error while progressing game"
,
"game"
,
game
.
Proxy
,
"err"
,
err
)
continue
}
player
.
ProgressGame
(
ctx
)
done
:=
player
.
ProgressGame
(
ctx
)
if
done
{
// Remove resources on disk as soon as the game is complete to save disk space.
// We keep the player in memory to avoid recreating it on every update but will no longer
// need the resources on disk because there are no further actions required on the game.
if
err
:=
player
.
Cleanup
();
err
!=
nil
{
m
.
logger
.
Error
(
"Unable to cleanup player data"
,
"err"
,
err
)
}
}
}
// Remove the player for any game that's no longer being returned from the list of active games
for
addr
:=
range
m
.
players
{
...
...
op-challenger/fault/monitor_test.go
View file @
4349d08f
...
...
@@ -146,6 +146,27 @@ func TestDeletePlayersWhenNoLongerInListOfGames(t *testing.T) {
require
.
Equal
(
t
,
1
,
games
.
created
[
addr1
]
.
progressCount
)
}
func
TestCleanupResourcesOfCompletedGames
(
t
*
testing
.
T
)
{
monitor
,
source
,
games
:=
setupMonitorTest
(
t
,
[]
common
.
Address
{})
games
.
createCompleted
=
true
addr1
:=
common
.
Address
{
0xaa
}
source
.
games
=
[]
FaultDisputeGame
{
{
Proxy
:
addr1
,
Timestamp
:
9999
,
},
}
err
:=
monitor
.
progressGames
(
context
.
Background
())
require
.
NoError
(
t
,
err
)
require
.
Len
(
t
,
games
.
created
,
1
,
"should create game agents"
)
require
.
Contains
(
t
,
games
.
created
,
addr1
)
require
.
Equal
(
t
,
1
,
games
.
created
[
addr1
]
.
progressCount
)
require
.
Equal
(
t
,
1
,
games
.
created
[
addr1
]
.
cleanupCount
,
"should clean up once game is done"
)
}
func
setupMonitorTest
(
t
*
testing
.
T
,
allowedGames
[]
common
.
Address
)
(
*
gameMonitor
,
*
stubGameSource
,
*
createdGames
)
{
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlDebug
)
source
:=
&
stubGameSource
{}
...
...
@@ -171,6 +192,7 @@ func (s *stubGameSource) FetchAllGamesAtBlock(ctx context.Context, earliest uint
type
stubGame
struct
{
addr
common
.
Address
progressCount
int
cleanupCount
int
done
bool
}
...
...
@@ -179,16 +201,22 @@ func (g *stubGame) ProgressGame(ctx context.Context) bool {
return
g
.
done
}
func
(
g
*
stubGame
)
Cleanup
()
error
{
g
.
cleanupCount
++
return
nil
}
type
createdGames
struct
{
t
*
testing
.
T
created
map
[
common
.
Address
]
*
stubGame
t
*
testing
.
T
createCompleted
bool
created
map
[
common
.
Address
]
*
stubGame
}
func
(
c
*
createdGames
)
CreateGame
(
addr
common
.
Address
)
(
gamePlayer
,
error
)
{
if
_
,
exists
:=
c
.
created
[
addr
];
exists
{
c
.
t
.
Fatalf
(
"game %v already exists"
,
addr
)
}
game
:=
&
stubGame
{
addr
:
addr
}
game
:=
&
stubGame
{
addr
:
addr
,
done
:
c
.
createCompleted
}
c
.
created
[
addr
]
=
game
return
game
,
nil
}
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