To learn more about what the Challenger does, check out the Challenger page.

Running the Challenger

1

Initialize Challenger Bot

To initialize the Challenger bot, use the following command:

opinitd init challenger
2

Configuration

To configure the Challenger, fill in the values in the ~/.opinit/challenger.json file.

challenger.json
{
  "version": 1,
  "listen_address": "localhost:3001",
  "l1_node": {
    "chain_id": "testnet-l1-1",
    "bech32_prefix": "init",
    "rpc_address": "tcp://localhost:26657",
  },
  "l2_node": {
    "chain_id": "testnet-l2-1",
    "bech32_prefix": "init",
    "rpc_address": "tcp://localhost:27657",
  },
  "l2_start_height": 0,
}
FieldDescription
versionIndicates the version of the OPinit spec (basically 1).
listen_addressThe address where the Challenger bot listens for incoming requests.
l1_nodeInformation about the L1 node, including chain ID and RPC address. See the L1 Networks page for more information.
l2_nodeInformation about the L2 node, including chain ID and RPC address. These configs are what you set when deploying the rollup
l2_start_heightChallenger automatically sets the starting height for challenge processing. If the value is already stored in the db, this config is ignored.
3

Start Bot

To start the bot, use the following command:

opinitd start challenger

The following options can be set:

OptionDescriptionDefault Value
--log-levelSets the log levelinfo
--polling-intervalSets the polling interval100ms
--configSets the config file name[bot-name].json
--homeSets the home directory~/.opinit

Queries

You can query the Challenger bot to get its status or view pending events and challenges:

Status

You can query the Challenger bot to get its status:

curl localhost:3001/status
{
  "bridge_id": 0,
  "host": {
    "node": {
      "last_block_height": 0
    },
    "last_output_index": 0,
    "last_output_time": "",
    "num_pending_events": {}
  },
  "child": {
    "node": {
      "last_block_height": 0
    },
    "last_updated_oracle_height": 0,
    "last_finalized_deposit_l1_block_height": 0,
    "last_finalized_deposit_l1_sequence": 0,
    "last_withdrawal_l2_sequence": 0,
    "working_tree_index": 0,
    "finalizing_block_height": 0,
    "last_output_submission_time": "",
    "next_output_submission_time": "",
    "num_pending_events": {}
  },
  "latest_challenges": []
}

Challenges

You can query the Challenger bot to view all challenges. The query response are paginated, with each page containing 100 challenges.

To retrieve a specific page of challenges, use the following command:

curl localhost:3001/challenges/{page}
[
  {
    "event_type": "Oracle",
    "id": {
      "type": 2,
      "id": 136
    },
    "log": "event timeout: Oracle{L1Height: 136, Data: nUYSP4e3jTUBk33jFSYuWW28U+uTO+g3IO5/iZfbDTo, Time: 2024-09-11 06:01:21.257012 +0000 UTC}",
    "timestamp": "2024-09-11T06:05:21.284479Z"
  },
]

Pending Events

Each event or transaction processed in a block is saved as a pending event. These events are processed atomically, meaning they are either fully processed or rolled back in case of an error. If a pending event matches a processed event or the event exceeds its timeout, a Challenge is created and stored in the database for further action.

You can query the Challenger bot to view the pending events on the host (L1) and child chains (L2):

curl localhost:3001/pending_events/host
[
  {
    "event_type": "Output",
    "l2_block_number": 2394,
    "output_index": 7,
    "output_root": "Lx+k0GuHi6jPcO5yA6dUwI/l0h4b25awy973F6CirYs=",
    "time": "2024-09-11T06:28:54.186941Z",
    "timeout": false
  }
]
curl localhost:3001/pending_events/child
[
  {
    "event_type": "Oracle",
    "l1_height": 1025,
    "data": "49Y7iryZGsQYzpao+rxR2Vfaz6owp3s5vlPnkboXwr0=",
    "time": "2024-09-11T06:31:28.657245Z",
    "timeout": false
  }
]

Resetting The Bot Database

If the database becomes corrupted or is moved to a new one, you need to initialize or reset it.

To reset the bot database, use the following command:

opinitd reset-db challenger