optimism

op-challenger

The op-challenger is a modular op-stack challenge agent written in golang for dispute games including, but not limited to, attestation games, fault games, and validity games. To learn more about dispute games, visit the fault proof specs.

Quickstart

To build the op-challenger, run just op-challenger. To view a list of available commands and options, run ./bin/op-challenger --help.

Usage

op-challenger is configurable via command line flags and environment variables. The help menu shows the available config options and can be accessed by running ./op-challenger --help.

Running with Cannon on Local Devnet

To run op-challenger against a local devnet, first start a local devnet that exposes the simple-devnet enclave.

Then build the op-challenger with just op-challenger.

Run the op-challenger with:

DISPUTE_GAME_FACTORY=$(jq -r .DisputeGameFactoryProxy .devnet/addresses.json)
./op-challenger/bin/op-challenger \
  --game-types cannon \
  --l1-eth-rpc http://localhost:8545 \
  --rollup-rpc http://localhost:9546 \
  --game-factory-address $DISPUTE_GAME_FACTORY \
  --datadir temp/challenger-data \
  --cannon-rollup-config .devnet/rollup.json  \
  --cannon-l2-genesis .devnet/genesis-l2.json \
  --cannon-bin ./cannon/bin/cannon \
  --cannon-server ./op-program/bin/op-program \
  --cannon-prestate ./op-program/bin/prestate.bin.gz \
  --l2-eth-rpc http://localhost:9545 \
  --mnemonic "test test test test test test test test test test test junk" \
  --hd-path "m/44'/60'/0'/0/8" \
  --num-confirmations 1

The mnemonic and hd-path above is a prefunded address on the devnet. The challenger will monitor dispute games and respond to any invalid claims by posting the correct trace as the counter-claim. The commands below can then be used to create and interact with games.

Devnet Management Commands

# Check status
kurtosis enclave ls
kurtosis enclave inspect simple-devnet

# View logs from specific services
kurtosis service logs simple-devnet op-challenger-challenger-2151908 # Adjust names as needed
kurtosis service logs simple-devnet op-node-2151908-node0 # Adjust names as needed

# Stop and clean up when done
kurtosis enclave stop simple-devnet
kurtosis enclave rm simple-devnet

Subcommands

The op-challenger has a few subcommands to interact with on-chain fault dispute games. The subcommands support game creation, performing game moves, and viewing fault dispute game data. They should not be used in production and are intended to provide convenient manual testing.

create-game

./bin/op-challenger create-game \
  --l1-eth-rpc <L1_ETH_RPC> \
  --game-factory-address <GAME_FACTORY_ADDRESS> \
  --output-root <OUTPUT_ROOT> \
  --l2-block-num <L2_BLOCK_NUM> \
  <SIGNER_ARGS>

Starts a new fault dispute game that disputes the latest output proposal in the L2 output oracle.

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.

move

The move subcommand can be run with either the --attack or --defend flag, but not both.

./bin/op-challenger move \
  --l1-eth-rpc <L1_ETH_RPC> \
  --game-address <GAME_ADDRESS> \
  --attack \
  --parent-index <PARENT_INDEX> \
  --claim <CLAIM> \
  <SIGNER_ARGS>

Performs a move to either attack or defend the latest claim in the specified game.

resolve-claim

./bin/op-challenger resolve-claim \
  --l1-eth-rpc <L1_ETH_RPC> \
  --game-address <GAME_ADDRESS> \
  --claim <CLAIM_INDEX> \
  <SIGNER_ARGS>

Resolves a claim in a dispute game. Note that this will fail if the claim has already been resolved or if the claim is not yet resolvable. If the claim is resolved successfully, the result is printed.

resolve

./bin/op-challenger resolve \
  --l1-eth-rpc <L1_ETH_RPC> \
  --game-address <GAME_ADDRESS> \
  <SIGNER_ARGS>

Resolves a dispute game. Note that this will fail if the dispute game has already been resolved or if the clocks have not yet expired and further moves are possible. If the game is resolved successfully, the result is printed.

list-games

./bin/op-challenger list-games \
  --l1-eth-rpc <L1_ETH_RPC> \
  --game-factory-address <GAME_FACTORY_ADDRESS>

Prints the games created by the game factory along with their current status.

For known networks, the --game-factory-address option can be replaced by --network. See the --help output for a list of predefined networks.

list-claims

./bin/op-challenger list-claims \
  --l1-eth-rpc <L1_ETH_RPC> \
  --game-address <GAME_ADDRESS>

Prints the list of current claims in a dispute game.

run-trace

./bin/op-challenger run-trace \
  --network=<NETWORK_NAME> \
  --l1-eth-rpc=<L1_ETH_RPC> \
  --l1-beacon=<L1_BEACON> \
  --l2-eth-rpc=<L2_ETH_RPC> \
  --rollup-rpc=<ROLLUP_RPC> \
  --datadir=<DATA_DIR> \
  --prestates-url=<PRESTATES_URL> \
  --run=<RUN_CONFIG>

Testing utility that continuously runs the specified trace providers against real chain data. The trace providers can be configured with multiple different prestates. This allows testing both the current and potential future prestates with 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 gameType/name/prestateHash where gameType is the game type to use with the prestate (e.g cannon or cannon-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 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.