Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions op-challenger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Run the `op-challenger` with:
```shell
DISPUTE_GAME_FACTORY=$(jq -r .DisputeGameFactoryProxy .devnet/addresses.json)
./op-challenger/bin/op-challenger \
--trace-type cannon \
--game-types cannon \
--l1-eth-rpc http://localhost:8545 \
--rollup-rpc http://localhost:9546 \
--game-factory-address $DISPUTE_GAME_FACTORY \
Expand Down Expand Up @@ -99,8 +99,7 @@ in the L2 output oracle.
* `L2_BLOCK_NUM` the L2 block number the proposed output root is from.
* `SIGNER_ARGS` arguments to specify the key to sign transactions with (e.g `--private-key`)

Optionally, you may specify the game type (aka "trace type") using the `--trace-type`
flag, which is set to the cannon trace type by default.
Optionally, you may override the game types to support using the `--game-types` flag.

For known networks, the `--game-factory-address` option can be replaced by `--network`. See the `--help` output for a
list of predefined networks.
Expand Down Expand Up @@ -226,10 +225,10 @@ configured with multiple different prestates. This allows testing both the curre
the fault proofs virtual machine used by the trace provider.

The same CLI options as `op-challenger` itself are supported to configure the trace providers. The additional `--run`
option allows specifying which prestates to use. The format is `traceType/name/prestateHash` where traceType is the
trace type to use with the prestate (e.g cannon or asterisc-kona), name is an arbitrary name for the prestate to use
option allows specifying which prestates to use. The format is `gameType/name/prestateHash` where gameType is the
game type to use with the prestate (e.g cannon or asterisc-kona), name is an arbitrary name for the prestate to use
when reporting metrics and prestateHash is the hex encoded absolute prestate commitment to use. If name is omitted the
trace type name is used. If the prestateHash is omitted, the absolute prestate hash used for new games on-chain is used.
game type name is used. If the prestateHash is omitted, the absolute prestate hash used for new games on-chain is used.

For example to run both the production cannon prestate and a custom
prestate, use `--run cannon,cannon/next-prestate/0x03c1f0d45248190f80430a4c31e24f8108f05f80ff8b16ecb82d20df6b1b43f3`.
687 changes: 348 additions & 339 deletions op-challenger/cmd/main_test.go

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions op-challenger/cmd/run_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"context"
"errors"
"fmt"
"slices"
"strings"

"github.com/ethereum-optimism/optimism/op-challenger/flags"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
gameTypes "github.com/ethereum-optimism/optimism/op-challenger/game/types"
"github.com/ethereum-optimism/optimism/op-challenger/runner"
opservice "github.com/ethereum-optimism/optimism/op-service"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
Expand All @@ -17,7 +16,6 @@ import (
)

var (
ErrUnknownTraceType = errors.New("unknown trace type")
ErrInvalidPrestateHash = errors.New("invalid prestate hash")
)

Expand All @@ -40,9 +38,9 @@ func RunTrace(ctx *cli.Context, _ context.CancelCauseFunc) (cliapp.Lifecycle, er
return nil, err
}
if len(runConfigs) == 0 {
// Default to running on-chain version of each enabled trace type
for _, traceType := range cfg.TraceTypes {
runConfigs = append(runConfigs, runner.RunConfig{TraceType: traceType})
// Default to running on-chain version of each enabled game type
for _, gameType := range cfg.GameTypes {
runConfigs = append(runConfigs, runner.RunConfig{GameType: gameType})
}
}
return runner.NewRunner(logger, cfg, runConfigs), nil
Expand All @@ -63,11 +61,11 @@ var RunTraceCommand = &cli.Command{
var (
RunTraceRunFlag = &cli.StringSliceFlag{
Name: "run",
Usage: "Specify a trace to run. Format is traceType/name/prestateHash where " +
"traceType is the trace type to use with the prestate (e.g cannon or asterisc-kona), " +
Usage: "Specify a trace to run. Format is gameType/name/prestateHash where " +
"gameType is the game type to use with the prestate (e.g cannon or asterisc-kona), " +
"name is an arbitrary name for the prestate to use when reporting metrics and" +
"prestateHash is the hex encoded absolute prestate commitment to use. " +
"If name is omitted the trace type name is used." +
"If name is omitted the game type name is used." +
"If the prestateHash is omitted, the absolute prestate hash used for new games on-chain.",
EnvVars: opservice.PrefixEnvVar(flags.EnvVarPrefix, "RUN"),
}
Expand All @@ -91,14 +89,15 @@ func parseRunArg(arg string) (runner.RunConfig, error) {
if len(opts) == 0 {
return runner.RunConfig{}, fmt.Errorf("invalid run config %q", arg)
}
cfg.TraceType = types.TraceType(opts[0])
if !slices.Contains(types.TraceTypes, cfg.TraceType) {
return runner.RunConfig{}, fmt.Errorf("%w %q for run config %q", ErrUnknownTraceType, opts[0], arg)
gameType, err := gameTypes.SupportedGameTypeFromString(opts[0])
if err != nil {
return runner.RunConfig{}, fmt.Errorf("%w %q for run config %q", err, opts[0], arg)
}
cfg.GameType = gameType
if len(opts) > 1 {
cfg.Name = opts[1]
} else {
cfg.Name = cfg.TraceType.String()
cfg.Name = cfg.GameType.String()
}
if len(opts) > 2 {
if strings.HasPrefix(opts[2], "0x") {
Expand Down
14 changes: 7 additions & 7 deletions op-challenger/cmd/run_trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
"testing"

"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
gameTypes "github.com/ethereum-optimism/optimism/op-challenger/game/types"
"github.com/ethereum-optimism/optimism/op-challenger/runner"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
Expand All @@ -16,13 +16,13 @@ func TestParseRunArg(t *testing.T) {
expected runner.RunConfig
err error
}{
{arg: "unknown/test1/0x1234", err: ErrUnknownTraceType},
{arg: "cannon", expected: runner.RunConfig{TraceType: types.TraceTypeCannon, Name: types.TraceTypeCannon.String()}},
{arg: "asterisc", expected: runner.RunConfig{TraceType: types.TraceTypeAsterisc, Name: types.TraceTypeAsterisc.String()}},
{arg: "cannon/test1", expected: runner.RunConfig{TraceType: types.TraceTypeCannon, Name: "test1"}},
{arg: "cannon/test1/0x1234", expected: runner.RunConfig{TraceType: types.TraceTypeCannon, Name: "test1", Prestate: common.HexToHash("0x1234")}},
{arg: "unknown/test1/0x1234", err: gameTypes.ErrUnknownGameType},
{arg: "cannon", expected: runner.RunConfig{GameType: gameTypes.CannonGameType, Name: gameTypes.CannonGameType.String()}},
{arg: "asterisc", expected: runner.RunConfig{GameType: gameTypes.AsteriscGameType, Name: gameTypes.AsteriscGameType.String()}},
{arg: "cannon/test1", expected: runner.RunConfig{GameType: gameTypes.CannonGameType, Name: "test1"}},
{arg: "cannon/test1/0x1234", expected: runner.RunConfig{GameType: gameTypes.CannonGameType, Name: "test1", Prestate: common.HexToHash("0x1234")}},
{arg: "cannon/test1/0xinvalid", err: ErrInvalidPrestateHash},
{arg: "cannon/test1/develop.bin.gz", expected: runner.RunConfig{TraceType: types.TraceTypeCannon, Name: "test1", PrestateFilename: "develop.bin.gz"}},
{arg: "cannon/test1/develop.bin.gz", expected: runner.RunConfig{GameType: gameTypes.CannonGameType, Name: "test1", PrestateFilename: "develop.bin.gz"}},
}
for _, test := range tests {
test := test
Expand Down
54 changes: 27 additions & 27 deletions op-challenger/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
"time"

"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/vm"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/types"
gameTypes "github.com/ethereum-optimism/optimism/op-challenger/game/types"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/ethereum-optimism/optimism/op-service/oppprof"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"
)

var (
ErrMissingTraceType = errors.New("no supported trace types specified")
ErrMissingGameType = errors.New("no supported game types specified")
ErrMissingDatadir = errors.New("missing datadir")
ErrMaxConcurrencyZero = errors.New("max concurrency must not be 0")
ErrMissingL2Rpc = errors.New("missing L2 rpc url")
Expand Down Expand Up @@ -80,7 +80,7 @@ type Config struct {

SelectiveClaimResolution bool // Whether to only resolve claims for the claimants in AdditionalBondClaimants union [TxSender.From()]

TraceTypes []types.TraceType // Type of traces supported
GameTypes []gameTypes.GameType // Type of games supported

RollupRpc string // L2 Rollup RPC Url
SupervisorRPC string // L2 supervisor RPC URL
Expand Down Expand Up @@ -129,7 +129,7 @@ func NewInteropConfig(
supervisorRpc string,
l2Rpcs []string,
datadir string,
supportedTraceTypes ...types.TraceType,
supportedGameTypes ...gameTypes.GameType,
) Config {
return Config{
L1EthRpc: l1EthRpc,
Expand All @@ -140,7 +140,7 @@ func NewInteropConfig(
MaxConcurrency: uint(runtime.NumCPU()),
PollInterval: DefaultPollInterval,

TraceTypes: supportedTraceTypes,
GameTypes: supportedGameTypes,

MaxPendingTx: DefaultMaxPendingTx,

Expand All @@ -151,7 +151,7 @@ func NewInteropConfig(
Datadir: datadir,

Cannon: vm.Config{
VmType: types.TraceTypeCannon,
VmType: gameTypes.CannonGameType,
L1: l1EthRpc,
L1Beacon: l1BeaconApi,
L2s: l2Rpcs,
Expand All @@ -161,7 +161,7 @@ func NewInteropConfig(
BinarySnapshots: true,
},
CannonKona: vm.Config{
VmType: types.TraceTypeCannonKona,
VmType: gameTypes.CannonKonaGameType,
L1: l1EthRpc,
L1Beacon: l1BeaconApi,
L2s: l2Rpcs,
Expand All @@ -171,7 +171,7 @@ func NewInteropConfig(
BinarySnapshots: true,
},
Asterisc: vm.Config{
VmType: types.TraceTypeAsterisc,
VmType: gameTypes.AsteriscGameType,
L1: l1EthRpc,
L1Beacon: l1BeaconApi,
L2s: l2Rpcs,
Expand All @@ -180,7 +180,7 @@ func NewInteropConfig(
BinarySnapshots: true,
},
AsteriscKona: vm.Config{
VmType: types.TraceTypeAsteriscKona,
VmType: gameTypes.AsteriscKonaGameType,
L1: l1EthRpc,
L1Beacon: l1BeaconApi,
L2s: l2Rpcs,
Expand All @@ -199,7 +199,7 @@ func NewConfig(
l2RollupRpc string,
l2EthRpc string,
datadir string,
supportedTraceTypes ...types.TraceType,
supportedGameTypes ...gameTypes.GameType,
) Config {
return Config{
L1EthRpc: l1EthRpc,
Expand All @@ -210,7 +210,7 @@ func NewConfig(
MaxConcurrency: uint(runtime.NumCPU()),
PollInterval: DefaultPollInterval,

TraceTypes: supportedTraceTypes,
GameTypes: supportedGameTypes,

MaxPendingTx: DefaultMaxPendingTx,

Expand All @@ -221,7 +221,7 @@ func NewConfig(
Datadir: datadir,

Cannon: vm.Config{
VmType: types.TraceTypeCannon,
VmType: gameTypes.CannonGameType,
L1: l1EthRpc,
L1Beacon: l1BeaconApi,
L2s: []string{l2EthRpc},
Expand All @@ -231,7 +231,7 @@ func NewConfig(
BinarySnapshots: true,
},
CannonKona: vm.Config{
VmType: types.TraceTypeCannonKona,
VmType: gameTypes.CannonKonaGameType,
L1: l1EthRpc,
L1Beacon: l1BeaconApi,
L2s: []string{l2EthRpc},
Expand All @@ -241,7 +241,7 @@ func NewConfig(
BinarySnapshots: true,
},
Asterisc: vm.Config{
VmType: types.TraceTypeAsterisc,
VmType: gameTypes.AsteriscGameType,
L1: l1EthRpc,
L1Beacon: l1BeaconApi,
L2s: []string{l2EthRpc},
Expand All @@ -250,7 +250,7 @@ func NewConfig(
BinarySnapshots: true,
},
AsteriscKona: vm.Config{
VmType: types.TraceTypeAsteriscKona,
VmType: gameTypes.AsteriscKonaGameType,
L1: l1EthRpc,
L1Beacon: l1BeaconApi,
L2s: []string{l2EthRpc},
Expand All @@ -262,8 +262,8 @@ func NewConfig(
}
}

func (c Config) TraceTypeEnabled(t types.TraceType) bool {
return slices.Contains(c.TraceTypes, t)
func (c Config) GameTypeEnabled(t gameTypes.GameType) bool {
return slices.Contains(c.GameTypes, t)
}

func (c Config) Check() error {
Expand All @@ -279,16 +279,16 @@ func (c Config) Check() error {
if c.GameFactoryAddress == (common.Address{}) {
return ErrMissingGameFactoryAddress
}
if len(c.TraceTypes) == 0 {
return ErrMissingTraceType
if len(c.GameTypes) == 0 {
return ErrMissingGameType
}
if c.Datadir == "" {
return ErrMissingDatadir
}
if c.MaxConcurrency == 0 {
return ErrMaxConcurrencyZero
}
if c.TraceTypeEnabled(types.TraceTypeSuperCannon) || c.TraceTypeEnabled(types.TraceTypeSuperPermissioned) {
if c.GameTypeEnabled(gameTypes.SuperCannonGameType) || c.GameTypeEnabled(gameTypes.SuperPermissionedGameType) {
if c.SupervisorRPC == "" {
return ErrMissingSupervisorRpc
}
Expand All @@ -300,15 +300,15 @@ func (c Config) Check() error {
return err
}
}
if c.TraceTypeEnabled(types.TraceTypeCannon) || c.TraceTypeEnabled(types.TraceTypePermissioned) {
if c.GameTypeEnabled(gameTypes.CannonGameType) || c.GameTypeEnabled(gameTypes.PermissionedGameType) {
if c.RollupRpc == "" {
return ErrMissingRollupRpc
}
if err := c.validateBaseCannonOptions(); err != nil {
return err
}
}
if c.TraceTypeEnabled(types.TraceTypeSuperCannonKona) {
if c.GameTypeEnabled(gameTypes.SuperCannonKonaGameType) {
if c.SupervisorRPC == "" {
return ErrMissingSupervisorRpc
}
Expand All @@ -320,15 +320,15 @@ func (c Config) Check() error {
return err
}
}
if c.TraceTypeEnabled(types.TraceTypeCannonKona) {
if c.GameTypeEnabled(gameTypes.CannonKonaGameType) {
if c.RollupRpc == "" {
return ErrMissingRollupRpc
}
if err := c.validateBaseCannonKonaOptions(); err != nil {
return err
}
}
if c.TraceTypeEnabled(types.TraceTypeAsterisc) {
if c.GameTypeEnabled(gameTypes.AsteriscGameType) {
if c.RollupRpc == "" {
return ErrMissingRollupRpc
}
Expand All @@ -345,15 +345,15 @@ func (c Config) Check() error {
return ErrMissingAsteriscInfoFreq
}
}
if c.TraceTypeEnabled(types.TraceTypeAsteriscKona) {
if c.GameTypeEnabled(gameTypes.AsteriscKonaGameType) {
if c.RollupRpc == "" {
return ErrMissingRollupRpc
}
if err := c.validateBaseAsteriscKonaOptions(); err != nil {
return err
}
}
if c.TraceTypeEnabled(types.TraceTypeSuperAsteriscKona) {
if c.GameTypeEnabled(gameTypes.SuperAsteriscKonaGameType) {
if c.SupervisorRPC == "" {
return ErrMissingSupervisorRpc
}
Expand All @@ -365,7 +365,7 @@ func (c Config) Check() error {
return err
}
}
if c.TraceTypeEnabled(types.TraceTypeAlphabet) || c.TraceTypeEnabled(types.TraceTypeFast) {
if c.GameTypeEnabled(gameTypes.AlphabetGameType) || c.GameTypeEnabled(gameTypes.FastGameType) {
if c.RollupRpc == "" {
return ErrMissingRollupRpc
}
Expand Down
Loading