Skip to content

Commit

Permalink
Merge pull request #24 from flashbots/pbs-docker
Browse files Browse the repository at this point in the history
Update docker build for op-geth
  • Loading branch information
jinmel authored Aug 21, 2024
2 parents 35837eb + 834667c commit ab12a22
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 10 deletions.
9 changes: 9 additions & 0 deletions ops-bedrock/Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM jinmel/builder:latest

RUN apk add --no-cache jq

COPY entrypoint-builder.sh /entrypoint.sh

VOLUME ["/db"]

ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
2 changes: 1 addition & 1 deletion ops-bedrock/Dockerfile.l2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM jinmel/op-geth:latest
FROM us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:optimism

RUN apk add --no-cache jq

Expand Down
12 changes: 5 additions & 7 deletions ops-bedrock/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,18 +305,20 @@ services:
ipv4_address: 10.5.0.123

builder-op-geth:
build:
context: .
dockerfile: Dockerfile.builder
depends_on:
- l1
- l2
- op-node
image: jinmel/builder:latest # NOTE: Replace with the builder image
ports:
- "5545:8545"
volumes:
- "builder_data:/db"
- "${PWD}/../.devnet/genesis-l2.json:/genesis.json"
- "${PWD}/test-jwt-secret.txt:/config/test-jwt-secret.txt"
- "${PWD}/entrypoint-l2.sh:/entrypoint.sh"
- "${PWD}/entrypoint-builder.sh:/entrypoint.sh"
entrypoint: # pass the L2 specific flags by overriding the entry-point and adding extra arguments
- "/bin/sh"
- "/entrypoint.sh"
Expand All @@ -329,11 +331,7 @@ services:
- "--rollup.disabletxpoolgossip"
- "--builder"
- "--builder.beacon_endpoints=http://builder-op-node:9546"
- "--builder.local_relay"
- "--builder.seconds_in_slot=2"
- "--builder.block_resubmit_interval=200ms"
- "--builder.submission_offset=1s"
- "--builder.algotype=greedy"
- "--builder.block_retry_interval=200ms"
- "--builder.block_time=2s"
environment:
GETH_MINER_RECOMMIT: 100ms
Expand Down
55 changes: 55 additions & 0 deletions ops-bedrock/entrypoint-builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh
set -exu

VERBOSITY=${GETH_VERBOSITY:-3}
GETH_DATA_DIR=/db
GETH_CHAINDATA_DIR="$GETH_DATA_DIR/geth/chaindata"
GENESIS_FILE_PATH="${GENESIS_FILE_PATH:-/genesis.json}"
CHAIN_ID=$(cat "$GENESIS_FILE_PATH" | jq -r .config.chainId)
RPC_PORT="${RPC_PORT:-8545}"
WS_PORT="${WS_PORT:-8546}"
AUTH_RPC_PORT="${AUTH_RPC_PORT:-8551}"
METRICS_PORT="${METRICS_PORT:-6060}"
P2P_PORT="${P2P_PORT:-30303}"

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

# Warning: Archive mode is required, otherwise old trie nodes will be
# pruned within minutes of starting the devnet.

exec geth \
--datadir="$GETH_DATA_DIR" \
--verbosity="$VERBOSITY" \
--port="$P2P_PORT" \
--http \
--http.corsdomain="*" \
--http.vhosts="*" \
--http.addr=0.0.0.0 \
--http.port="$RPC_PORT" \
--http.api=web3,debug,eth,txpool,net,engine,admin \
--ws \
--ws.addr=0.0.0.0 \
--ws.port="$WS_PORT" \
--ws.origins="*" \
--ws.api=debug,eth,txpool,net,engine \
--syncmode=full \
--networkid=$CHAIN_ID \
--rpc.allow-unprotected-txs \
--authrpc.addr=0.0.0.0 \
--authrpc.port="$AUTH_RPC_PORT" \
--authrpc.vhosts="*" \
--authrpc.jwtsecret=/config/jwt-secret.txt \
--gcmode=archive \
--metrics \
--metrics.addr=0.0.0.0 \
--metrics.port="$METRICS_PORT" \
"$@"
2 changes: 2 additions & 0 deletions ops-bedrock/entrypoint-l1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if [ ! -d "$GETH_CHAINDATA_DIR" ]; then
echo "Initializing genesis."
geth --verbosity="$VERBOSITY" init \
--datadir="$GETH_DATA_DIR" \
--state.scheme=hash \
"$GENESIS_FILE_PATH"
else
echo "$GETH_CHAINDATA_DIR exists."
Expand Down Expand Up @@ -66,6 +67,7 @@ exec geth \
--authrpc.vhosts="*" \
--authrpc.jwtsecret=/config/jwt-secret.txt \
--gcmode=archive \
--state.scheme=hash \
--metrics \
--metrics.addr=0.0.0.0 \
--metrics.port=6060 \
Expand Down
6 changes: 4 additions & 2 deletions ops-bedrock/entrypoint-l2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ if [ ! -d "$GETH_CHAINDATA_DIR" ]; then
echo "Initializing genesis."
geth --verbosity="$VERBOSITY" init \
--datadir="$GETH_DATA_DIR" \
--state.scheme=hash \
"$GENESIS_FILE_PATH"
else
echo "$GETH_CHAINDATA_DIR exists."
Expand All @@ -37,15 +38,16 @@ exec geth \
--ws.origins="*" \
--ws.api=debug,eth,txpool,net,engine \
--syncmode=full \
--nodiscover \
--maxpeers=0 \
--nodiscover \
--maxpeers=0 \
--networkid="$CHAIN_ID" \
--rpc.allow-unprotected-txs \
--authrpc.addr="0.0.0.0" \
--authrpc.port="8551" \
--authrpc.vhosts="*" \
--authrpc.jwtsecret=/config/jwt-secret.txt \
--gcmode=archive \
--state.scheme=hash \
--metrics \
--metrics.addr=0.0.0.0 \
--metrics.port=6060 \
Expand Down

0 comments on commit ab12a22

Please sign in to comment.