try to generalize op stack

This commit is contained in:
Sebastian
2024-02-17 08:27:26 +01:00
parent 714c5cb1c8
commit 0568929aa6
7 changed files with 15602 additions and 0 deletions

84
op-lisk-sepolia.yml Normal file
View File

@@ -0,0 +1,84 @@
version: '3.1'
services:
op-lisk-sepolia: # this is Optimism's geth client
build: ./op
expose:
- 8545 # RPC / Websocket
- 54521 # P2P TCP (currently unused)
- 54521/udp # P2P UDP (currently unused)
- 6060 # metrics
ports:
- "54521:54521"
- "54521:54521/udp"
command: [ "sh", "./geth-entrypoint" ]
restart: always
stop_grace_period: 30s
volumes:
- lisk-sepolia:/data
environment:
- "OP_GETH_GENESIS_FILE_PATH=sepolia/lisk/genesis.json"
#- "OP_GETH_SEQUENCER_HTTP=https://mainnet-sequencer.base.org"
- "OP_GETH_GCMODE=full"
- "OP_GETH_STATE_SCHEME=path"
- "GETH_DB_ENGINE=pebble"
- "CHAIN_NAME=lisk-sepolia"
- "P2P_PORT=54521"
- "WS_PORT=8545"
- "OP_NODE_L2_ENGINE_AUTH_RAW=688f5d737bad920bdfb2fc2f488d6b6209eebda1dae949a8de91398d932c517a"
- "OP_NODE_L2_ENGINE_AUTH=/tmp/engine-auth-jwt"
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.base-stripprefix.stripprefix.prefixes=/lisk-sepolia"
- "traefik.http.services.base.loadbalancer.server.port=8545"
- "traefik.http.routers.base.entrypoints=websecure"
- "traefik.http.routers.base.tls.certresolver=myresolver"
- "traefik.http.routers.base.rule=Host(`$DOMAIN`) && PathPrefix(`/lisk-sepolia`)"
- "traefik.http.routers.base.middlewares=base-stripprefix, ipwhitelist"
networks:
- chains
op-lisk-sepolia-node:
build: ./op
depends_on:
- op-lisk-sepolia
expose:
- 8545 # RPC
- 18660 # P2P TCP
- 18660/udp # P2P UDP
- 7300 # metrics
- 6060 # pprof
ports:
- "18660:18660"
- "18660:18660/udp"
command: [ "sh", "./op-node-entrypoint" ]
restart: always
stop_grace_period: 30s
environment:
- "OP_NODE_NETWORK=lisk-sepolia"
- "OP_NODE_L1_ETH_RPC=${ETHEREUM_SEPOLIA_ENDPOINT}"
- "OP_NODE_L2_ENGINE_AUTH_RAW=688f5d737bad920bdfb2fc2f488d6b6209eebda1dae949a8de91398d932c517a"
- "OP_NODE_L2_ENGINE_AUTH=/tmp/engine-auth-jwt"
- "OP_NODE_L2_ENGINE_RPC=http://op-lisk-sepolia: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=lisk"
- "OP_NODE_P2P_BOOTNODES=enr:-Iu4QI5BdaTmfMhNKXd-vSniNRSCXk-a3m3nQbe9TCV3puGtCr6FvX6-Vr0Uvx4tYVilGCIYdQNf6fK8O2MKxVqjYJ8BgmlkgnY0gmlwhCKN6PiJc2VjcDI1NmsxoQLBQIaRwlvNxrRKcGtxKmh4JS_orkawS44D4KIORICoi4N0Y3CCIyuDdWRwgiMr"
- "OP_NODE_P2P_LISTEN_IP=0.0.0.0"
- "OP_NODE_P2P_LISTEN_TCP_PORT=18660"
- "OP_NODE_P2P_LISTEN_UDP_PORT=18660"
- "OP_NODE_ROLLUP_CONFIG=sepolia/lisk/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=4"
- "OP_NODE_L1_RPC_KIND=${ETHEREUM_SEPOLIA_ENDPOINT_KIND:-basic}"
- "OP_NODE_L1_TRUST_RPC=${ETHEREUM_SEPLIA_ENDPOINT_TRUST:-false}"
networks:
- chains
volumes:
lisk-sepolia:

46
op/#Dockerfile# Normal file
View File

@@ -0,0 +1,46 @@
FROM golang:1.20 as op
WORKDIR /app
ENV REPO=https://github.com/ethereum-optimism/optimism.git
ENV VERSION=v1.4.2
# for verification:
ENV COMMIT=f2229b8b955e53408be0775a22d7f9f162b0de66
RUN git clone $REPO --branch op-node/$VERSION --single-branch . && \
git switch -c branch-$VERSION && \
bash -c '[ "$(git rev-parse HEAD)" = "$COMMIT" ]'
RUN cd op-node && \
make op-node
FROM golang:1.20 as geth
WORKDIR /app
ENV REPO=https://github.com/ethereum-optimism/op-geth.git
ENV VERSION=v1.1801304.2
# for verification:
ENV COMMIT=c6b416da212fe6713ff40b8092303d0035405a47
# avoid depth=1, so the geth build can read tags
RUN git clone $REPO --branch $VERSION --single-branch . && \
git switch -c branch-$VERSION && \
bash -c '[ "$(git rev-parse HEAD)" = "$COMMIT" ]'
RUN go run build/ci.go install -static ./cmd/geth
FROM golang:1.19
RUN apt-get update && \
apt-get install -y jq curl && \
rm -rf /var/lib/apt/lists
WORKDIR /app
COPY --from=op /app/op-node/bin/op-node ./
COPY --from=geth /app/build/bin/geth ./
COPY geth-entrypoint .
COPY op-node-entrypoint .
COPY goerli ./goerli
COPY mainnet ./mainnet

