Skip to content

Commit

Permalink
Merge pull request #31 from initia-labs/feat/celestia
Browse files Browse the repository at this point in the history
impl celestia to batch submitter
  • Loading branch information
beer-1 authored Mar 25, 2024
2 parents 8e6f980 + 54a4d38 commit 778ba83
Show file tree
Hide file tree
Showing 20 changed files with 18,044 additions and 23,391 deletions.
5 changes: 5 additions & 0 deletions bots/.env_sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ L1_LCD_URI=http://localhost:1317
L1_RPC_URI=http://localhost:26657
L2_LCD_URI=http://localhost:1318
L2_RPC_URI=http://localhost:26667
CELESTIA_LIGHT_NODE_RPC_URI=http://127.0.0.1:26658
CELESTIA_RPC_URI=http://localhost:26667
CELESTIA_TOKEN_AUTH=eyJ...
CELESTIA_NAMESPACE_ID=00000000000000000000000000000000000000000000000123456789
PUBLISH_BATCH_TARGET=celestia
BRIDGE_ID=1

# setting for slack (optional)
Expand Down
126 changes: 68 additions & 58 deletions bots/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ Initia Optimistic Rollup Bots.

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.

```typescript
```typescript
import { MsgCreateBridge, BridgeConfig, Duration } from '@initia/initia.js';

const bridgeConfig = new BridgeConfig(
challenger.key.accAddress,
outputSubmitter.key.accAddress,
Duration.fromString(submissionInterval.toString()),
Duration.fromString(finalizedTime.toString()),
new Date(),
this.metadata
challenger.key.accAddress,
outputSubmitter.key.accAddress,
Duration.fromString(submissionInterval.toString()),
Duration.fromString(finalizedTime.toString()),
new Date(),
this.metadata
);
const msg = new MsgCreateBridge(executor.key.accAddress, bridgeConfig);
```

### Step2. 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.
> 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 @@ -57,61 +57,67 @@ For example, if you want to set `.env` for `executor`, you should name it as `.e

> Note that if `EXECUTOR_L1_MONITOR_HEIGHT` and `EXECUTOR_L2_MONITOR_HEIGHT` are not set, `executor` will start monitoring from height stored on `state` table. If you want to start monitoring from specific height, you should set them in `.env.executor` file.

- `.env.output`

| Name | Description | Default |
| ------------------------- | ------------------------------------------------------ | -------------------------------- |
| L1_LCD_URI | L1 node LCD URI | <http://127.0.0.1:1317> |
| 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) | '' |
| Name | Description | Default |
| ------------------------- | ------------------------------------------ | ------------------------ |
| L1_LCD_URI | L1 node LCD URI | <http://127.0.0.1:1317> |
| 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`

| Name | Description | Default |
| ------------------------- | ------------------------------------------------------ | -------------------------------- |
| L1_LCD_URI | L1 node LCD URI | <http://127.0.0.1:1317> |
| L1_RPC_URI | L1 node RPC URI | <http://127.0.0.1:26657> |
| L2_LCD_URI | L2 node LCD URI | <http://127.0.0.1:1317> |
| L2_RPC_URI | L2 node RPC URI | <http://127.0.0.1:26657> |
| BRIDGE_ID | Bridge ID | '' |
| BATCH_PORT | Batch submitter port | 5001 |
| BATCH_SUBMITTER_MNEMONIC | Mnemonic seed for submitter | '' |
| SLACK_WEB_HOOK | Slack web hook for notification (optional) | '' |
| Name | Description | Default |
| --------------------------- | ------------------------------------------------------------ | ------------------------ |
| L1_LCD_URI | L1 node LCD URI | <http://127.0.0.1:1317> |
| L1_RPC_URI | L1 node RPC URI | <http://127.0.0.1:26657> |
| L2_LCD_URI | L2 node LCD URI | <http://127.0.0.1:1317> |
| L2_RPC_URI | L2 node RPC URI | <http://127.0.0.1:26657> |
| BRIDGE_ID | Bridge ID | '' |
| BATCH_PORT | Batch submitter port | 5001 |
| BATCH_SUBMITTER_MNEMONIC | Mnemonic seed for submitter | '' |
| SLACK_WEB_HOOK | Slack web hook for notification (optional) | '' |
| CELESTIA_RPC_URI | Celestia node RPC URI | <http://127.0.0.1:26657> |
| CELESTIA_LIGHT_NODE_RPC_URI | Celestia light node RPC URI | <http://127.0.0.1:26658> |
| CELESTIA_TOKEN_AUTH | Celestia light node admin token | '' |
| CELESTIA_NAMESPACE_ID | Celestia namespace id | '' |
| CELESTIA_GAS_PRICE | Celestia utia gas price | 0.01 |
| PUBLISH_BATCH_TARGET | Target chain to publish batch (supports: ['l1', 'celestia']) | '' |

- `.env.challenger`

| Name | Description | Default |
| ------------------------- | ------------------------------------------------------ | -------------------------------- |
| L1_LCD_URI | L1 node LCD URI | <http://127.0.0.1:1317> |
| L1_RPC_URI | L1 node RPC URI | <http://127.0.0.1:26657> |
| L2_LCD_URI | L2 node LCD URI | <http://127.0.0.1:1317> |
| L2_RPC_URI | L2 node RPC URI | <http://127.0.0.1:26657> |
| BRIDGE_ID | Bridge ID | '' |
| CHALLENGER_MNEMONIC | Mnemonic seed for challenger | '' |
| DELETE_OUTPUT_PROPOSAL | Enable delete output proposal instantly | '' |
| SLACK_WEB_HOOK | Slack web hook for notification (optional) | '' |

| Name | Description | Default |
| ---------------------- | ------------------------------------------ | ------------------------ |
| L1_LCD_URI | L1 node LCD URI | <http://127.0.0.1:1317> |
| L1_RPC_URI | L1 node RPC URI | <http://127.0.0.1:26657> |
| L2_LCD_URI | L2 node LCD URI | <http://127.0.0.1:1317> |
| L2_RPC_URI | L2 node RPC URI | <http://127.0.0.1:26657> |
| BRIDGE_ID | Bridge ID | '' |
| CHALLENGER_MNEMONIC | Mnemonic seed for challenger | '' |
| DELETE_OUTPUT_PROPOSAL | Enable delete output proposal instantly | '' |
| SLACK_WEB_HOOK | Slack web hook for notification (optional) | '' |

### Step3. Run Bots

- Install dependencies
```bash
npm install
```

```bash
npm install
```

- Bridge Executor

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

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

```bash
npm run executor
```

- Output Submitter

Expand All @@ -122,29 +128,33 @@ Output submitter will get the L2 output results from executor and submit it to L
1. Configure `.env.output` file
2. Run output submitter bot
```bash
npm run output
```

```bash
npm run output
```

- Batch Submitter

Batch submitter is a background process that submits transaction batches to the BatchInbox module of L1.
Batch submitter is a background process that submits transaction batches to the BatchInbox module of L1 or Celestia.

> **NOTE** To run celestia batch submitter, you have to set [celestia light node](https://docs.celestia.org/nodes/light-node)
1. Configure `.env.batch` file
2. Run batch submitter bot
```bash
npm run batch
```

```bash
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.
> **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
```

```bash
npm run challenger
```
Loading

0 comments on commit 778ba83

Please sign in to comment.