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
534cfa36
Unverified
Commit
534cfa36
authored
Aug 23, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Make datadir required for all trace types
parent
4349d08f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
56 additions
and
43 deletions
+56
-43
main_test.go
op-challenger/cmd/main_test.go
+11
-11
config.go
op-challenger/config/config.go
+10
-6
config_test.go
op-challenger/config/config_test.go
+6
-7
executor_test.go
op-challenger/fault/cannon/executor_test.go
+1
-2
provider.go
op-challenger/fault/cannon/provider.go
+1
-1
provider_test.go
op-challenger/fault/cannon/provider_test.go
+1
-1
flags.go
op-challenger/flags/flags.go
+7
-10
charlie.sh
op-challenger/scripts/alphabet/charlie.sh
+8
-1
mallory.sh
op-challenger/scripts/alphabet/mallory.sh
+8
-1
helper.go
op-e2e/e2eutils/challenger/helper.go
+3
-3
No files found.
op-challenger/cmd/main_test.go
View file @
534cfa36
...
...
@@ -22,7 +22,7 @@ var (
cannonBin
=
"./bin/cannon"
cannonServer
=
"./bin/op-program"
cannonPreState
=
"./pre.json"
cannonDatadir
=
"./test_data"
datadir
=
"./test_data"
cannonL2
=
"http://example.com:9545"
alphabetTrace
=
"abcdefghijz"
agreeWithProposedOutput
=
"true"
...
...
@@ -45,14 +45,14 @@ func TestLogLevel(t *testing.T) {
func
TestDefaultCLIOptionsMatchDefaultConfig
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgs
(
config
.
TraceTypeAlphabet
))
defaultCfg
:=
config
.
NewConfig
(
common
.
HexToAddress
(
gameFactoryAddressValue
),
l1EthRpc
,
config
.
TraceTypeAlphabet
,
true
)
defaultCfg
:=
config
.
NewConfig
(
common
.
HexToAddress
(
gameFactoryAddressValue
),
l1EthRpc
,
config
.
TraceTypeAlphabet
,
true
,
datadir
)
// Add in the extra CLI options required when using alphabet trace type
defaultCfg
.
AlphabetTrace
=
alphabetTrace
require
.
Equal
(
t
,
defaultCfg
,
cfg
)
}
func
TestDefaultConfigIsValid
(
t
*
testing
.
T
)
{
cfg
:=
config
.
NewConfig
(
common
.
HexToAddress
(
gameFactoryAddressValue
),
l1EthRpc
,
config
.
TraceTypeAlphabet
,
true
)
cfg
:=
config
.
NewConfig
(
common
.
HexToAddress
(
gameFactoryAddressValue
),
l1EthRpc
,
config
.
TraceTypeAlphabet
,
true
,
datadir
)
// Add in options that are required based on the specific trace type
// To avoid needing to specify unused options, these aren't included in the params for NewConfig
cfg
.
AlphabetTrace
=
alphabetTrace
...
...
@@ -192,18 +192,18 @@ func TestCannonAbsolutePrestate(t *testing.T) {
})
}
func
Test
Cannon
DataDir
(
t
*
testing
.
T
)
{
t
.
Run
(
"
Not
RequiredForAlphabetTrace"
,
func
(
t
*
testing
.
T
)
{
configForArgs
(
t
,
addRequiredArgsExcept
(
config
.
TraceTypeAlphabet
,
"--cannon
-datadir"
))
func
TestDataDir
(
t
*
testing
.
T
)
{
t
.
Run
(
"RequiredForAlphabetTrace"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
"flag datadir is required"
,
addRequiredArgsExcept
(
config
.
TraceTypeAlphabet
,
"-
-datadir"
))
})
t
.
Run
(
"Required"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
"flag
cannon-datadir is required"
,
addRequiredArgsExcept
(
config
.
TraceTypeCannon
,
"--cannon
-datadir"
))
t
.
Run
(
"Required
ForCannonTrace
"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
"flag
datadir is required"
,
addRequiredArgsExcept
(
config
.
TraceTypeCannon
,
"-
-datadir"
))
})
t
.
Run
(
"Valid"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgsExcept
(
config
.
TraceTypeCannon
,
"--
cannon-datadir"
,
"--cannon
-datadir=/foo/bar/cannon"
))
require
.
Equal
(
t
,
"/foo/bar/cannon"
,
cfg
.
Cannon
Datadir
)
cfg
:=
configForArgs
(
t
,
addRequiredArgsExcept
(
config
.
TraceTypeCannon
,
"--
datadir"
,
"-
-datadir=/foo/bar/cannon"
))
require
.
Equal
(
t
,
"/foo/bar/cannon"
,
cfg
.
Datadir
)
})
}
...
...
@@ -353,6 +353,7 @@ func requiredArgs(traceType config.TraceType) map[string]string {
"--l1-eth-rpc"
:
l1EthRpc
,
"--game-factory-address"
:
gameFactoryAddressValue
,
"--trace-type"
:
traceType
.
String
(),
"--datadir"
:
datadir
,
}
switch
traceType
{
case
config
.
TraceTypeAlphabet
:
...
...
@@ -362,7 +363,6 @@ func requiredArgs(traceType config.TraceType) map[string]string {
args
[
"--cannon-bin"
]
=
cannonBin
args
[
"--cannon-server"
]
=
cannonServer
args
[
"--cannon-prestate"
]
=
cannonPreState
args
[
"--cannon-datadir"
]
=
cannonDatadir
args
[
"--cannon-l2"
]
=
cannonL2
}
return
args
...
...
op-challenger/config/config.go
View file @
534cfa36
...
...
@@ -15,7 +15,7 @@ import (
var
(
ErrMissingTraceType
=
errors
.
New
(
"missing trace type"
)
ErrMissing
CannonDatadir
=
errors
.
New
(
"missing cannon
datadir"
)
ErrMissing
Datadir
=
errors
.
New
(
"missing
datadir"
)
ErrMissingCannonL2
=
errors
.
New
(
"missing cannon L2"
)
ErrMissingCannonBin
=
errors
.
New
(
"missing cannon bin"
)
ErrMissingCannonServer
=
errors
.
New
(
"missing cannon server"
)
...
...
@@ -92,7 +92,9 @@ type Config struct {
GameAllowlist
[]
common
.
Address
// Allowlist of fault game addresses
GameWindow
time
.
Duration
// Maximum time duration to look for games to progress
AgreeWithProposedOutput
bool
// Temporary config if we agree or disagree with the posted output
TraceType
TraceType
// Type of trace
Datadir
string
// Data Directory
TraceType
TraceType
// Type of trace
// Specific to the alphabet trace provider
AlphabetTrace
string
// String for the AlphabetTraceProvider
...
...
@@ -104,7 +106,6 @@ type Config struct {
CannonNetwork
string
CannonRollupConfigPath
string
CannonL2GenesisPath
string
CannonDatadir
string
// Cannon Data Directory
CannonL2
string
// L2 RPC Url
CannonSnapshotFreq
uint
// Frequency of snapshots to create when executing cannon (in VM instructions)
...
...
@@ -118,6 +119,7 @@ func NewConfig(
l1EthRpc
string
,
traceType
TraceType
,
agreeWithProposedOutput
bool
,
datadir
string
,
)
Config
{
return
Config
{
L1EthRpc
:
l1EthRpc
,
...
...
@@ -131,6 +133,8 @@ func NewConfig(
MetricsConfig
:
opmetrics
.
DefaultCLIConfig
(),
PprofConfig
:
oppprof
.
DefaultCLIConfig
(),
Datadir
:
datadir
,
CannonSnapshotFreq
:
DefaultCannonSnapshotFreq
,
GameWindow
:
DefaultGameWindow
,
}
...
...
@@ -146,6 +150,9 @@ func (c Config) Check() error {
if
c
.
TraceType
==
""
{
return
ErrMissingTraceType
}
if
c
.
Datadir
==
""
{
return
ErrMissingDatadir
}
if
c
.
TraceType
==
TraceTypeCannon
{
if
c
.
CannonBin
==
""
{
return
ErrMissingCannonBin
...
...
@@ -174,9 +181,6 @@ func (c Config) Check() error {
if
c
.
CannonAbsolutePreState
==
""
{
return
ErrMissingCannonAbsolutePreState
}
if
c
.
CannonDatadir
==
""
{
return
ErrMissingCannonDatadir
}
if
c
.
CannonL2
==
""
{
return
ErrMissingCannonL2
}
...
...
op-challenger/config/config_test.go
View file @
534cfa36
...
...
@@ -17,13 +17,13 @@ var (
validCannonOpProgramBin
=
"./bin/op-program"
validCannonNetwork
=
"mainnet"
validCannonAbsolutPreState
=
"pre.json"
valid
CannonDatadir
=
"/tmp/cannon
"
valid
Datadir
=
"/tmp/data
"
validCannonL2
=
"http://localhost:9545"
agreeWithProposedOutput
=
true
)
func
validConfig
(
traceType
TraceType
)
Config
{
cfg
:=
NewConfig
(
validGameFactoryAddress
,
validL1EthRpc
,
traceType
,
agreeWithProposedOutput
)
cfg
:=
NewConfig
(
validGameFactoryAddress
,
validL1EthRpc
,
traceType
,
agreeWithProposedOutput
,
validDatadir
)
switch
traceType
{
case
TraceTypeAlphabet
:
cfg
.
AlphabetTrace
=
validAlphabetTrace
...
...
@@ -31,7 +31,6 @@ func validConfig(traceType TraceType) Config {
cfg
.
CannonBin
=
validCannonBin
cfg
.
CannonServer
=
validCannonOpProgramBin
cfg
.
CannonAbsolutePreState
=
validCannonAbsolutPreState
cfg
.
CannonDatadir
=
validCannonDatadir
cfg
.
CannonL2
=
validCannonL2
cfg
.
CannonNetwork
=
validCannonNetwork
}
...
...
@@ -99,10 +98,10 @@ func TestCannonAbsolutePreStateRequired(t *testing.T) {
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingCannonAbsolutePreState
)
}
func
Test
Cannon
DatadirRequired
(
t
*
testing
.
T
)
{
config
:=
validConfig
(
TraceType
Cannon
)
config
.
Cannon
Datadir
=
""
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissing
Cannon
Datadir
)
func
TestDatadirRequired
(
t
*
testing
.
T
)
{
config
:=
validConfig
(
TraceType
Alphabet
)
config
.
Datadir
=
""
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingDatadir
)
}
func
TestCannonL2Required
(
t
*
testing
.
T
)
{
...
...
op-challenger/fault/cannon/executor_test.go
View file @
534cfa36
...
...
@@ -21,10 +21,9 @@ const execTestCannonPrestate = "/foo/pre.json"
func
TestGenerateProof
(
t
*
testing
.
T
)
{
input
:=
"starting.json"
cfg
:=
config
.
NewConfig
(
common
.
Address
{
0xbb
},
"http://localhost:8888"
,
config
.
TraceTypeCannon
,
true
)
tempDir
:=
t
.
TempDir
()
dir
:=
filepath
.
Join
(
tempDir
,
"gameDir"
)
cfg
.
CannonDatadir
=
tempDir
cfg
:=
config
.
NewConfig
(
common
.
Address
{
0xbb
},
"http://localhost:8888"
,
config
.
TraceTypeCannon
,
true
,
dir
)
cfg
.
CannonAbsolutePreState
=
"pre.json"
cfg
.
CannonBin
=
"./bin/cannon"
cfg
.
CannonServer
=
"./bin/op-program"
...
...
op-challenger/fault/cannon/provider.go
View file @
534cfa36
...
...
@@ -68,7 +68,7 @@ func NewTraceProvider(ctx context.Context, logger log.Logger, cfg *config.Config
}
func
NewTraceProviderFromInputs
(
logger
log
.
Logger
,
cfg
*
config
.
Config
,
gameDirName
string
,
localInputs
LocalGameInputs
)
*
CannonTraceProvider
{
dir
:=
filepath
.
Join
(
cfg
.
Cannon
Datadir
,
gameDirName
)
dir
:=
filepath
.
Join
(
cfg
.
Datadir
,
gameDirName
)
return
&
CannonTraceProvider
{
logger
:
logger
,
dir
:
dir
,
...
...
op-challenger/fault/cannon/provider_test.go
View file @
534cfa36
...
...
@@ -196,7 +196,7 @@ func TestUseGameSpecificSubdir(t *testing.T) {
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
cfg
:=
&
config
.
Config
{
CannonAbsolutePreState
:
filepath
.
Join
(
tempDir
,
"state.json"
),
CannonDatadir
:
dataDir
,
Datadir
:
dataDir
,
}
gameDirName
:=
"gameSubdir"
localInputs
:=
LocalGameInputs
{}
...
...
op-challenger/flags/flags.go
View file @
534cfa36
...
...
@@ -57,6 +57,11 @@ var (
Usage
:
"Temporary hardcoded flag if we agree or disagree with the proposed output."
,
EnvVars
:
prefixEnvVars
(
"AGREE_WITH_PROPOSED_OUTPUT"
),
}
DatadirFlag
=
&
cli
.
StringFlag
{
Name
:
"datadir"
,
Usage
:
"Directory to store data generated as part of responding to games"
,
EnvVars
:
prefixEnvVars
(
"DATADIR"
),
}
// Optional Flags
AlphabetFlag
=
&
cli
.
StringFlag
{
Name
:
"alphabet"
,
...
...
@@ -93,11 +98,6 @@ var (
Usage
:
"Path to absolute prestate to use when generating trace data (cannon trace type only)"
,
EnvVars
:
prefixEnvVars
(
"CANNON_PRESTATE"
),
}
CannonDatadirFlag
=
&
cli
.
StringFlag
{
Name
:
"cannon-datadir"
,
Usage
:
"Directory to store data generated by cannon (cannon trace type only)"
,
EnvVars
:
prefixEnvVars
(
"CANNON_DATADIR"
),
}
CannonL2Flag
=
&
cli
.
StringFlag
{
Name
:
"cannon-l2"
,
Usage
:
"L2 Address of L2 JSON-RPC endpoint to use (eth and debug namespace required) (cannon trace type only)"
,
...
...
@@ -123,6 +123,7 @@ var requiredFlags = []cli.Flag{
FactoryAddressFlag
,
TraceTypeFlag
,
AgreeWithProposedOutputFlag
,
DatadirFlag
,
}
// optionalFlags is a list of unchecked cli flags
...
...
@@ -135,7 +136,6 @@ var optionalFlags = []cli.Flag{
CannonBinFlag
,
CannonServerFlag
,
CannonPreStateFlag
,
CannonDatadirFlag
,
CannonL2Flag
,
CannonSnapshotFreqFlag
,
GameWindowFlag
,
...
...
@@ -181,9 +181,6 @@ func CheckRequired(ctx *cli.Context) error {
if
!
ctx
.
IsSet
(
CannonPreStateFlag
.
Name
)
{
return
fmt
.
Errorf
(
"flag %s is required"
,
CannonPreStateFlag
.
Name
)
}
if
!
ctx
.
IsSet
(
CannonDatadirFlag
.
Name
)
{
return
fmt
.
Errorf
(
"flag %s is required"
,
CannonDatadirFlag
.
Name
)
}
if
!
ctx
.
IsSet
(
CannonL2Flag
.
Name
)
{
return
fmt
.
Errorf
(
"flag %s is required"
,
CannonL2Flag
.
Name
)
}
...
...
@@ -237,7 +234,7 @@ func NewConfigFromCLI(ctx *cli.Context) (*config.Config, error) {
CannonBin
:
ctx
.
String
(
CannonBinFlag
.
Name
),
CannonServer
:
ctx
.
String
(
CannonServerFlag
.
Name
),
CannonAbsolutePreState
:
ctx
.
String
(
CannonPreStateFlag
.
Name
),
CannonDatadir
:
ctx
.
String
(
Cannon
DatadirFlag
.
Name
),
Datadir
:
ctx
.
String
(
DatadirFlag
.
Name
),
CannonL2
:
ctx
.
String
(
CannonL2Flag
.
Name
),
CannonSnapshotFreq
:
ctx
.
Uint
(
CannonSnapshotFreqFlag
.
Name
),
AgreeWithProposedOutput
:
ctx
.
Bool
(
AgreeWithProposedOutputFlag
.
Name
),
...
...
op-challenger/scripts/alphabet/charlie.sh
View file @
534cfa36
...
...
@@ -19,12 +19,19 @@ DISPUTE_GAME_PROXY=$(jq -r .DisputeGameFactoryProxy $MONOREPO_DIR/.devnet/addres
FAULT_GAME_ADDRESS
=
$(
cat
$FAULT_GAME_ADDR_FILE
)
echo
"Fault dispute game address:
$FAULT_GAME_ADDRESS
"
DATADIR
=
`
mktemp
-d
`
trap
cleanup SIGINT
cleanup
(){
rm
-rf
"
${
DATADIR
}
"
}
$CHALLENGER_DIR
/bin/op-challenger
\
--l1-eth-rpc
http://localhost:8545
\
--trace-type
=
"alphabet"
\
--alphabet
"abcdefgh"
\
--datadir
"
${
DATADIR
}
"
\
--game-factory-address
$DISPUTE_GAME_PROXY
\
--game-a
ddress
$FAULT_GAME_ADDRESS
\
--game-a
llowlist
$FAULT_GAME_ADDRESS
\
--private-key
$CHARLIE_KEY
\
--num-confirmations
1
\
--metrics
.enabled
--metrics
.port
=
7304
\
...
...
op-challenger/scripts/alphabet/mallory.sh
View file @
534cfa36
...
...
@@ -19,12 +19,19 @@ DISPUTE_GAME_PROXY=$(jq -r .DisputeGameFactoryProxy $MONOREPO_DIR/.devnet/addres
FAULT_GAME_ADDRESS
=
$(
cat
$FAULT_GAME_ADDR_FILE
)
echo
"Fault dispute game address:
$FAULT_GAME_ADDRESS
"
DATADIR
=
`
mktemp
-d
`
trap
cleanup SIGINT
cleanup
(){
rm
-rf
"
${
DATADIR
}
"
}
$CHALLENGER_DIR
/bin/op-challenger
\
--l1-eth-rpc
http://localhost:8545
\
--trace-type
=
"alphabet"
\
--alphabet
"abcdexyz"
\
--datadir
"
${
DATADIR
}
"
\
--game-factory-address
$DISPUTE_GAME_PROXY
\
--game-a
ddress
$FAULT_GAME_ADDRESS
\
--game-a
llowlist
$FAULT_GAME_ADDRESS
\
--private-key
$MALLORY_KEY
\
--num-confirmations
1
\
--metrics
.enabled
--metrics
.port
=
7305
\
...
...
op-e2e/e2eutils/challenger/helper.go
View file @
534cfa36
...
...
@@ -74,7 +74,6 @@ func WithCannon(
require
:=
require
.
New
(
t
)
c
.
TraceType
=
config
.
TraceTypeCannon
c
.
CannonL2
=
l2Endpoint
c
.
CannonDatadir
=
t
.
TempDir
()
c
.
CannonBin
=
"../cannon/bin/cannon"
c
.
CannonServer
=
"../op-program/bin/op-program"
c
.
CannonAbsolutePreState
=
"../op-program/bin/prestate.json"
...
...
@@ -82,13 +81,13 @@ func WithCannon(
genesisBytes
,
err
:=
json
.
Marshal
(
l2Genesis
)
require
.
NoError
(
err
,
"marshall l2 genesis config"
)
genesisFile
:=
filepath
.
Join
(
c
.
Cannon
Datadir
,
"l2-genesis.json"
)
genesisFile
:=
filepath
.
Join
(
c
.
Datadir
,
"l2-genesis.json"
)
require
.
NoError
(
os
.
WriteFile
(
genesisFile
,
genesisBytes
,
0644
))
c
.
CannonL2GenesisPath
=
genesisFile
rollupBytes
,
err
:=
json
.
Marshal
(
rollupCfg
)
require
.
NoError
(
err
,
"marshall rollup config"
)
rollupFile
:=
filepath
.
Join
(
c
.
Cannon
Datadir
,
"rollup.json"
)
rollupFile
:=
filepath
.
Join
(
c
.
Datadir
,
"rollup.json"
)
require
.
NoError
(
os
.
WriteFile
(
rollupFile
,
rollupBytes
,
0644
))
c
.
CannonRollupConfigPath
=
rollupFile
}
...
...
@@ -121,6 +120,7 @@ func NewChallengerConfig(t *testing.T, l1Endpoint string, options ...Option) *co
AlphabetTrace
:
""
,
AgreeWithProposedOutput
:
true
,
TxMgrConfig
:
txmgrCfg
,
Datadir
:
t
.
TempDir
(),
}
for
_
,
option
:=
range
options
{
option
(
cfg
)
...
...
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