├── .env.mainnet.example ├── .env.testnet.example ├── .gitignore ├── README.md ├── docker-compose.yml ├── envs ├── mainnet │ └── op-geth.env └── testnet │ └── op-geth.env ├── jwt.txt └── scripts ├── op-geth-start.sh └── op-node-start.sh /.env.mainnet.example: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # ↓ REQUIRED ↓ # 3 | ############################################################################### 4 | 5 | # L1 node that the op-node will get chain data from 6 | OP_NODE__RPC_ENDPOINT= 7 | 8 | # replace the p2p private key with yours 9 | # you can generate a new one with `openssl rand -hex 32` 10 | P2P_PRIV_KEY= 11 | 12 | # you can find the correct image tag for the network at https://github.com/bnb-chain/op-geth 13 | OP_GETH_IMAGE_TAG=latest 14 | # you can find the correct image tag for the network at https://github.com/bnb-chain/opbnb 15 | OP_NODE_IMAGE_TAG=latest 16 | 17 | ############################################################################### 18 | # ↓ OPTIONAL ↓ # 19 | ############################################################################### 20 | PORT__OP_GETH= 21 | PORT__OP_NODE= 22 | PORT__OP_NODE_P2P= 23 | 24 | ############################################################################### 25 | # ↓ DON'T REMOVE ↓ # 26 | ############################################################################### 27 | # Network to run the node on ("testnet" or "mainnet") 28 | NETWORK_NAME=mainnet 29 | -------------------------------------------------------------------------------- /.env.testnet.example: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # ↓ REQUIRED ↓ # 3 | ############################################################################### 4 | 5 | # L1 node that the op-node will get chain data from 6 | OP_NODE__RPC_ENDPOINT= 7 | 8 | # replace the p2p private key with yours 9 | # you can generate a new one with `openssl rand -hex 32` 10 | P2P_PRIV_KEY= 11 | 12 | # you can find the correct image tag for the network at https://github.com/bnb-chain/op-geth 13 | OP_GETH_IMAGE_TAG=latest 14 | # you can find the correct image tag for the network at https://github.com/bnb-chain/opbnb 15 | OP_NODE_IMAGE_TAG=latest 16 | 17 | ############################################################################### 18 | # ↓ OPTIONAL ↓ # 19 | ############################################################################### 20 | PORT__OP_GETH= 21 | PORT__OP_NODE= 22 | PORT__OP_NODE_P2P= 23 | 24 | ############################################################################### 25 | # ↓ DON'T REMOVE ↓ # 26 | ############################################################################### 27 | # Network to run the node on ("testnet" or "mainnet") 28 | NETWORK_NAME=testnet 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .env 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # opbnb-node-docker 2 | 3 | ## Hardware Requirements 4 | Replicas must store the transaction history of opBNB and run Geth. For optimal performance, they should be powerful machines (real or virtual) with at least 16 GB RAM and an SSD drive with 500 GB free space (for production network). 5 | 6 | ## Software Requirements 7 | 8 | git 9 | docker 10 | 11 | ## Running Your Own opBNB Node 12 | 13 | Follow the steps below to run your own opBNB node: 14 | 15 | 1. Use git clone to clone this repository to your local machine and enter the opbnb-node-docker folder: 16 | 17 | ``` 18 | git clone https://github.com/bnb-chain/opbnb-node-docker.git 19 | cd opbnb-node-docker 20 | 21 | ``` 22 | 23 | 2. Copy `.env.testnet.example`(or `.env.mainnet.example` if you want to start mainnet node), and name it `.env`: 24 | 25 | ``` 26 | cp .env.testnet.example .env 27 | 28 | ``` 29 | 30 | 3. Fill in all the `REQUIRED` parts in the `.env` file. 31 | 4. Generate `jwt.txt` (Optional): 32 | 33 | ``` 34 | openssl rand -hex 32 > jwt.txt 35 | 36 | ``` 37 | 38 | 5. Once everything is ready, use the command to start the node: `docker compose up -d` 39 | 40 | ## Operating the Node 41 | 42 | ### Start 43 | 44 | ``` 45 | docker compose up -d 46 | 47 | ``` 48 | 49 | ### Stop 50 | 51 | ``` 52 | docker compose down 53 | 54 | ``` 55 | 56 | ### Wipe 57 | 58 | ``` 59 | docker compose down -v 60 | 61 | ``` 62 | 63 | Note: This operation will delete volumes created by the container, thus deleting the data completely. This is a destructive operation, so please be careful. 64 | 65 | ### Logs 66 | 67 | ``` 68 | docker compose logs 69 | 70 | ``` 71 | 72 | This will show the logs of the specified service. You can add the `-f` parameter to get real-time scrolling logs. 73 | 74 | ### Update 75 | 76 | ``` 77 | docker compose pull 78 | 79 | ``` 80 | 81 | This will download the latest version of the image to run with the latest code. 82 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "3.4" 3 | x-logging: &logging 4 | logging: 5 | driver: json-file 6 | options: 7 | max-size: 10m 8 | max-file: "3" 9 | 10 | services: 11 | 12 | op-geth: 13 | image: ghcr.io/bnb-chain/op-geth:${OP_GETH_IMAGE_TAG} 14 | platform: linux/amd64 15 | restart: unless-stopped 16 | stop_grace_period: 5m 17 | entrypoint: /scripts/op-geth-start.sh 18 | env_file: 19 | - ./envs/${NETWORK_NAME}/op-geth.env 20 | - .env 21 | ports: 22 | - ${PORT__OP_GETH:-8545}:8545 23 | volumes: 24 | - ./scripts/:/scripts 25 | - ./jwt.txt:/jwt.txt 26 | - op_geth:/geth 27 | <<: *logging 28 | 29 | op-node: 30 | image: ghcr.io/bnb-chain/op-node:${OP_NODE_IMAGE_TAG} 31 | platform: linux/amd64 32 | depends_on: 33 | - op-geth 34 | restart: unless-stopped 35 | stop_grace_period: 5m 36 | entrypoint: /scripts/op-node-start.sh 37 | env_file: 38 | - .env 39 | ports: 40 | - ${PORT__OP_NODE_P2P:-9003}:9003 41 | - ${PORT__OP_NODE:-8546}:8546 42 | volumes: 43 | - ./scripts/:/scripts 44 | - ./jwt.txt:/jwt.txt 45 | - op_node:/op_node 46 | <<: *logging 47 | 48 | volumes: 49 | op_geth: 50 | op_node: 51 | -------------------------------------------------------------------------------- /envs/mainnet/op-geth.env: -------------------------------------------------------------------------------- 1 | BEDROCK_DATADIR=/geth 2 | CHAIN_ID=204 3 | L2_RPC=https://opbnb-mainnet-rpc.bnbchain.org 4 | -------------------------------------------------------------------------------- /envs/testnet/op-geth.env: -------------------------------------------------------------------------------- 1 | BEDROCK_DATADIR=/geth 2 | CHAIN_ID=5611 3 | L2_RPC=https://opbnb-testnet-rpc.bnbchain.org 4 | -------------------------------------------------------------------------------- /jwt.txt: -------------------------------------------------------------------------------- 1 | 2dea57c304c0bc2359b04d7ff87c0fca783b88b73be47e13c89a40b369df0b3b 2 | -------------------------------------------------------------------------------- /scripts/op-geth-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eou 3 | 4 | if [ "$NETWORK_NAME" == "testnet" ]; then 5 | export NETWORK=opBNBTestnet 6 | fi 7 | 8 | if [ "$NETWORK_NAME" == "mainnet" ]; then 9 | export NETWORK=opBNBMainnet 10 | fi 11 | 12 | # Start op-geth. 13 | exec geth \ 14 | --$NETWORK \ 15 | --datadir="$BEDROCK_DATADIR" \ 16 | --http.addr=0.0.0.0 \ 17 | --authrpc.addr="0.0.0.0" \ 18 | --authrpc.vhosts="*" \ 19 | --authrpc.jwtsecret=./jwt.txt \ 20 | --rollup.sequencerhttp=$L2_RPC 21 | -------------------------------------------------------------------------------- /scripts/op-node-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eou 3 | 4 | if [ "$NETWORK_NAME" == "testnet" ]; then 5 | export NETWORK=opBNBTestnet 6 | fi 7 | 8 | if [ "$NETWORK_NAME" == "mainnet" ]; then 9 | export NETWORK=opBNBMainnet 10 | fi 11 | 12 | # Start op-node. 13 | exec op-node \ 14 | --network=$NETWORK \ 15 | --snapshotlog.file=./snapshot.log \ 16 | --l2.jwt-secret=./jwt.txt \ 17 | --l1=$OP_NODE__RPC_ENDPOINT \ 18 | --l2=http://op-geth:8551 19 | --------------------------------------------------------------------------------