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
1 year ago
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) {
...
@@ -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
)
{
func
verifyArgsInvalid
(
t
*
testing
.
T
,
messageContains
string
,
cliArgs
[]
string
)
{
_
,
_
,
err
:=
runWithArgs
(
cliArgs
)
_
,
_
,
err
:=
runWithArgs
(
cliArgs
)
require
.
ErrorContains
(
t
,
err
,
messageContains
)
require
.
ErrorContains
(
t
,
err
,
messageContains
)
...
...
This diff is collapsed.
Click to expand it.
op-challenger/config/config.go
View file @
d0ec7ab5
...
@@ -18,6 +18,7 @@ var (
...
@@ -18,6 +18,7 @@ var (
ErrMissingAlphabetTrace
=
errors
.
New
(
"missing alphabet trace"
)
ErrMissingAlphabetTrace
=
errors
.
New
(
"missing alphabet trace"
)
ErrMissingL1EthRPC
=
errors
.
New
(
"missing l1 eth rpc url"
)
ErrMissingL1EthRPC
=
errors
.
New
(
"missing l1 eth rpc url"
)
ErrMissingGameAddress
=
errors
.
New
(
"missing game address"
)
ErrMissingGameAddress
=
errors
.
New
(
"missing game address"
)
ErrMissingCannonSnapshotFreq
=
errors
.
New
(
"missing cannon snapshot freq"
)
)
)
type
TraceType
string
type
TraceType
string
...
@@ -51,6 +52,8 @@ func ValidTraceType(value TraceType) bool {
...
@@ -51,6 +52,8 @@ func ValidTraceType(value TraceType) bool {
return
false
return
false
}
}
const
DefaultCannonSnapshotFreq
=
uint
(
10
_000
)
// Config is a well typed config that is parsed from the CLI params.
// Config is a well typed config that is parsed from the CLI params.
// This also contains config options for auxiliary services.
// This also contains config options for auxiliary services.
// It is used to initialize the challenger.
// It is used to initialize the challenger.
...
@@ -71,6 +74,7 @@ type Config struct {
...
@@ -71,6 +74,7 @@ type Config struct {
CannonAbsolutePreState
string
// File to load the absolute pre-state for Cannon traces from
CannonAbsolutePreState
string
// File to load the absolute pre-state for Cannon traces from
CannonDatadir
string
// Cannon Data Directory
CannonDatadir
string
// Cannon Data Directory
CannonL2
string
// L2 RPC Url
CannonL2
string
// L2 RPC Url
CannonSnapshotFreq
uint
// Frequency of snapshots to create when executing cannon (in VM instructions)
TxMgrConfig
txmgr
.
CLIConfig
TxMgrConfig
txmgr
.
CLIConfig
}
}
...
@@ -92,6 +96,8 @@ func NewConfig(
...
@@ -92,6 +96,8 @@ func NewConfig(
TraceType
:
traceType
,
TraceType
:
traceType
,
TxMgrConfig
:
txmgr
.
NewCLIConfig
(
l1EthRpc
),
TxMgrConfig
:
txmgr
.
NewCLIConfig
(
l1EthRpc
),
CannonSnapshotFreq
:
DefaultCannonSnapshotFreq
,
}
}
}
}
...
@@ -121,6 +127,9 @@ func (c Config) Check() error {
...
@@ -121,6 +127,9 @@ func (c Config) Check() error {
if
c
.
CannonL2
==
""
{
if
c
.
CannonL2
==
""
{
return
ErrMissingCannonL2
return
ErrMissingCannonL2
}
}
if
c
.
CannonSnapshotFreq
==
0
{
return
ErrMissingCannonSnapshotFreq
}
}
}
if
c
.
TraceType
==
TraceTypeAlphabet
&&
c
.
AlphabetTrace
==
""
{
if
c
.
TraceType
==
TraceTypeAlphabet
&&
c
.
AlphabetTrace
==
""
{
return
ErrMissingAlphabetTrace
return
ErrMissingAlphabetTrace
...
...
This diff is collapsed.
Click to expand it.
op-challenger/config/config_test.go
View file @
d0ec7ab5
...
@@ -102,3 +102,11 @@ func TestCannonL2Required(t *testing.T) {
...
@@ -102,3 +102,11 @@ func TestCannonL2Required(t *testing.T) {
config
.
CannonL2
=
""
config
.
CannonL2
=
""
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingCannonL2
)
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
)
})
}
This diff is collapsed.
Click to expand it.
op-challenger/flags/flags.go
View file @
d0ec7ab5
...
@@ -83,6 +83,12 @@ var (
...
@@ -83,6 +83,12 @@ var (
Usage
:
"L2 Address of L2 JSON-RPC endpoint to use (eth and debug namespace required) (cannon trace type only)"
,
Usage
:
"L2 Address of L2 JSON-RPC endpoint to use (eth and debug namespace required) (cannon trace type only)"
,
EnvVars
:
prefixEnvVars
(
"CANNON_L2"
),
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]
// requiredFlags are checked by [CheckRequired]
...
@@ -102,6 +108,7 @@ var optionalFlags = []cli.Flag{
...
@@ -102,6 +108,7 @@ var optionalFlags = []cli.Flag{
CannonPreStateFlag
,
CannonPreStateFlag
,
CannonDatadirFlag
,
CannonDatadirFlag
,
CannonL2Flag
,
CannonL2Flag
,
CannonSnapshotFreqFlag
,
}
}
func
init
()
{
func
init
()
{
...
@@ -173,6 +180,7 @@ func NewConfigFromCLI(ctx *cli.Context) (*config.Config, error) {
...
@@ -173,6 +180,7 @@ func NewConfigFromCLI(ctx *cli.Context) (*config.Config, error) {
CannonAbsolutePreState
:
ctx
.
String
(
CannonPreStateFlag
.
Name
),
CannonAbsolutePreState
:
ctx
.
String
(
CannonPreStateFlag
.
Name
),
CannonDatadir
:
ctx
.
String
(
CannonDatadirFlag
.
Name
),
CannonDatadir
:
ctx
.
String
(
CannonDatadirFlag
.
Name
),
CannonL2
:
ctx
.
String
(
CannonL2Flag
.
Name
),
CannonL2
:
ctx
.
String
(
CannonL2Flag
.
Name
),
CannonSnapshotFreq
:
ctx
.
Uint
(
CannonSnapshotFreqFlag
.
Name
),
AgreeWithProposedOutput
:
ctx
.
Bool
(
AgreeWithProposedOutputFlag
.
Name
),
AgreeWithProposedOutput
:
ctx
.
Bool
(
AgreeWithProposedOutputFlag
.
Name
),
GameDepth
:
ctx
.
Int
(
GameDepthFlag
.
Name
),
GameDepth
:
ctx
.
Int
(
GameDepthFlag
.
Name
),
TxMgrConfig
:
txMgrConfig
,
TxMgrConfig
:
txMgrConfig
,
...
...
This diff is collapsed.
Click to expand it.
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