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
76d06925
Unverified
Commit
76d06925
authored
Aug 07, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Load pre-image oracle address from the dispute game contract
parent
58a2d894
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
48 additions
and
74 deletions
+48
-74
main_test.go
op-challenger/cmd/main_test.go
+12
-34
config.go
op-challenger/config/config.go
+2
-8
config_test.go
op-challenger/config/config_test.go
+1
-8
executor_test.go
op-challenger/fault/cannon/executor_test.go
+1
-1
updater.go
op-challenger/fault/cannon/updater.go
+30
-1
updater_test.go
op-challenger/fault/cannon/updater_test.go
+1
-1
service.go
op-challenger/fault/service.go
+1
-1
flags.go
op-challenger/flags/flags.go
+0
-20
No files found.
op-challenger/cmd/main_test.go
View file @
76d06925
...
...
@@ -13,17 +13,16 @@ import (
)
var
(
l1EthRpc
=
"http://example.com:8545"
gameAddressValue
=
"0xaa00000000000000000000000000000000000000"
preimageOracleAddressValue
=
"0xbb00000000000000000000000000000000000000"
cannonBin
=
"./bin/cannon"
cannonServer
=
"./bin/op-program"
cannonPreState
=
"./pre.json"
cannonDatadir
=
"./test_data"
cannonL2
=
"http://example.com:9545"
alphabetTrace
=
"abcdefghijz"
agreeWithProposedOutput
=
"true"
gameDepth
=
"4"
l1EthRpc
=
"http://example.com:8545"
gameAddressValue
=
"0xaa00000000000000000000000000000000000000"
cannonBin
=
"./bin/cannon"
cannonServer
=
"./bin/op-program"
cannonPreState
=
"./pre.json"
cannonDatadir
=
"./test_data"
cannonL2
=
"http://example.com:9545"
alphabetTrace
=
"abcdefghijz"
agreeWithProposedOutput
=
"true"
gameDepth
=
"4"
)
func
TestLogLevel
(
t
*
testing
.
T
)
{
...
...
@@ -43,14 +42,14 @@ func TestLogLevel(t *testing.T) {
func
TestDefaultCLIOptionsMatchDefaultConfig
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgs
(
config
.
TraceTypeAlphabet
))
defaultCfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
co
mmon
.
HexToAddress
(
preimageOracleAddressValue
),
co
nfig
.
TraceTypeAlphabet
,
true
,
4
)
defaultCfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
config
.
TraceTypeAlphabet
,
true
,
4
)
// 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
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
co
mmon
.
HexToAddress
(
preimageOracleAddressValue
),
co
nfig
.
TraceTypeAlphabet
,
true
,
4
)
cfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
config
.
TraceTypeAlphabet
,
true
,
4
)
// 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
...
...
@@ -140,26 +139,6 @@ func TestGameDepth(t *testing.T) {
})
}
func
TestPreimageOracleAddress
(
t
*
testing
.
T
)
{
t
.
Run
(
"NotRequiredForAlphabetTrace"
,
func
(
t
*
testing
.
T
)
{
configForArgs
(
t
,
addRequiredArgsExcept
(
config
.
TraceTypeAlphabet
,
"--preimage-oracle-address"
))
})
t
.
Run
(
"Required"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
"flag preimage-oracle-address is required"
,
addRequiredArgsExcept
(
config
.
TraceTypeCannon
,
"--preimage-oracle-address"
))
})
t
.
Run
(
"Valid"
,
func
(
t
*
testing
.
T
)
{
addr
:=
common
.
Address
{
0xbb
,
0xcc
,
0xdd
}
cfg
:=
configForArgs
(
t
,
addRequiredArgsExcept
(
config
.
TraceTypeCannon
,
"--preimage-oracle-address"
,
"--preimage-oracle-address="
+
addr
.
Hex
()))
require
.
Equal
(
t
,
addr
,
cfg
.
PreimageOracleAddress
)
})
t
.
Run
(
"Invalid"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
"invalid address: foo"
,
addRequiredArgsExcept
(
config
.
TraceTypeCannon
,
"--preimage-oracle-address"
,
"--preimage-oracle-address=foo"
))
})
}
func
TestCannonBin
(
t
*
testing
.
T
)
{
t
.
Run
(
"NotRequiredForAlphabetTrace"
,
func
(
t
*
testing
.
T
)
{
configForArgs
(
t
,
addRequiredArgsExcept
(
config
.
TraceTypeAlphabet
,
"--cannon-bin"
))
...
...
@@ -288,7 +267,6 @@ func requiredArgs(traceType config.TraceType) map[string]string {
"--agree-with-proposed-output"
:
agreeWithProposedOutput
,
"--l1-eth-rpc"
:
l1EthRpc
,
"--game-address"
:
gameAddressValue
,
"--preimage-oracle-address"
:
preimageOracleAddressValue
,
"--trace-type"
:
traceType
.
String
(),
}
switch
traceType
{
...
...
op-challenger/config/config.go
View file @
76d06925
...
...
@@ -61,7 +61,6 @@ const DefaultCannonSnapshotFreq = uint(10_000)
type
Config
struct
{
L1EthRpc
string
// L1 RPC Url
GameAddress
common
.
Address
// Address of the fault game
PreimageOracleAddress
common
.
Address
// Address of the pre-image oracle
AgreeWithProposedOutput
bool
// Temporary config if we agree or disagree with the posted output
GameDepth
int
// Depth of the game tree
...
...
@@ -84,15 +83,13 @@ type Config struct {
func
NewConfig
(
l1EthRpc
string
,
gameAddress
common
.
Address
,
preimageOracleAddress
common
.
Address
,
traceType
TraceType
,
agreeWithProposedOutput
bool
,
gameDepth
int
,
)
Config
{
return
Config
{
L1EthRpc
:
l1EthRpc
,
GameAddress
:
gameAddress
,
PreimageOracleAddress
:
preimageOracleAddress
,
L1EthRpc
:
l1EthRpc
,
GameAddress
:
gameAddress
,
AgreeWithProposedOutput
:
agreeWithProposedOutput
,
GameDepth
:
gameDepth
,
...
...
@@ -116,9 +113,6 @@ func (c Config) Check() error {
return
ErrMissingTraceType
}
if
c
.
TraceType
==
TraceTypeCannon
{
if
c
.
PreimageOracleAddress
==
(
common
.
Address
{})
{
return
ErrMissingPreimageOracleAddress
}
if
c
.
CannonBin
==
""
{
return
ErrMissingCannonBin
}
...
...
op-challenger/config/config_test.go
View file @
76d06925
...
...
@@ -11,7 +11,6 @@ import (
var
(
validL1EthRpc
=
"http://localhost:8545"
validGameAddress
=
common
.
HexToAddress
(
"0x7bdd3b028C4796eF0EAf07d11394d0d9d8c24139"
)
validPreimageOracleAddress
=
common
.
HexToAddress
(
"0x7bdd3b028C4796eF0EAf07d11394d0d9d8c24139"
)
validAlphabetTrace
=
"abcdefgh"
validCannonBin
=
"./bin/cannon"
validCannonOpProgramBin
=
"./bin/op-program"
...
...
@@ -23,7 +22,7 @@ var (
)
func
validConfig
(
traceType
TraceType
)
Config
{
cfg
:=
NewConfig
(
validL1EthRpc
,
validGameAddress
,
validPreimageOracleAddress
,
traceType
,
agreeWithProposedOutput
,
gameDepth
)
cfg
:=
NewConfig
(
validL1EthRpc
,
validGameAddress
,
traceType
,
agreeWithProposedOutput
,
gameDepth
)
switch
traceType
{
case
TraceTypeAlphabet
:
cfg
.
AlphabetTrace
=
validAlphabetTrace
...
...
@@ -74,12 +73,6 @@ func TestAlphabetTraceRequired(t *testing.T) {
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingAlphabetTrace
)
}
func
TestCannonPreimageOracleAddressRequired
(
t
*
testing
.
T
)
{
config
:=
validConfig
(
TraceTypeCannon
)
config
.
PreimageOracleAddress
=
common
.
Address
{}
require
.
ErrorIs
(
t
,
config
.
Check
(),
ErrMissingPreimageOracleAddress
)
}
func
TestCannonBinRequired
(
t
*
testing
.
T
)
{
config
:=
validConfig
(
TraceTypeCannon
)
config
.
CannonBin
=
""
...
...
op-challenger/fault/cannon/executor_test.go
View file @
76d06925
...
...
@@ -20,7 +20,7 @@ const execTestCannonPrestate = "/foo/pre.json"
func
TestGenerateProof
(
t
*
testing
.
T
)
{
input
:=
"starting.json"
cfg
:=
config
.
NewConfig
(
"http://localhost:8888"
,
common
.
Address
{
0xaa
},
co
mmon
.
Address
{
0xbb
},
co
nfig
.
TraceTypeCannon
,
true
,
5
)
cfg
:=
config
.
NewConfig
(
"http://localhost:8888"
,
common
.
Address
{
0xaa
},
config
.
TraceTypeCannon
,
true
,
5
)
cfg
.
CannonDatadir
=
t
.
TempDir
()
cfg
.
CannonAbsolutePreState
=
"pre.json"
cfg
.
CannonBin
=
"./bin/cannon"
...
...
op-challenger/fault/cannon/updater.go
View file @
76d06925
...
...
@@ -8,6 +8,7 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -28,8 +29,36 @@ type cannonUpdater struct {
preimageOracleAddr
common
.
Address
}
// NewOracleUpdater returns a new updater.
// NewOracleUpdater returns a new updater.
The pre-image oracle address is loaded from the fault dispute game.
func
NewOracleUpdater
(
ctx
context
.
Context
,
logger
log
.
Logger
,
txMgr
txmgr
.
TxManager
,
fdgAddr
common
.
Address
,
client
bind
.
ContractCaller
,
)
(
*
cannonUpdater
,
error
)
{
gameCaller
,
err
:=
bindings
.
NewFaultDisputeGameCaller
(
fdgAddr
,
client
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"create caller for game %v: %w"
,
fdgAddr
,
err
)
}
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
vm
,
err
:=
gameCaller
.
VM
(
opts
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to load VM address from game %v: %w"
,
fdgAddr
,
err
)
}
mipsCaller
,
err
:=
bindings
.
NewMIPSCaller
(
vm
,
client
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to create MIPS caller for address %v: %w"
,
vm
,
err
)
}
oracleAddr
,
err
:=
mipsCaller
.
Oracle
(
opts
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to load pre-image oracle address from game %v: %w"
,
fdgAddr
,
err
)
}
return
NewOracleUpdaterWithOracle
(
logger
,
txMgr
,
fdgAddr
,
oracleAddr
)
}
// NewOracleUpdaterWithOracle returns a new updater using a specified pre-image oracle address.
func
NewOracleUpdaterWithOracle
(
logger
log
.
Logger
,
txMgr
txmgr
.
TxManager
,
fdgAddr
common
.
Address
,
...
...
op-challenger/fault/cannon/updater_test.go
View file @
76d06925
...
...
@@ -64,7 +64,7 @@ func newTestCannonUpdater(t *testing.T, sendFails bool) (*cannonUpdater, *mockTx
from
:
mockFdgAddress
,
sendFails
:
sendFails
,
}
updater
,
err
:=
NewOracleUpdater
(
logger
,
txMgr
,
mockFdgAddress
,
mockPreimageOracleAddress
)
updater
,
err
:=
NewOracleUpdater
WithOracle
(
logger
,
txMgr
,
mockFdgAddress
,
mockPreimageOracleAddress
)
require
.
NoError
(
t
,
err
)
return
updater
,
txMgr
}
...
...
op-challenger/fault/service.go
View file @
76d06925
...
...
@@ -49,7 +49,7 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*se
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"create cannon trace provider: %w"
,
err
)
}
updater
,
err
=
cannon
.
NewOracleUpdater
(
logger
,
txMgr
,
cfg
.
GameAddress
,
cfg
.
PreimageOracleAddress
)
updater
,
err
=
cannon
.
NewOracleUpdater
(
ctx
,
logger
,
txMgr
,
cfg
.
GameAddress
,
client
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to create the cannon updater: %w"
,
err
)
}
...
...
op-challenger/flags/flags.go
View file @
76d06925
...
...
@@ -10,7 +10,6 @@ import (
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"
"github.com/urfave/cli/v2"
)
...
...
@@ -59,11 +58,6 @@ var (
Usage
:
"Correct Alphabet Trace (alphabet trace type only)"
,
EnvVars
:
prefixEnvVars
(
"ALPHABET"
),
}
PreimageOracleAddressFlag
=
&
cli
.
StringFlag
{
Name
:
"preimage-oracle-address"
,
Usage
:
"Address of the Preimage Oracle contract (only required for cannon)."
,
EnvVars
:
prefixEnvVars
(
"PREIMAGE_ORACLE_ADDRESS"
),
}
CannonBinFlag
=
&
cli
.
StringFlag
{
Name
:
"cannon-bin"
,
Usage
:
"Path to cannon executable to use when generating trace data (cannon trace type only)"
,
...
...
@@ -109,7 +103,6 @@ var requiredFlags = []cli.Flag{
// optionalFlags is a list of unchecked cli flags
var
optionalFlags
=
[]
cli
.
Flag
{
AlphabetFlag
,
PreimageOracleAddressFlag
,
CannonBinFlag
,
CannonServerFlag
,
CannonPreStateFlag
,
...
...
@@ -137,9 +130,6 @@ func CheckRequired(ctx *cli.Context) error {
gameType
:=
config
.
TraceType
(
strings
.
ToLower
(
ctx
.
String
(
TraceTypeFlag
.
Name
)))
switch
gameType
{
case
config
.
TraceTypeCannon
:
if
!
ctx
.
IsSet
(
PreimageOracleAddressFlag
.
Name
)
{
return
fmt
.
Errorf
(
"flag %s is required"
,
PreimageOracleAddressFlag
.
Name
)
}
if
!
ctx
.
IsSet
(
CannonBinFlag
.
Name
)
{
return
fmt
.
Errorf
(
"flag %s is required"
,
CannonBinFlag
.
Name
)
}
...
...
@@ -179,21 +169,11 @@ func NewConfigFromCLI(ctx *cli.Context) (*config.Config, error) {
traceTypeFlag
:=
config
.
TraceType
(
strings
.
ToLower
(
ctx
.
String
(
TraceTypeFlag
.
Name
)))
preimageOracleAddress
:=
common
.
Address
{}
preimageOracleValue
:=
ctx
.
String
(
PreimageOracleAddressFlag
.
Name
)
if
traceTypeFlag
==
config
.
TraceTypeCannon
||
preimageOracleValue
!=
""
{
preimageOracleAddress
,
err
=
opservice
.
ParseAddress
(
preimageOracleValue
)
if
err
!=
nil
{
return
nil
,
err
}
}
return
&
config
.
Config
{
// Required Flags
L1EthRpc
:
ctx
.
String
(
L1EthRpcFlag
.
Name
),
TraceType
:
traceTypeFlag
,
GameAddress
:
dgfAddress
,
PreimageOracleAddress
:
preimageOracleAddress
,
AlphabetTrace
:
ctx
.
String
(
AlphabetFlag
.
Name
),
CannonBin
:
ctx
.
String
(
CannonBinFlag
.
Name
),
CannonServer
:
ctx
.
String
(
CannonServerFlag
.
Name
),
...
...
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