Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Feb 1, 2023
0 parents commit ca0b9b0
Show file tree
Hide file tree
Showing 8 changed files with 15,449 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.idea/
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM golang:1.19 as op

WORKDIR /app

ENV REPO=https://github.com/ethereum-optimism/optimism.git
ENV COMMIT=3c3e1a88b234a68bcd59be0c123d9f3cc152a91e
RUN git init && \
git remote add origin $REPO && \
git fetch --depth=1 origin $COMMIT && \
git reset --hard FETCH_HEAD

RUN cd op-node && \
make op-node


FROM golang:1.19 as geth

WORKDIR /app

ENV REPO=https://github.com/ethereum-optimism/op-geth.git
ENV COMMIT=0678a130d7908b64aea596320099d30463119169
RUN git init && \
git remote add origin $REPO && \
git fetch --depth=1 origin $COMMIT && \
git reset --hard FETCH_HEAD

RUN go run build/ci.go install -static ./cmd/geth


FROM golang:1.19

RUN apt-get update && \
apt-get install -y jq curl

WORKDIR /app

COPY --from=op /app/op-node/bin/op-node ./
COPY --from=geth /app/build/bin/geth ./
COPY . .
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# node

This repository contains the relevant Docker builds to run your own node on the Base network.
Currently only the Base testnet (on Goerli) is supported.

### Usage

1. Ensure you have an Goerli L1 node RPC available, and set `OP_NODE_L1_ETH_RPC` (in `docker-compose.yml` if using docker-compose).
2. Run:
```
docker-compose up
```
3. You should now be able to `curl` your Base node:
```
curl -d '{"id":0,"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest",false]}' \
-H "Content-Type: application/json" \
http://localhost:8545
```
43 changes: 43 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
services:
geth:
build: .
ports:
- 8545:8545
- 8546:8546
- 30303:30303
command:
- ./geth-entrypoint.sh
environment:
- OP_GETH_GENESIS_FILE_PATH=goerli/genesis-l2.json
- OP_NODE_L2_ENGINE_AUTH=/tmp/engine-auth-jwt
- OP_NODE_L2_ENGINE_AUTH_RAW=688f5d737bad920bdfb2fc2f488d6b6209eebda1dae949a8de91398d932c517a # for localdev only
node:
build: .
depends_on:
- geth
ports:
- 7545:8545
- 9222:9222
- 7300:7300
- 6060:6060
command:
- ./op-node-entrypoint.sh
environment:
- OP_NODE_L1_ETH_RPC=https://ethereum-goerli-rpc.allthatnode.com # replace with your L1 node RPC URL
- OP_NODE_L2_ENGINE_AUTH=/tmp/engine-auth-jwt
- OP_NODE_L2_ENGINE_AUTH_RAW=688f5d737bad920bdfb2fc2f488d6b6209eebda1dae949a8de91398d932c517a # for localdev only
- OP_NODE_L2_ENGINE_RPC=http://geth:8551
- OP_NODE_LOG_LEVEL=info
- OP_NODE_METRICS_ADDR=0.0.0.0
- OP_NODE_METRICS_ENABLED=true
- OP_NODE_METRICS_PORT=7300
- OP_NODE_P2P_AGENT=base
- OP_NODE_P2P_BOOTNODES=enr:-J64QBbwPjPLZ6IOOToOLsSjtFUjjzN66qmBZdUexpO32Klrc458Q24kbty2PdRaLacHM5z-cZQr8mjeQu3pik6jPSOGAYYFIqBfgmlkgnY0gmlwhDaRWFWHb3BzdGFja4SzlAUAiXNlY3AyNTZrMaECmeSnJh7zjKrDSPoNMGXoopeDF4hhpj5I0OsQUUt4u8uDdGNwgiQGg3VkcIIkBg,enr:-J64QAlTCDa188Hl1OGv5_2Kj2nWCsvxMVc_rEnLtw7RPFbOfqUOV6khXT_PH6cC603I2ynY31rSQ8sI9gLeJbfFGaWGAYYFIrpdgmlkgnY0gmlwhANWgzCHb3BzdGFja4SzlAUAiXNlY3AyNTZrMaECkySjcg-2v0uWAsFsZZu43qNHppGr2D5F913Qqs5jDCGDdGNwgiQGg3VkcIIkBg
- OP_NODE_P2P_LISTEN_IP=0.0.0.0
- OP_NODE_P2P_LISTEN_TCP_PORT=9222
- OP_NODE_P2P_LISTEN_UDP_PORT=9222
- OP_NODE_ROLLUP_CONFIG=goerli/rollup.json
- OP_NODE_RPC_ADDR=0.0.0.0
- OP_NODE_RPC_PORT=8545
- OP_NODE_SNAPSHOT_LOG=/tmp/op-node-snapshot-log
- OP_NODE_VERIFIER_L1_CONFS=0
51 changes: 51 additions & 0 deletions geth-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
set -eu

VERBOSITY=${GETH_VERBOSITY:-3}
GETH_DATA_DIR=/data
GETH_CHAINDATA_DIR="$GETH_DATA_DIR/geth/chaindata"
OP_GETH_GENESIS_FILE_PATH="${OP_GETH_GENESIS_FILE_PATH:-/genesis.json}"
CHAIN_ID=$(cat "$OP_GETH_GENESIS_FILE_PATH" | jq -r .config.chainId)
RPC_PORT="${RPC_PORT:-8545}"
WS_PORT="${WS_PORT:-8546}"
AUTHRPC_PORT="${AUTHRPC_PORT:-8551}"
HOST_IP="0.0.0.0"

mkdir -p $GETH_DATA_DIR

if [ ! -d "$GETH_CHAINDATA_DIR" ]; then
echo "$GETH_CHAINDATA_DIR missing, running init"
echo "Initializing genesis."
./geth --verbosity="$VERBOSITY" init \
--datadir="$GETH_DATA_DIR" \
"$OP_GETH_GENESIS_FILE_PATH"
else
echo "$GETH_CHAINDATA_DIR exists."
fi

echo "$OP_NODE_L2_ENGINE_AUTH_RAW" > "$OP_NODE_L2_ENGINE_AUTH"

./geth \
--datadir="$GETH_DATA_DIR" \
--verbosity="$VERBOSITY" \
--http \
--http.corsdomain="*" \
--http.vhosts="*" \
--http.addr=0.0.0.0 \
--http.port="$RPC_PORT" \
--http.api=web3,debug,eth,txpool,net,engine \
--authrpc.addr=0.0.0.0 \
--authrpc.port="$AUTHRPC_PORT" \
--authrpc.vhosts="*" \
--authrpc.jwtsecret="$OP_NODE_L2_ENGINE_AUTH" \
--ws \
--ws.addr=0.0.0.0 \
--ws.port="$WS_PORT" \
--ws.origins="*" \
--ws.api=debug,eth,txpool,net,engine \
--syncmode=full \
--gcmode=archive \
--nodiscover \
--maxpeers=100 \
--nat=extip:$HOST_IP \
--networkid="$CHAIN_ID"
Loading

0 comments on commit ca0b9b0

Please sign in to comment.