Skip to content

Commit

Permalink
remove docker setup
Browse files Browse the repository at this point in the history
wip

tested version

use base64 for buffer and impelemnt challenger

fix challenger

handle pagination output proposal

clean up

update bots readme

remove unnecessary file

fix readme

fix base port in readme

fix ports in sample and config.ts

update initia.js

apply blockchainData

fix to handle block

fix sync error

activate L2 Monitor

fix handle event

support stone-12-1

update dockerfile

implement resurrector

remove mnemonic
  • Loading branch information
JSHan94 committed Dec 13, 2023
1 parent 1cf667f commit 7006080
Show file tree
Hide file tree
Showing 88 changed files with 2,482 additions and 2,853 deletions.
5 changes: 0 additions & 5 deletions bots/.env

This file was deleted.

33 changes: 18 additions & 15 deletions bots/.envrc_sample
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
export TYPEORM_CONNECTION=postgres
export TYPEORM_HOST=localhost
export TYPEORM_USERNAME=jungsuhan
export TYPEORM_PASSWORD=jungsuhan
export TYPEORM_DATABASE=challenger
export TYPEORM_USERNAME=user
export TYPEORM_PASSWORD=password
export TYPEORM_DATABASE=rollup
export TYPEORM_PORT=5432
export TYPEORM_SYNCHRONIZE=true
export TYPEORM_LOGGING=false
export TYPEORM_ENTITIES=src/orm/*Entity.ts
export USE_LOG_FILE=false

export EXECUTOR_PORT=3000
export BATCH_PORT=3001
export EXECUTOR_PORT=5000
export BATCH_PORT=5001

export L1_LCD_URI=https://next-stone-rest.initia.tech
export L1_RPC_URI=https://next-stone-rpc.initia.tech
export L2_LCD_URI=http://localhost:1318
export L2_RPC_URI=http://localhost:26658
export L2ID=0x56ccf33c45b99546cd1da172cf6849395bbf8573::s10r1::Minitia
# l2 setup (need challenger, output, executor mnemonic)
export SUBMISSION_INTERVAL=10000
export FINALIZED_TIME=10000
export IBC_METADATA='channel-1'

export L1_LCD_URI=http://localhost:1317
export L1_RPC_URI=http://localhost:26657
export L2_LCD_URI=http://localhost:1318
export L2_RPC_URI=http://localhost:26667
export BRIDGE_ID=1

# executor config
export EXECUTOR_MNEMONIC='recycle sight world spoon leopard shine dizzy before public use jungle either arctic detail hawk output option august hedgehog menu keen night work become'
export EXECUTOR_MNEMONIC=''

# batch submitter config
export BATCH_SUBMITTER_MNEMONIC='broken umbrella tent include pet simple amount renew insect page sound whip shock dynamic deputy left outside churn lounge raise mirror toss annual fat'
export BATCH_SUBMITTER_MNEMONIC=''

# challenger config
export CHALLENGER_MNEMONIC='purity yard brush wagon note forest athlete seek offer clown surround cover present ski bargain obvious cute admit gloom text shaft super impose rubber'
export CHALLENGER_MNEMONIC=''

# output submitter config
export OUTPUT_SUBMITTER_MNEMONIC='airport hidden cake dry bleak alcohol enough tower charge cash modify feature analyst suffer bus oyster initial coffee wine plug paper damp sock afraid'
export EXECUTOR_URI=http://localhost:3000
export OUTPUT_SUBMITTER_MNEMONIC=''
1 change: 1 addition & 0 deletions bots/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ apidoc/
static/

.envrc
.env
build
logs/
testing/
Expand Down
3 changes: 0 additions & 3 deletions bots/.gitmodules

This file was deleted.

22 changes: 0 additions & 22 deletions bots/Dockerfile

This file was deleted.

155 changes: 65 additions & 90 deletions bots/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Initia Rollup JS
# OPinit Bots

Initia Optimistic Rollup Bots.

Expand All @@ -9,116 +9,91 @@ Initia Optimistic Rollup Bots.

## How to use

## Setup L2
## Create Bridge

Initializes the L2 id and op-bridge/output contracts.
You should set `submissionInterval`, `finalizedTime` and `l2StartBlockHeight` before initializing.
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.

```bash
export SUB_INTV=10
export FIN_TIME=10
export L2_HEIGHT=1
npm run l2setup
```
```typescript
import { MsgCreateBridge, BridgeConfig, Duration } from '@initia/initia.js';

## Bridge Executor
const bridgeConfig = new BridgeConfig(
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);
```

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

1. Publish L2 ID to L1
- L2 ID should be published under executor account
2. Initialize bridge contract on L1 with L2 ID
- Execute `initialize<L2ID>` entry function in `bridge.move`
3. Run executor bot
- Execute L1, L2 monitor in bridge executor
| Name | Description | Default |
| ------------------------- | ------------------------------------------------------ | -------------------------------- |
| L1_LCD_URI | L1 node LCD URI | <https://stone-rest.initia.tech> |
| L1_RPC_URI | L1 node RPC URI | <https://stone-rpc.initia.tech> |
| L2_LCD_URI | L2 node LCD URI | <https://minitia-rest.initia.tech>|
| L2_RPC_URI | L2 node RPC URI | <https://minitia-rpc.initia.tech>|
| BRIDGE_ID | Bridge ID | '' |
| EXECUTOR_PORT | Executor port | 5000 |
| BATCH_PORT | Batch submitter port | 5001 |
| EXECUTOR_MNEMONIC | Mnemonic seed for executor | '' |
| BATCH_SUBMITTER_MNEMONIC | Mnemonic seed for submitter | '' |
| OUTPUT_SUBMITTER_MNEMONIC | Mnemonic seed for output submitter | '' |
| CHALLENGER_MNEMONIC | Mnemonic seed for challenger | '' |

```bash
npm run executor
```
> In OPinit bots, we use [direnv](https://direnv.net) for managing environment variable for development. See [sample of .envrc](.envrc_sample).
- If you use pm2, you can run executor with following command.
## Bridge Executor

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

4. Register coin to bridge store and prepare deposit store
- Execute `register_token<L2ID, CoinType>`
5. Now you can deposit after registering coin is done
1. Set bridge executor mnemonic on `.envrc`.
```bash
export EXECUTOR_MNEMONIC="..."
```
2. Run executor bot
```bash
npm run executor
```

## Batch Submitter

Batch submitter is a background process that submits transaction batches to the BatchInbox module of L1.
You can run with following command.

```bash
npm run batch
```

If you use pm2,

```bash
pm2 start batch.json
```
1. Set batch submitter mnemonic on `.envrc`.
```bash
export BATCH_SUBMITTER_MNEMONIC="..."
```
2. Run batch submitter bot
```bash
npm run batch
```

## 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 using `propose_l2_output<L2ID>` in `output.move`.

```bash
npm run output
```
Output submitter will get the L2 output results from executor and submit it to L1.

If you use pm2,

```bash
pm2 start output.json
```
1. Set output submitter mnemonic on `.envrc`.
```bash
export OUTPUT_SUBMITTER_MNEMONIC="..."
```
2. Run output submitter bot
```bash
npm run output
```

## Challenger

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

```bash
npm run challenger
```

If you use pm2,

```bash
pm2 start challenger.json
```

## Configuration

| Name | Description | Default |
| ------------------------- | ------------------------------------------------------ | -------------------------------- |
| L1_LCD_URI | L1 node LCD URI | <https://stone-rest.initia.tech>' |
| L1_RPC_URI | L1 node RPC URI | <https://stone-rpc.initia.tech>' |
| L2_LCD_URI | L2 node LCD URI | <http://localhost:1317> |
| L2_RPC_URI | L2 node RPC URI | <http://localhost:26657> |
| L2ID | L2ID | '' |
| BATCH_PORT | Batch submitter port | 3000 |
| EXECUTOR_PORT | Executor port | 3001 |
| EXECUTOR_URI | Executor URI (for output submitter) | <http://localhost:3000> |
| EXECUTOR_MNEMONIC | Mnemonic seed for executor | '' |
| BATCH_SUBMITTER_MNEMONIC | Mnemonic seed for submitter | '' |
| OUTPUT_SUBMITTER_MNEMONIC | Mnemonic seed for output submitter | '' |
| CHALLENGER_MNEMONIC | Mnemonic seed for challenger | '' |

> In Batch Submitter, we use [direnv](https://direnv.net) for managing environment variable for development. See [sample of .envrc](.envrc_sample)

## Test

Docker and docker-compose are required to run integration test.

```bash
npm run test:integration
```

If you want to reset docker container, run following command.

```bash
./docker-compose-reset
```
1. Set challenger mnemonic on `.envrc`.
```bash
export CHALLENGER_MNEMONIC="..."
```
2. Run challenger bot
```bash
npm run challenger
```
11 changes: 0 additions & 11 deletions bots/batch.json

This file was deleted.

11 changes: 0 additions & 11 deletions bots/challenger.json

This file was deleted.

7 changes: 0 additions & 7 deletions bots/docker-compose-reset

This file was deleted.

73 changes: 0 additions & 73 deletions bots/docker-compose.yml

This file was deleted.

Loading

0 comments on commit 7006080

Please sign in to comment.