Skip to content

Commit

Permalink
add mainnetv2 runbook
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueShells authored Mar 16, 2024
1 parent 07ef560 commit 17984f6
Show file tree
Hide file tree
Showing 2 changed files with 259 additions and 0 deletions.
112 changes: 112 additions & 0 deletions docker-compose-mainnetv2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
version: '3.4'

x-healthcheck: &healthcheck
test: [ "CMD", "curl", "-sf", "http://localhost:8545" ]
interval: 5s
timeout: 5s
retries: 3
start_period: 30s

services:
op-geth:
image: mantlenetworkio/op-geth:v1.0.0-alpha.1
deploy:
resources:
limits:
cpus: '4'
memory: 8000M
reservations:
cpus: '4'
memory: 8000M
restart_policy:
condition: on-failure
extra_hosts:
- "host.docker.internal:host-gateway"
entrypoint: geth
command:
- --datadir=/db
- --verbosity=3
- --port=30300
- --http
- --http.corsdomain=*
- --http.vhosts=*
- --http.addr=0.0.0.0
- --http.port=8545
- --http.api=web3,eth,debug,txpool,net
- --ws
- --ws.addr=0.0.0.0
- --ws.port=8546
- --ws.origins=*
- --ws.api=web3,eth,debug,txpool,net
- --syncmode=full
- --maxpeers=0
- --networkid=5003
- --rpc.allow-unprotected-txs
- --authrpc.addr=0.0.0.0
- --authrpc.port=8551
- --authrpc.vhosts=*
- --authrpc.jwtsecret=/secret/jwt_secret_txt
- --pprof
- --pprof.addr=0.0.0.0
- --pprof.port=6060
- --gcmode=archive
- --metrics
- --metrics.addr=0.0.0.0
- --metrics.port=9001
volumes:
- ./mainnet/secret:/secret/
- ./data/mainnet-geth:/db/geth/
ports:
- ${VERIFIER_HTTP_PORT:-8545}:8545
- ${VERIFIER_WS_PORT:-8546}:8546
- ${VERIFIER_AUTH_PORT:-8551}:8551
op-node:
image: mantlenetworkio/op-node:v1.0.0-alpha.1
deploy:
resources:
limits:
cpus: '4'
memory: 8000M
reservations:
cpus: '4'
memory: 8000M
restart_policy:
condition: on-failure
depends_on:
- op-geth
volumes:
- ./mainnet/secret:/secret
- ./mainnet/rollup.json:/config/rollup.json
environment:
OP_NODE_L1_ETH_RPC: 'wss://mainnet.gateway.tenderly.co' #change this
OP_NODE_L2_ENGINE_RPC: 'http://op-geth:8551'
OP_NODE_L2_ENGINE_AUTH: /secret/jwt_secret_txt
OP_NODE_ROLLUP_CONFIG: '/config/rollup.json'
OP_NODE_P2P_PRIV_PATH: /secret/p2p_node_key_txt
OP_NODE_VERIFIER_L1_CONFS: '3'
OP_NODE_RPC_ADDR: '0.0.0.0'
OP_NODE_RPC_PORT: 8545
OP_NODE_P2P_LISTEN_IP: '0.0.0.0'
OP_NODE_P2P_LISTEN_TCP_PORT: 9003
OP_NODE_P2P_LISTEN_UDP_PORT: 9003
OP_NODE_P2P_PEER_SCORING: 'light'
OP_NODE_P2P_PEER_BANNING: 'true'
OP_NODE_METRICS_ENABLED: 'true'
OP_NODE_METRICS_ADDR: '0.0.0.0'
OP_NODE_METRICS_PORT: 7300
OP_NODE_PPROF_ENABLED: 'true'
OP_NODE_PPROF_PORT: 6060
OP_NODE_PPROF_ADDR: '0.0.0.0'
OP_NODE_P2P_DISCOVERY_PATH: '/op-node/opnode_discovery_db'
OP_NODE_P2P_PEERSTORE_PATH: '/op-node/opnode_peerstore_db'
OP_NODE_INDEXER_SOCKET: 'da-indexer-api.mantle.xyz:443'
OP_NODE_INDEXER_ENABLE: 'true'
OP_NODE_L2_BACKUP_UNSAFE_SYNC_RPC: https://rpc.mantle.xyz
OP_NODE_P2P_STATIC: '/ip4/18.139.118.7/tcp/9003/p2p/16Uiu2HAkywYkvLRUH2MXbD6tSoT3jSMAzTWTp1aDijxpXQXxG6VM'
OP_NODE_SEQUENCER_ENABLED: 'false'
OP_NODE_P2P_AGENT: 'mantle'
OP_NODE_L2_ENGINE_SYNC_ENABLED: 'true'
OP_NODE_L2_SKIP_SYNC_START_CHECK: 'true'
OP_NODE_P2P_SYNC_REQ_RESP: 'true'
ports:
- ${NODE_RPC_PORT:-9545}:8545
147 changes: 147 additions & 0 deletions run-node-mainnetv2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Simple Mantle Node

