Skip to content

Commit

Permalink
Merge pull request #26 from initia-labs/docs/readme
Browse files Browse the repository at this point in the history
add explanation for setting
  • Loading branch information
beer-1 authored Feb 26, 2024
2 parents 77c1e0b + 6a4628f commit bedd1a7
Showing 1 changed file with 40 additions and 31 deletions.
71 changes: 40 additions & 31 deletions bots/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ Initia Optimistic Rollup Bots.

## How to use

## Create Bridge
### Prerequisites

- Postgres 14+
- Node.js 16+
- Node LCD/RPC (L1 and L2)

### Step1. Create Bridge

Before running rollup bots, you should create bridge between L1 and L2. If you use `initia.js`, you can create bridge using `MsgCreateBridge` message as follows.

Expand All @@ -27,7 +33,12 @@ const bridgeConfig = new BridgeConfig(
const msg = new MsgCreateBridge(executor.key.accAddress, bridgeConfig);
```

## Configuration
### Step2. Configuration

You should set `.env` file for each bot in `bots/worker`. To transfer assets between L1 and L2, you should run `executor` and `output submitter` at least.

> In OPinit bots, we use [.dotenv](https://www.npmjs.com/package/dotenv) for managing environment variable for development. If you want to set `.env` by worker, you should name it as `.env.{WORKER_NAME}` and set `WORKER_NAME` in [`executor`, `output`, `batch`, `challenger`].
For example, if you want to set `.env` for `executor`, you should name it as `.env.executor` and set `WORKER_NAME=executor` in local environment. `.env` files should be located in `OPinit/bots` directory.

- `.env.executor`

Expand All @@ -50,6 +61,7 @@ const msg = new MsgCreateBridge(executor.key.accAddress, bridgeConfig);
| L1_RPC_URI | L1 node RPC URI | <http://127.0.0.1:26657> |
| BRIDGE_ID | Bridge ID | '' |
| OUTPUT_SUBMITTER_MNEMONIC | Mnemonic seed for output submitter | '' |
| EXECUTOR_URI | Executor URI | <http://localhost:5000> |
| SLACK_WEB_HOOK | Slack web hook for notification (optional) | '' |

- `.env.batch`
Expand Down Expand Up @@ -79,57 +91,54 @@ const msg = new MsgCreateBridge(executor.key.accAddress, bridgeConfig);
| SLACK_WEB_HOOK | Slack web hook for notification (optional) | '' |


> In OPinit bots, we use [.dotenv](https://www.npmjs.com/package/dotenv) for managing environment variable for development. If you want to set `.env` by worker, you should name it as `.env.{WORKER_NAME}` and set `WORKER_NAME` in [`executor`, `output`, `batch`, `challenger`].
For example, if you want to set `.env` for `executor`, you should name it as `.env.executor` and set `WORKER_NAME=executor` in local environment.

## Bridge Executor

Bridge executor is a bot that monitor L1, L2 node and execute bridge transaction. It will execute following steps.
### Step3. Run Bots

1. Set bridge executor mnemonic on `.env`.
- Install dependencies
```bash
export EXECUTOR_MNEMONIC="..."
```
2. Run executor bot
```bash
npm run executor
npm install
```

## Batch Submitter
- Bridge Executor

Batch submitter is a background process that submits transaction batches to the BatchInbox module of L1.
Bridge executor is a bot that monitor L1, L2 node and execute bridge transaction. It will execute following steps.

1. Set batch submitter mnemonic on `.env`.
```bash
export BATCH_SUBMITTER_MNEMONIC="..."
```
2. Run batch submitter bot
1. Configure `.env.executor` file
2. Run executor bot
```bash
npm run batch
npm run executor
```

## Output Submitter
- Output Submitter

Output submitter is the component to store the L2 output root for block finalization.
Output submitter will get the L2 output results from executor and submit it to L1.

1. Set output submitter mnemonic on `.env`.
```bash
export OUTPUT_SUBMITTER_MNEMONIC="..."
```
> Before running output submitter, you should set `executor` first. It will get the L2 output results from `executor` and submit it to L1.

1. Configure `.env.output` file
2. Run output submitter bot
```bash
npm run output
```

## Challenger
- Batch Submitter

Challenger is an entity capable of deleting invalid output proposals from the output oracle.
Batch submitter is a background process that submits transaction batches to the BatchInbox module of L1.

1. Set challenger mnemonic on `.env`.
1. Configure `.env.batch` file
2. Run batch submitter bot
```bash
export CHALLENGER_MNEMONIC="..."
npm run batch
```

- Challenger

Challenger is an entity capable of deleting invalid output proposals from the output oracle.

> **NOTE**
> `challenger` should be independent from `executor` and `output submitter`. It will monitor the output oracle and delete invalid output proposals.

1. Configure `.env.challenger` file
2. Run challenger bot
```bash
npm run challenger
Expand Down

0 comments on commit bedd1a7

Please sign in to comment.