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
d0ec7ab5
Unverified
Commit
d0ec7ab5
authored
Jul 26, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Add cannon-snapshot-freq flag
parent
0a829efe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
0 deletions
+37
-0
main_test.go
op-challenger/cmd/main_test.go
+12
-0
config.go
op-challenger/config/config.go
+9
-0
config_test.go
op-challenger/config/config_test.go
+8
-0
flags.go
op-challenger/flags/flags.go
+8
-0
No files found.
op-challenger/cmd/main_test.go
View file @
d0ec7ab5
...
...
@@ -214,6 +214,18 @@ func TestCannonL2(t *testing.T) {
})
}
func
TestCannonSnapshotFreq
(
t
*
testing
.
T
)
{
t
.
Run
(
"UsesDefault"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgs
(
config
.
TraceTypeCannon
))
require
.
Equal
(
t
,
config
.
DefaultCannonSnapshotFreq
,
cfg
.
CannonSnapshotFreq
)
})
t
.
Run
(
"Valid"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgs
(
config
.
TraceTypeCannon
,
"--cannon-snapshot-freq=1234"
))
require
.
Equal
(
t
,
uint
(
1234
),
cfg
.
CannonSnapshotFreq
)
})
}
func
verifyArgsInvalid
(
t
*
testing
.
T
,
messageContains
string
,
cliArgs
[]
string
)
{
_
,
_
,
err
:=
runWithArgs
(
cliArgs
)
require
.
ErrorContains
(
t
,
err
,
messageContains
)
...
...
op-challenger/config/config.go
View file @
d0ec7ab5
...
...
@@ -18,6 +18,7 @@ var (
ErrMissingAlphabetTrace
=
errors
.
New
(
"missing alphabet trace"
)
ErrMissingL1EthRPC
=
errors
.
New
(
"missing l1 eth rpc url"
)
ErrMissingGameAddress
=
errors
.
New
(
"missing game address"
)
ErrMissingCannonSnapshotFreq
=
errors
.
New
(
"missing cannon snapshot freq"
)
)
type
TraceType
string
...
...
@@ -51,6 +52,8 @@ func ValidTraceType(value TraceType) bool {
return
false
}
const
DefaultCannonSnapshotFreq
=
uint
(
10
_000
)
// Config is a well typed config that is parsed from the CLI params.
// This also contains config options for auxiliary services.
// It is used to initialize the challenger.
...
...
@@ -71,6 +74,7 @@ type Config struct {
CannonAbsolutePreState
string
// File to load the absolute pre-state for Cannon traces from
CannonDatadir
string
// Cannon Data Directory
CannonL2
string
// L2 RPC Url
CannonSnapshotFreq
uint
// Frequency of snapshots to create when executing cannon (in VM instructions)
TxMgrConfig
txmgr
.
CLIConfig
}
...
...
@@ -92,6 +96,8 @@ func NewConfig(
TraceType
:
traceType
,
TxMgrConfig
:
txmgr
.
NewCLIConfig
(
l1EthRpc
),
CannonSnapshotFreq
:
DefaultCannonSnapshotFreq
,
}
}
...
...
@@ -121,6 +127,9 @@ func (c Config) Check() error {
if
c
.
CannonL2
==
""
{
return
ErrMissingCannonL2
}
if
c
.
CannonSnapshotFreq
==
0
{
return
ErrMissingCannonSnapshotFreq
}
}
if
c
.
TraceType
==
TraceTypeAlphabet
&&
c
.
AlphabetTrace
==
""
{
return
ErrMissingAlphabetTrace
...
...
op-challenger/config/config_test.go
View file @
d0ec7ab5
...
...
@@ -102,3 +102,11 @@ func TestCannonL2Required(t *testing.T) {
config
.
CannonL2
=
""
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingCannonL2
)
}
func
TestCannonSnapshotFreq
(
t
*
testing
.
T
)
{
t
.
Run
(
"MustNotBeZero"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
validConfig
(
TraceTypeCannon
)
cfg
.
CannonSnapshotFreq
=
0
require
.
ErrorIs
(
t
,
cfg
.
Check
(),
ErrMissingCannonSnapshotFreq
)
})
}
op-challenger/flags/flags.go
View file @
d0ec7ab5
...
...
@@ -83,6 +83,12 @@ var (
Usage
:
"L2 Address of L2 JSON-RPC endpoint to use (eth and debug namespace required) (cannon trace type only)"
,
EnvVars
:
prefixEnvVars
(
"CANNON_L2"
),
}
CannonSnapshotFreqFlag
=
&
cli
.
UintFlag
{
Name
:
"cannon-snapshot-freq"
,
Usage
:
"Frequency of cannon snapshots to generate in VM steps (cannon trace type only)"
,
EnvVars
:
prefixEnvVars
(
"CANNON_SNAPSHOT_FREQ"
),
Value
:
config
.
DefaultCannonSnapshotFreq
,
}
)
// requiredFlags are checked by [CheckRequired]
...
...
@@ -102,6 +108,7 @@ var optionalFlags = []cli.Flag{
CannonPreStateFlag
,
CannonDatadirFlag
,
CannonL2Flag
,
CannonSnapshotFreqFlag
,
}
func
init
()
{
...
...
@@ -173,6 +180,7 @@ func NewConfigFromCLI(ctx *cli.Context) (*config.Config, error) {
CannonAbsolutePreState
:
ctx
.
String
(
CannonPreStateFlag
.
Name
),
CannonDatadir
:
ctx
.
String
(
CannonDatadirFlag
.
Name
),
CannonL2
:
ctx
.
String
(
CannonL2Flag
.
Name
),
CannonSnapshotFreq
:
ctx
.
Uint
(
CannonSnapshotFreqFlag
.
Name
),
AgreeWithProposedOutput
:
ctx
.
Bool
(
AgreeWithProposedOutputFlag
.
Name
),
GameDepth
:
ctx
.
Int
(
GameDepthFlag
.
Name
),
TxMgrConfig
:
txMgrConfig
,
...
...
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