46
op/Dockerfile Normal file
View File

@@ -0,0 +1,46 @@
FROM golang:1.20 as op
WORKDIR /app
ENV REPO=https://github.com/ethereum-optimism/optimism.git
ENV VERSION=v1.4.2
# for verification:
ENV COMMIT=f2229b8b955e53408be0775a22d7f9f162b0de66
RUN git clone $REPO --branch op-node/$VERSION --single-branch . && \
git switch -c branch-$VERSION && \
bash -c '[ "$(git rev-parse HEAD)" = "$COMMIT" ]'
RUN cd op-node && \
make op-node
FROM golang:1.20 as geth
WORKDIR /app
ENV REPO=https://github.com/ethereum-optimism/op-geth.git
ENV VERSION=v1.101304.2
# for verification:
ENV COMMIT=c6b416da212fe6713ff40b8092303d0035405a47
# avoid depth=1, so the geth build can read tags
RUN git clone $REPO --branch $VERSION --single-branch . && \
git switch -c branch-$VERSION && \
bash -c '[ "$(git rev-parse HEAD)" = "$COMMIT" ]'
RUN go run build/ci.go install -static ./cmd/geth
FROM golang:1.19
RUN apt-get update && \
apt-get install -y jq curl && \
rm -rf /var/lib/apt/lists
WORKDIR /app
COPY --from=op /app/op-node/bin/op-node ./
COPY --from=geth /app/build/bin/geth ./
COPY geth-entrypoint .
COPY op-node-entrypoint .
COPY sepolia ./sepolia
COPY mainnet ./mainnet

73
op/geth-entrypoint Executable file
View File

@@ -0,0 +1,73 @@
#!/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=$(jq -r .config.chainId < "$OP_GETH_GENESIS_FILE_PATH")
RPC_PORT="${RPC_PORT:-8545}"
WS_PORT="${WS_PORT:-8546}"
AUTHRPC_PORT="${AUTHRPC_PORT:-8551}"
METRICS_PORT="${METRICS_PORT:-6060}"
HOST_IP="0.0.0.0"
P2P_PORT="${P2P_PORT:-30303}"
ADDITIONAL_ARGS=""
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"
if [ "${OP_GETH_ETH_STATS+x}" = x ]; then
ADDITIONAL_ARGS="$ADDITIONAL_ARGS --ethstats=$OP_GETH_ETH_STATS"
fi
if [ "${OP_GETH_ALLOW_UNPROTECTED_TXS+x}" = x ]; then
ADDITIONAL_ARGS="$ADDITIONAL_ARGS --rpc.allow-unprotected-txs=$OP_GETH_ALLOW_UNPROTECTED_TXS"
fi
exec ./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,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,net,engine \
--metrics \
--metrics.addr=0.0.0.0 \
--metrics.port="$METRICS_PORT" \
--syncmode=full \
--gcmode=${OP_GETH_GCMODE:-full} \
--state.scheme=${OP_GETH_STATE_SCHEME:-path} \
--db.engine=${GETH_DB_ENGINE:-pebble} \
--discovery.port=${P2P_PORT:-30303} \
--nodiscover \
--maxpeers=100 \
--nat=extip:$HOST_IP \
--networkid="$CHAIN_ID" \
--op-network="$CHAIN_NAME" \
--rollup.halt=major \
--rollup.sequencerhttp="$OP_GETH_SEQUENCER_HTTP" \
--port="$P2P_PORT" \
$ADDITIONAL_ARGS # intentionally unquoted

15303
op/lisk-sepolia/genesis.json Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,34 @@
{
"genesis": {
"l1": {
"hash": "0x7d9d6dcec39efe182119f41b1bd2aa7b35b82e43927522afea86d210a4eace4b",
"number": 5089851
},
"l2": {
"hash": "0xead3e6ddd08ae7e27fd952b74ceb468ba889047ac96b351dd13bd55e5faf3372",
"number": 0
},
"l2_time": 1705312992,
"system_config": {
"scalar": "0x00000000000000000000000000000000000000000000000000000000000f4240",
"gasLimit": 30000000,
"overhead": "0x0000000000000000000000000000000000000000000000000000000000000834",
"batcherAddr": "0x246e119a5bcc2875161b23e4e602e25cece96e37",
"basefeeScalar": 0,
"blobBasefeeScalar": 0
}
},
"block_time": 2,
"delta_time": 0,
"canyon_time": 0,
"l1_chain_id": 11155111,
"l2_chain_id": 4202,
"regolith_time": 0,
"channel_timeout": 300,
"seq_window_size": 3600,
"batch_inbox_address": "0xff00000000000000000000000000000000004202",
"max_sequencer_drift": 600,
"deposit_contract_address": "0xe3d90f21490686ec7ef37be788e02dfc12787264",
"l1_system_config_address": "0xf54791059df4a12ba461b881b4080ae81a1d0ac0",
"protocol_versions_address": "0x0000000000000000000000000000000000000000"
}

16
op/op-node-entrypoint Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -eu
# wait until local geth comes up (authed so will return 401 without token)
until [ "$(curl -s -w '%{http_code}' -o /dev/null "$OP_NODE_L2_ENGINE_RPC")" -eq 401 ]; do
echo "waiting for geth to be ready"
sleep 5
done
# public-facing P2P node, advertise public IP address
PUBLIC_IP=$(curl -s v4.ident.me)
export OP_NODE_P2P_ADVERTISE_IP=$PUBLIC_IP
echo "$OP_NODE_L2_ENGINE_AUTH_RAW" > "$OP_NODE_L2_ENGINE_AUTH"
exec ./op-node