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
d2b14ac9
Unverified
Commit
d2b14ac9
authored
Aug 22, 2023
by
Adrian Sutton
Committed by
GitHub
Aug 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Use game specific data dir for cannon trace provider (#6918)
parent
1d5a9820
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
18 deletions
+33
-18
executor.go
op-challenger/fault/cannon/executor.go
+1
-3
executor_test.go
op-challenger/fault/cannon/executor_test.go
+11
-9
provider.go
op-challenger/fault/cannon/provider.go
+4
-3
provider_test.go
op-challenger/fault/cannon/provider_test.go
+16
-1
helper.go
op-e2e/e2eutils/disputegame/helper.go
+1
-1
faultproof_test.go
op-e2e/faultproof_test.go
+0
-1
No files found.
op-challenger/fault/cannon/executor.go
View file @
d2b14ac9
...
@@ -39,7 +39,6 @@ type Executor struct {
...
@@ -39,7 +39,6 @@ type Executor struct {
rollupConfig
string
rollupConfig
string
l2Genesis
string
l2Genesis
string
absolutePreState
string
absolutePreState
string
dataDir
string
snapshotFreq
uint
snapshotFreq
uint
selectSnapshot
snapshotSelect
selectSnapshot
snapshotSelect
cmdExecutor
cmdExecutor
cmdExecutor
cmdExecutor
...
@@ -57,7 +56,6 @@ func NewExecutor(logger log.Logger, cfg *config.Config, inputs LocalGameInputs)
...
@@ -57,7 +56,6 @@ func NewExecutor(logger log.Logger, cfg *config.Config, inputs LocalGameInputs)
rollupConfig
:
cfg
.
CannonRollupConfigPath
,
rollupConfig
:
cfg
.
CannonRollupConfigPath
,
l2Genesis
:
cfg
.
CannonL2GenesisPath
,
l2Genesis
:
cfg
.
CannonL2GenesisPath
,
absolutePreState
:
cfg
.
CannonAbsolutePreState
,
absolutePreState
:
cfg
.
CannonAbsolutePreState
,
dataDir
:
cfg
.
CannonDatadir
,
snapshotFreq
:
cfg
.
CannonSnapshotFreq
,
snapshotFreq
:
cfg
.
CannonSnapshotFreq
,
selectSnapshot
:
findStartingSnapshot
,
selectSnapshot
:
findStartingSnapshot
,
cmdExecutor
:
runCmd
,
cmdExecutor
:
runCmd
,
...
@@ -71,7 +69,7 @@ func (e *Executor) GenerateProof(ctx context.Context, dir string, i uint64) erro
...
@@ -71,7 +69,7 @@ func (e *Executor) GenerateProof(ctx context.Context, dir string, i uint64) erro
return
fmt
.
Errorf
(
"find starting snapshot: %w"
,
err
)
return
fmt
.
Errorf
(
"find starting snapshot: %w"
,
err
)
}
}
proofDir
:=
filepath
.
Join
(
dir
,
proofsDir
)
proofDir
:=
filepath
.
Join
(
dir
,
proofsDir
)
dataDir
:=
filepath
.
Join
(
e
.
dataD
ir
,
preimagesDir
)
dataDir
:=
filepath
.
Join
(
d
ir
,
preimagesDir
)
lastGeneratedState
:=
filepath
.
Join
(
dir
,
finalState
)
lastGeneratedState
:=
filepath
.
Join
(
dir
,
finalState
)
args
:=
[]
string
{
args
:=
[]
string
{
"run"
,
"run"
,
...
...
op-challenger/fault/cannon/executor_test.go
View file @
d2b14ac9
...
@@ -22,7 +22,9 @@ const execTestCannonPrestate = "/foo/pre.json"
...
@@ -22,7 +22,9 @@ const execTestCannonPrestate = "/foo/pre.json"
func
TestGenerateProof
(
t
*
testing
.
T
)
{
func
TestGenerateProof
(
t
*
testing
.
T
)
{
input
:=
"starting.json"
input
:=
"starting.json"
cfg
:=
config
.
NewConfig
(
common
.
Address
{
0xbb
},
"http://localhost:8888"
,
config
.
TraceTypeCannon
,
true
)
cfg
:=
config
.
NewConfig
(
common
.
Address
{
0xbb
},
"http://localhost:8888"
,
config
.
TraceTypeCannon
,
true
)
cfg
.
CannonDatadir
=
t
.
TempDir
()
tempDir
:=
t
.
TempDir
()
dir
:=
filepath
.
Join
(
tempDir
,
"gameDir"
)
cfg
.
CannonDatadir
=
tempDir
cfg
.
CannonAbsolutePreState
=
"pre.json"
cfg
.
CannonAbsolutePreState
=
"pre.json"
cfg
.
CannonBin
=
"./bin/cannon"
cfg
.
CannonBin
=
"./bin/cannon"
cfg
.
CannonServer
=
"./bin/op-program"
cfg
.
CannonServer
=
"./bin/op-program"
...
@@ -58,7 +60,7 @@ func TestGenerateProof(t *testing.T) {
...
@@ -58,7 +60,7 @@ func TestGenerateProof(t *testing.T) {
}
}
return
nil
return
nil
}
}
err
:=
executor
.
GenerateProof
(
context
.
Background
(),
cfg
.
CannonData
dir
,
proofAt
)
err
:=
executor
.
GenerateProof
(
context
.
Background
(),
dir
,
proofAt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
return
binary
,
subcommand
,
args
return
binary
,
subcommand
,
args
}
}
...
@@ -68,15 +70,15 @@ func TestGenerateProof(t *testing.T) {
...
@@ -68,15 +70,15 @@ func TestGenerateProof(t *testing.T) {
cfg
.
CannonRollupConfigPath
=
""
cfg
.
CannonRollupConfigPath
=
""
cfg
.
CannonL2GenesisPath
=
""
cfg
.
CannonL2GenesisPath
=
""
binary
,
subcommand
,
args
:=
captureExec
(
t
,
cfg
,
150
_000_000
)
binary
,
subcommand
,
args
:=
captureExec
(
t
,
cfg
,
150
_000_000
)
require
.
DirExists
(
t
,
filepath
.
Join
(
cfg
.
CannonData
dir
,
preimagesDir
))
require
.
DirExists
(
t
,
filepath
.
Join
(
dir
,
preimagesDir
))
require
.
DirExists
(
t
,
filepath
.
Join
(
cfg
.
CannonData
dir
,
proofsDir
))
require
.
DirExists
(
t
,
filepath
.
Join
(
dir
,
proofsDir
))
require
.
DirExists
(
t
,
filepath
.
Join
(
cfg
.
CannonData
dir
,
snapsDir
))
require
.
DirExists
(
t
,
filepath
.
Join
(
dir
,
snapsDir
))
require
.
Equal
(
t
,
cfg
.
CannonBin
,
binary
)
require
.
Equal
(
t
,
cfg
.
CannonBin
,
binary
)
require
.
Equal
(
t
,
"run"
,
subcommand
)
require
.
Equal
(
t
,
"run"
,
subcommand
)
require
.
Equal
(
t
,
input
,
args
[
"--input"
])
require
.
Equal
(
t
,
input
,
args
[
"--input"
])
require
.
Contains
(
t
,
args
,
"--meta"
)
require
.
Contains
(
t
,
args
,
"--meta"
)
require
.
Equal
(
t
,
""
,
args
[
"--meta"
])
require
.
Equal
(
t
,
""
,
args
[
"--meta"
])
require
.
Equal
(
t
,
filepath
.
Join
(
cfg
.
CannonData
dir
,
finalState
),
args
[
"--output"
])
require
.
Equal
(
t
,
filepath
.
Join
(
dir
,
finalState
),
args
[
"--output"
])
require
.
Equal
(
t
,
"=150000000"
,
args
[
"--proof-at"
])
require
.
Equal
(
t
,
"=150000000"
,
args
[
"--proof-at"
])
require
.
Equal
(
t
,
"=150000001"
,
args
[
"--stop-at"
])
require
.
Equal
(
t
,
"=150000001"
,
args
[
"--stop-at"
])
require
.
Equal
(
t
,
"%500"
,
args
[
"--snapshot-at"
])
require
.
Equal
(
t
,
"%500"
,
args
[
"--snapshot-at"
])
...
@@ -86,9 +88,9 @@ func TestGenerateProof(t *testing.T) {
...
@@ -86,9 +88,9 @@ func TestGenerateProof(t *testing.T) {
require
.
Equal
(
t
,
"--server"
,
args
[
cfg
.
CannonServer
])
require
.
Equal
(
t
,
"--server"
,
args
[
cfg
.
CannonServer
])
require
.
Equal
(
t
,
cfg
.
L1EthRpc
,
args
[
"--l1"
])
require
.
Equal
(
t
,
cfg
.
L1EthRpc
,
args
[
"--l1"
])
require
.
Equal
(
t
,
cfg
.
CannonL2
,
args
[
"--l2"
])
require
.
Equal
(
t
,
cfg
.
CannonL2
,
args
[
"--l2"
])
require
.
Equal
(
t
,
filepath
.
Join
(
cfg
.
CannonData
dir
,
preimagesDir
),
args
[
"--datadir"
])
require
.
Equal
(
t
,
filepath
.
Join
(
dir
,
preimagesDir
),
args
[
"--datadir"
])
require
.
Equal
(
t
,
filepath
.
Join
(
cfg
.
CannonData
dir
,
proofsDir
,
"%d.json"
),
args
[
"--proof-fmt"
])
require
.
Equal
(
t
,
filepath
.
Join
(
dir
,
proofsDir
,
"%d.json"
),
args
[
"--proof-fmt"
])
require
.
Equal
(
t
,
filepath
.
Join
(
cfg
.
CannonData
dir
,
snapsDir
,
"%d.json"
),
args
[
"--snapshot-fmt"
])
require
.
Equal
(
t
,
filepath
.
Join
(
dir
,
snapsDir
,
"%d.json"
),
args
[
"--snapshot-fmt"
])
require
.
Equal
(
t
,
cfg
.
CannonNetwork
,
args
[
"--network"
])
require
.
Equal
(
t
,
cfg
.
CannonNetwork
,
args
[
"--network"
])
require
.
NotContains
(
t
,
args
,
"--rollup.config"
)
require
.
NotContains
(
t
,
args
,
"--rollup.config"
)
require
.
NotContains
(
t
,
args
,
"--l2.genesis"
)
require
.
NotContains
(
t
,
args
,
"--l2.genesis"
)
...
...
op-challenger/fault/cannon/provider.go
View file @
d2b14ac9
...
@@ -64,13 +64,14 @@ func NewTraceProvider(ctx context.Context, logger log.Logger, cfg *config.Config
...
@@ -64,13 +64,14 @@ func NewTraceProvider(ctx context.Context, logger log.Logger, cfg *config.Config
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"fetch local game inputs: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"fetch local game inputs: %w"
,
err
)
}
}
return
NewTraceProviderFromInputs
(
logger
,
cfg
,
localInputs
),
nil
return
NewTraceProviderFromInputs
(
logger
,
cfg
,
gameAddr
.
Hex
(),
localInputs
),
nil
}
}
func
NewTraceProviderFromInputs
(
logger
log
.
Logger
,
cfg
*
config
.
Config
,
localInputs
LocalGameInputs
)
*
CannonTraceProvider
{
func
NewTraceProviderFromInputs
(
logger
log
.
Logger
,
cfg
*
config
.
Config
,
gameDirName
string
,
localInputs
LocalGameInputs
)
*
CannonTraceProvider
{
dir
:=
filepath
.
Join
(
cfg
.
CannonDatadir
,
gameDirName
)
return
&
CannonTraceProvider
{
return
&
CannonTraceProvider
{
logger
:
logger
,
logger
:
logger
,
dir
:
cfg
.
CannonData
dir
,
dir
:
dir
,
prestate
:
cfg
.
CannonAbsolutePreState
,
prestate
:
cfg
.
CannonAbsolutePreState
,
generator
:
NewExecutor
(
logger
,
cfg
,
localInputs
),
generator
:
NewExecutor
(
logger
,
cfg
,
localInputs
),
}
}
...
...
op-challenger/fault/cannon/provider_test.go
View file @
d2b14ac9
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"testing"
"testing"
"github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
...
@@ -149,7 +150,6 @@ func TestGetStepData(t *testing.T) {
...
@@ -149,7 +150,6 @@ func TestGetStepData(t *testing.T) {
func
TestAbsolutePreState
(
t
*
testing
.
T
)
{
func
TestAbsolutePreState
(
t
*
testing
.
T
)
{
dataDir
:=
t
.
TempDir
()
dataDir
:=
t
.
TempDir
()
_
=
os
.
Mkdir
(
dataDir
,
0
o777
)
prestate
:=
"state.json"
prestate
:=
"state.json"
...
@@ -189,6 +189,21 @@ func TestAbsolutePreState(t *testing.T) {
...
@@ -189,6 +189,21 @@ func TestAbsolutePreState(t *testing.T) {
})
})
}
}
func
TestUseGameSpecificSubdir
(
t
*
testing
.
T
)
{
tempDir
:=
t
.
TempDir
()
dataDir
:=
filepath
.
Join
(
tempDir
,
"data"
)
setupPreState
(
t
,
tempDir
,
"state.json"
)
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
cfg
:=
&
config
.
Config
{
CannonAbsolutePreState
:
filepath
.
Join
(
tempDir
,
"state.json"
),
CannonDatadir
:
dataDir
,
}
gameDirName
:=
"gameSubdir"
localInputs
:=
LocalGameInputs
{}
provider
:=
NewTraceProviderFromInputs
(
logger
,
cfg
,
gameDirName
,
localInputs
)
require
.
Equal
(
t
,
filepath
.
Join
(
dataDir
,
gameDirName
),
provider
.
dir
,
"should use game specific subdir"
)
}
func
setupPreState
(
t
*
testing
.
T
,
dataDir
string
,
filename
string
)
{
func
setupPreState
(
t
*
testing
.
T
,
dataDir
string
,
filename
string
)
{
srcDir
:=
filepath
.
Join
(
"test_data"
)
srcDir
:=
filepath
.
Join
(
"test_data"
)
path
:=
filepath
.
Join
(
srcDir
,
filename
)
path
:=
filepath
.
Join
(
srcDir
,
filename
)
...
...
op-e2e/e2eutils/disputegame/helper.go
View file @
d2b14ac9
...
@@ -170,7 +170,7 @@ func (h *FactoryHelper) StartCannonGameWithCorrectRoot(ctx context.Context, roll
...
@@ -170,7 +170,7 @@ func (h *FactoryHelper) StartCannonGameWithCorrectRoot(ctx context.Context, roll
L2Claim
:
challengedOutput
.
OutputRoot
,
L2Claim
:
challengedOutput
.
OutputRoot
,
L2BlockNumber
:
challengedOutput
.
L2BlockNumber
,
L2BlockNumber
:
challengedOutput
.
L2BlockNumber
,
}
}
provider
:=
cannon
.
NewTraceProviderFromInputs
(
testlog
.
Logger
(
h
.
t
,
log
.
LvlInfo
)
.
New
(
"role"
,
"CorrectTrace"
),
cfg
,
inputs
)
provider
:=
cannon
.
NewTraceProviderFromInputs
(
testlog
.
Logger
(
h
.
t
,
log
.
LvlInfo
)
.
New
(
"role"
,
"CorrectTrace"
),
cfg
,
"correct"
,
inputs
)
rootClaim
,
err
:=
provider
.
Get
(
ctx
,
math
.
MaxUint64
)
rootClaim
,
err
:=
provider
.
Get
(
ctx
,
math
.
MaxUint64
)
h
.
require
.
NoError
(
err
,
"Compute correct root hash"
)
h
.
require
.
NoError
(
err
,
"Compute correct root hash"
)
...
...
op-e2e/faultproof_test.go
View file @
d2b14ac9
...
@@ -50,7 +50,6 @@ func TestMultipleAlphabetGames(t *testing.T) {
...
@@ -50,7 +50,6 @@ func TestMultipleAlphabetGames(t *testing.T) {
}
}
func
TestMultipleCannonGames
(
t
*
testing
.
T
)
{
func
TestMultipleCannonGames
(
t
*
testing
.
T
)
{
t
.
Skip
(
"Cannon provider doesn't currently isolate different game traces"
)
InitParallel
(
t
)
InitParallel
(
t
)
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
...
...
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