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
838e8968
Unverified
Commit
838e8968
authored
Aug 03, 2023
by
mergify[bot]
Committed by
GitHub
Aug 03, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into feat/deploy-script
parents
042048ba
710ca379
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
307 additions
and
36 deletions
+307
-36
charlie.sh
op-challenger/charlie.sh
+3
-0
main_test.go
op-challenger/cmd/main_test.go
+34
-12
config.go
op-challenger/config/config.go
+9
-2
config_test.go
op-challenger/config/config_test.go
+8
-1
updater.go
op-challenger/fault/alphabet/updater.go
+27
-0
updater_test.go
op-challenger/fault/alphabet/updater_test.go
+19
-0
executor_test.go
op-challenger/fault/cannon/executor_test.go
+1
-1
updater.go
op-challenger/fault/cannon/updater.go
+59
-0
updater_test.go
op-challenger/fault/cannon/updater_test.go
+87
-0
service.go
op-challenger/fault/service.go
+27
-16
types.go
op-challenger/fault/types/types.go
+6
-0
flags.go
op-challenger/flags/flags.go
+24
-4
mallory.sh
op-challenger/mallory.sh
+3
-0
No files found.
op-challenger/charlie.sh
View file @
838e8968
...
...
@@ -14,11 +14,14 @@ MALLORY_KEY="28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
FAULT_GAME_ADDRESS
=
"0x8daf17a20c9dba35f005b6324f493785d239719d"
PREIMAGE_ORACLE_ADDRESS
=
"0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"
./bin/op-challenger
\
--l1-eth-rpc
http://localhost:8545
\
--trace-type
=
"alphabet"
\
--alphabet
"abcdefgh"
\
--game-address
$FAULT_GAME_ADDRESS
\
--preimage-oracle-address
$PREIMAGE_ORACLE_ADDRESS
\
--private-key
$CHARLIE_KEY
\
--num-confirmations
1
\
--game-depth
4
\
...
...
op-challenger/cmd/main_test.go
View file @
838e8968
...
...
@@ -13,16 +13,17 @@ import (
)
var
(
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"
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"
)
func
TestLogLevel
(
t
*
testing
.
T
)
{
...
...
@@ -42,14 +43,14 @@ func TestLogLevel(t *testing.T) {
func
TestDefaultCLIOptionsMatchDefaultConfig
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgs
(
config
.
TraceTypeAlphabet
))
defaultCfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
config
.
TraceTypeAlphabet
,
true
,
4
)
defaultCfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
co
mmon
.
HexToAddress
(
preimageOracleAddressValue
),
co
nfig
.
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
),
config
.
TraceTypeAlphabet
,
true
,
4
)
cfg
:=
config
.
NewConfig
(
l1EthRpc
,
common
.
HexToAddress
(
gameAddressValue
),
co
mmon
.
HexToAddress
(
preimageOracleAddressValue
),
co
nfig
.
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
...
...
@@ -139,6 +140,26 @@ 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"
))
...
...
@@ -267,6 +288,7 @@ 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 @
838e8968
...
...
@@ -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"
)
ErrMissingPreimageOracleAddress
=
errors
.
New
(
"missing pre-image oracle address"
)
ErrMissingCannonSnapshotFreq
=
errors
.
New
(
"missing cannon snapshot freq"
)
)
...
...
@@ -60,6 +61,7 @@ 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
...
...
@@ -82,13 +84,15 @@ 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
,
L1EthRpc
:
l1EthRpc
,
GameAddress
:
gameAddress
,
PreimageOracleAddress
:
preimageOracleAddress
,
AgreeWithProposedOutput
:
agreeWithProposedOutput
,
GameDepth
:
gameDepth
,
...
...
@@ -112,6 +116,9 @@ 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 @
838e8968
...
...
@@ -11,6 +11,7 @@ import (
var
(
validL1EthRpc
=
"http://localhost:8545"
validGameAddress
=
common
.
HexToAddress
(
"0x7bdd3b028C4796eF0EAf07d11394d0d9d8c24139"
)
validPreimageOracleAddress
=
common
.
HexToAddress
(
"0x7bdd3b028C4796eF0EAf07d11394d0d9d8c24139"
)
validAlphabetTrace
=
"abcdefgh"
validCannonBin
=
"./bin/cannon"
validCannonOpProgramBin
=
"./bin/op-program"
...
...
@@ -22,7 +23,7 @@ var (
)
func
validConfig
(
traceType
TraceType
)
Config
{
cfg
:=
NewConfig
(
validL1EthRpc
,
validGameAddress
,
traceType
,
agreeWithProposedOutput
,
gameDepth
)
cfg
:=
NewConfig
(
validL1EthRpc
,
validGameAddress
,
validPreimageOracleAddress
,
traceType
,
agreeWithProposedOutput
,
gameDepth
)
switch
traceType
{
case
TraceTypeAlphabet
:
cfg
.
AlphabetTrace
=
validAlphabetTrace
...
...
@@ -73,6 +74,12 @@ 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/alphabet/updater.go
0 → 100644
View file @
838e8968
package
alphabet
import
(
"context"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum/go-ethereum/log"
)
// alphabetUpdater is a [types.OracleUpdater] that exposes a
// method to update onchain oracles with required data.
type
alphabetUpdater
struct
{
logger
log
.
Logger
}
// NewOracleUpdater returns a new updater.
func
NewOracleUpdater
(
logger
log
.
Logger
)
*
alphabetUpdater
{
return
&
alphabetUpdater
{
logger
:
logger
,
}
}
// UpdateOracle updates the oracle with the given data.
func
(
u
*
alphabetUpdater
)
UpdateOracle
(
ctx
context
.
Context
,
data
types
.
PreimageOracleData
)
error
{
u
.
logger
.
Info
(
"alphabet oracle updater called"
)
return
nil
}
op-challenger/fault/alphabet/updater_test.go
0 → 100644
View file @
838e8968
package
alphabet
import
(
"context"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/fault/types"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
)
// TestAlphabetUpdater tests the [alphabetUpdater].
func
TestAlphabetUpdater
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
updater
:=
NewOracleUpdater
(
logger
)
require
.
Nil
(
t
,
updater
.
UpdateOracle
(
context
.
Background
(),
types
.
PreimageOracleData
{}))
}
op-challenger/fault/cannon/executor_test.go
View file @
838e8968
...
...
@@ -19,7 +19,7 @@ const execTestCannonPrestate = "/foo/pre.json"
func
TestGenerateProof
(
t
*
testing
.
T
)
{
input
:=
"starting.json"
cfg
:=
config
.
NewConfig
(
"http://localhost:8888"
,
common
.
Address
{
0xaa
},
config
.
TraceTypeCannon
,
true
,
5
)
cfg
:=
config
.
NewConfig
(
"http://localhost:8888"
,
common
.
Address
{
0xaa
},
co
mmon
.
Address
{
0xbb
},
co
nfig
.
TraceTypeCannon
,
true
,
5
)
cfg
.
CannonDatadir
=
t
.
TempDir
()
cfg
.
CannonAbsolutePreState
=
"pre.json"
cfg
.
CannonBin
=
"./bin/cannon"
...
...
op-challenger/fault/cannon/updater.go
0 → 100644
View file @
838e8968
package
cannon
import
(
"context"
"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"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
)
// cannonUpdater is a [types.OracleUpdater] that exposes a method
// to update onchain cannon oracles with required data.
type
cannonUpdater
struct
{
logger
log
.
Logger
txMgr
txmgr
.
TxManager
fdgAbi
abi
.
ABI
fdgAddr
common
.
Address
preimageOracleAbi
abi
.
ABI
preimageOracleAddr
common
.
Address
}
// NewOracleUpdater returns a new updater.
func
NewOracleUpdater
(
logger
log
.
Logger
,
txMgr
txmgr
.
TxManager
,
fdgAddr
common
.
Address
,
preimageOracleAddr
common
.
Address
,
)
(
*
cannonUpdater
,
error
)
{
fdgAbi
,
err
:=
bindings
.
FaultDisputeGameMetaData
.
GetAbi
()
if
err
!=
nil
{
return
nil
,
err
}
preimageOracleAbi
,
err
:=
bindings
.
PreimageOracleMetaData
.
GetAbi
()
if
err
!=
nil
{
return
nil
,
err
}
return
&
cannonUpdater
{
logger
:
logger
,
txMgr
:
txMgr
,
fdgAbi
:
*
fdgAbi
,
fdgAddr
:
fdgAddr
,
preimageOracleAbi
:
*
preimageOracleAbi
,
preimageOracleAddr
:
preimageOracleAddr
,
},
nil
}
// UpdateOracle updates the oracle with the given data.
func
(
u
*
cannonUpdater
)
UpdateOracle
(
ctx
context
.
Context
,
data
types
.
PreimageOracleData
)
error
{
panic
(
"oracle updates not implemented"
)
}
op-challenger/fault/cannon/updater_test.go
0 → 100644
View file @
838e8968
package
cannon
import
(
"context"
"errors"
"math/big"
"testing"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum"
ethtypes
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
)
var
(
mockFdgAddress
=
common
.
HexToAddress
(
"0x1234"
)
mockPreimageOracleAddress
=
common
.
HexToAddress
(
"0x12345"
)
mockSendError
=
errors
.
New
(
"mock send error"
)
)
type
mockTxManager
struct
{
from
common
.
Address
sends
int
calls
int
sendFails
bool
}
func
(
m
*
mockTxManager
)
Send
(
ctx
context
.
Context
,
candidate
txmgr
.
TxCandidate
)
(
*
ethtypes
.
Receipt
,
error
)
{
if
m
.
sendFails
{
return
nil
,
mockSendError
}
m
.
sends
++
return
ethtypes
.
NewReceipt
(
[]
byte
{},
false
,
0
,
),
nil
}
func
(
m
*
mockTxManager
)
Call
(
_
context
.
Context
,
_
ethereum
.
CallMsg
,
_
*
big
.
Int
)
([]
byte
,
error
)
{
if
m
.
sendFails
{
return
nil
,
mockSendError
}
m
.
calls
++
return
[]
byte
{},
nil
}
func
(
m
*
mockTxManager
)
BlockNumber
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
panic
(
"not implemented"
)
}
func
(
m
*
mockTxManager
)
From
()
common
.
Address
{
return
m
.
from
}
func
newTestCannonUpdater
(
t
*
testing
.
T
,
sendFails
bool
)
(
*
cannonUpdater
,
*
mockTxManager
)
{
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
txMgr
:=
&
mockTxManager
{
from
:
mockFdgAddress
,
sendFails
:
sendFails
,
}
updater
,
err
:=
NewOracleUpdater
(
logger
,
txMgr
,
mockFdgAddress
,
mockPreimageOracleAddress
)
require
.
NoError
(
t
,
err
)
return
updater
,
txMgr
}
// TestCannonUpdater_UpdateOracle tests the [cannonUpdater]
// UpdateOracle function.
func
TestCannonUpdater_UpdateOracle
(
t
*
testing
.
T
)
{
t
.
Run
(
"succeeds"
,
func
(
t
*
testing
.
T
)
{
_
,
_
=
newTestCannonUpdater
(
t
,
false
)
// require.Nil(t, updater.UpdateOracle(context.Background(), types.PreimageOracleData{}))
// require.Equal(t, 1, mockTxMgr.calls)
})
t
.
Run
(
"send fails"
,
func
(
t
*
testing
.
T
)
{
_
,
_
=
newTestCannonUpdater
(
t
,
true
)
// require.Error(t, updater.UpdateOracle(context.Background(), types.PreimageOracleData{}))
// require.Equal(t, 1, mockTxMgr.calls)
})
}
op-challenger/fault/service.go
View file @
838e8968
...
...
@@ -31,14 +31,35 @@ type service struct {
// NewService creates a new Service.
func
NewService
(
ctx
context
.
Context
,
logger
log
.
Logger
,
cfg
*
config
.
Config
)
(
*
service
,
error
)
{
client
,
err
:=
ethclient
.
Dial
(
cfg
.
L1EthRpc
)
txMgr
,
err
:=
txmgr
.
NewSimpleTxManager
(
"challenger"
,
logger
,
&
metrics
.
NoopTxMetrics
{},
cfg
.
TxMgrConfig
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to
dial L1
: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to
create the transaction manager
: %w"
,
err
)
}
txMgr
,
err
:=
txmgr
.
NewSimpleTxManager
(
"challenger"
,
logger
,
&
metrics
.
NoopTxMetrics
{},
cfg
.
TxMgrConfig
)
var
trace
types
.
TraceProvider
var
updater
types
.
OracleUpdater
switch
cfg
.
TraceType
{
case
config
.
TraceTypeCannon
:
trace
=
cannon
.
NewTraceProvider
(
logger
,
cfg
)
updater
,
err
=
cannon
.
NewOracleUpdater
(
logger
,
txMgr
,
cfg
.
GameAddress
,
cfg
.
PreimageOracleAddress
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to create the cannon updater: %w"
,
err
)
}
case
config
.
TraceTypeAlphabet
:
trace
=
alphabet
.
NewTraceProvider
(
cfg
.
AlphabetTrace
,
uint64
(
cfg
.
GameDepth
))
updater
=
alphabet
.
NewOracleUpdater
(
logger
)
default
:
return
nil
,
fmt
.
Errorf
(
"unsupported trace type: %v"
,
cfg
.
TraceType
)
}
return
newTypedService
(
ctx
,
logger
,
cfg
,
trace
,
updater
,
txMgr
)
}
// newTypedService creates a new Service from a provided trace provider.
func
newTypedService
(
ctx
context
.
Context
,
logger
log
.
Logger
,
cfg
*
config
.
Config
,
provider
types
.
TraceProvider
,
uploader
types
.
OracleUpdater
,
txMgr
txmgr
.
TxManager
)
(
*
service
,
error
)
{
client
,
err
:=
ethclient
.
Dial
(
cfg
.
L1EthRpc
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to
create the transaction manager
: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to
dial L1
: %w"
,
err
)
}
contract
,
err
:=
bindings
.
NewFaultDisputeGameCaller
(
cfg
.
GameAddress
,
client
)
...
...
@@ -53,23 +74,13 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*se
return
nil
,
fmt
.
Errorf
(
"failed to create the responder: %w"
,
err
)
}
var
trace
types
.
TraceProvider
switch
cfg
.
TraceType
{
case
config
.
TraceTypeCannon
:
trace
=
cannon
.
NewTraceProvider
(
logger
,
cfg
)
case
config
.
TraceTypeAlphabet
:
trace
=
alphabet
.
NewTraceProvider
(
cfg
.
AlphabetTrace
,
uint64
(
cfg
.
GameDepth
))
default
:
return
nil
,
fmt
.
Errorf
(
"unsupported trace type: %v"
,
cfg
.
TraceType
)
}
agent
:=
NewAgent
(
loader
,
cfg
.
GameDepth
,
trace
,
responder
,
cfg
.
AgreeWithProposedOutput
,
gameLogger
)
caller
,
err
:=
NewFaultCallerFromBindings
(
cfg
.
GameAddress
,
client
,
gameLogger
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to bind the fault contract: %w"
,
err
)
}
agent
:=
NewAgent
(
loader
,
cfg
.
GameDepth
,
provider
,
responder
,
cfg
.
AgreeWithProposedOutput
,
gameLogger
)
return
&
service
{
agent
:
agent
,
agreeWithProposedOutput
:
cfg
.
AgreeWithProposedOutput
,
...
...
op-challenger/fault/types/types.go
View file @
838e8968
...
...
@@ -44,6 +44,12 @@ type StepCallData struct {
Proof
[]
byte
}
// OracleUpdater is a generic interface for updating oracles.
type
OracleUpdater
interface
{
// UpdateOracle updates the oracle with the given data.
UpdateOracle
(
ctx
context
.
Context
,
data
PreimageOracleData
)
error
}
// TraceProvider is a generic way to get a claim value at a specific step in the trace.
type
TraceProvider
interface
{
// Get returns the claim value at the requested index.
...
...
op-challenger/flags/flags.go
View file @
838e8968
...
...
@@ -5,12 +5,13 @@ import (
"strings"
"github.com/ethereum-optimism/optimism/op-challenger/config"
openum
"github.com/ethereum-optimism/optimism/op-service/enum"
"github.com/urfave/cli/v2"
opservice
"github.com/ethereum-optimism/optimism/op-service"
openum
"github.com/ethereum-optimism/optimism/op-service/enum"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
txmgr
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"
"github.com/urfave/cli/v2"
)
const
(
...
...
@@ -58,6 +59,11 @@ 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)"
,
...
...
@@ -103,6 +109,7 @@ var requiredFlags = []cli.Flag{
// optionalFlags is a list of unchecked cli flags
var
optionalFlags
=
[]
cli
.
Flag
{
AlphabetFlag
,
PreimageOracleAddressFlag
,
CannonBinFlag
,
CannonServerFlag
,
CannonPreStateFlag
,
...
...
@@ -130,6 +137,9 @@ 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
)
}
...
...
@@ -169,11 +179,21 @@ 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
),
...
...
op-challenger/mallory.sh
View file @
838e8968
...
...
@@ -14,11 +14,14 @@ MALLORY_KEY="28d7045146193f5f4eeb151c4843544b1b0d30a7ac1680c845a416fac65a7715"
FAULT_GAME_ADDRESS
=
"0x8daf17a20c9dba35f005b6324f493785d239719d"
PREIMAGE_ORACLE_ADDRESS
=
"0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"
./bin/op-challenger
\
--l1-eth-rpc
http://localhost:8545
\
--trace-type
=
"alphabet"
\
--alphabet
"abcdexyz"
\
--game-address
$FAULT_GAME_ADDRESS
\
--preimage-oracle-address
$PREIMAGE_ORACLE_ADDRESS
\
--private-key
$MALLORY_KEY
\
--num-confirmations
1
\
--game-depth
4
\
...
...
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