## Required Software

- [docker](https://docs.docker.com/engine/install/)
- [node](https://nodejs.org/en/download/)
- [foundry](https://github.com/foundry-rs/foundry/releases)

## Recommended Hardware

- 16GB+ RAM
- 8C+ CPU
- 500GB+ disk (HDD works for now, SSD is better)
- 10mb/s+ download

## Installation and Setup Instructions


### Init to generate the 'jwt_secret_txt' file and the 'p2p_node_key_txt'

```sh
cd networks/


mkdir -p mainnet/secret

node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" > mainnet/secret/jwt_secret_txt

cast w n |grep -i "Private Key" |awk -F ": " '{print $2}' |sed 's/0x//' > mainnet/secret/p2p_node_key_txt
```

### Operating the Node

#### Download latest snapshot from mantle

We recommend that you start the node with latest shapshot, so that you don't need to wait a long time to sync data.

example:

```sh
mkdir -p ./data/mainnet-geth

# latest snapshot tarball
linux:
date=$(date -d "2 days ago" +%Y%m%d)
mac:
date=$(date -v-2d +%Y%m%d)

tarball="$date-mainnet-chaindata.tar"

wget https://s3.ap-southeast-1.amazonaws.com/snapshot.mainnet.mantle.xyz/${tarball}

tar xf ${tarball} -C ./data/mainnet-geth

```

Check the data was unarchived successfully:
```sh
$ ls ./data/mainnet-geth
chaindata
```

#### Start

```sh
docker-compose -f docker-compose-mainnet.yml up -d
```

Will start the node in a detatched shell (`-d`), meaning the node will continue to run in the background.
You will need to run this again if you ever turn your machine off.

The first time you start the node it synchronizes from regenesis (December 1th, 2022) to the present.
This process takes hours.

#### Stop

```sh
docker-compose -f docker-compose-mainnet.yml down
```

Will shut down the node without wiping any volumes.
You can safely run this command and then restart the node again.

#### Wipe

```sh
docker-compose -f docker-compose-mainnet.yml down -v
```

Will completely wipe the node by removing the volumes that were created for each container.
Note that this is a destructive action, be very careful!

#### Logs

```sh
docker-compose logs <service name>
```

Will display the logs for a given service.
You can also follow along with the logs for a service in real time by adding the flag `-f`.

The available services are:
- [`op-geth`](#mantle-node)
- [`op-node`](#mantle-node)


#### Update

```sh
docker-compose pull
```

Will download the latest images for any services where you haven't hard-coded a service version.
Updates are regularly pushed to improve the stability of Mantle nodes or to introduce new quality-of-life features like better logging and better metrics.
I recommend that you run this command every once in a while (once a week should be more than enough).

## How To Check If The Deployment Is Successful

### Check Service

If the service status is 'up,' it means that the service has started without any issues.

```sh
docker-compose -f docker-compose-mainnet.yml ps
```

### Check Data

Use the command 'cast bn' to execute multiple times and check if the height increases.

example:

```sh
cast bn
cast bn --rpc-url https://rpc.mainnet.mantle.xyz
```

Use the command 'cast rpc optimism_syncStatus' to execute multiple times and check if the safe_l2 and inalized_l2 increases.
It may need to be increased after thirty minutes

example:

```sh
cast rpc optimism_syncStatus --rpc-url localhost:9545 |jq .finalized_l2.number

cast rpc optimism_syncStatus --rpc-url localhost:9545 |jq .safe_l2.number
```

0 comments on commit 17984f6

Please sign in to comment.