From c39fecd1472a4ad5c0d30cee558978112d529f56 Mon Sep 17 00:00:00 2001 From: Marketen Date: Thu, 9 May 2024 22:46:49 +0200 Subject: [PATCH 1/3] base config --- docker-compose.yml | 12 ++++++------ op-geth/entrypoint.sh | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7080f1b..282757a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,17 +6,17 @@ services: args: UPSTREAM_VERSION: v1.101311.0 volumes: - - "data:/data" + - data:/data restart: unless-stopped environment: - EXTRA_FLAGS - P2P_PORT=33142 - SYNCMODE=snap - - "HISTORICAL_RPC_URL=http://op-l2geth.dappnode:8545" - - "SEQUENCER_HTTP_URL=https://mainnet-sequencer.optimism.io/" - image: "geth.op-geth.dnp.dappnode.eth:0.1.1" + - HISTORICAL_RPC_URL=http://op-l2geth.dappnode:8545 + - SEQUENCER_HTTP_URL=https://mainnet-sequencer.optimism.io/ + image: geth.op-geth.dnp.dappnode.eth:0.1.1 ports: - - "33142:33142/tcp" - - "33142:33142/udp" + - 33142:33142/tcp + - 33142:33142/udp volumes: data: {} diff --git a/op-geth/entrypoint.sh b/op-geth/entrypoint.sh index 2176baa..5e4184d 100755 --- a/op-geth/entrypoint.sh +++ b/op-geth/entrypoint.sh @@ -10,7 +10,8 @@ PRELOADED_DATA_FILE=/mainnet-bedrock.tar.zst # TODO: Should we add --http.api and --ws.api flags? echo "[INFO - entrypoint] Starting Geth" -exec geth --rollup.sequencerhttp $SEQUENCER_HTTP_URL \ +exec geth --datadir $DATA_DIR \ + --rollup.sequencerhttp $SEQUENCER_HTTP_URL \ --rollup.disabletxpoolgossip \ --ws \ --ws.port 8546 \ @@ -29,4 +30,5 @@ exec geth --rollup.sequencerhttp $SEQUENCER_HTTP_URL \ --syncmode=snap \ --port ${P2P_PORT} \ --networkid=10 \ - --op-network=op-mainnet \ No newline at end of file + --op-network=op-mainnet \ + ${EXTRA_FLAGS} From e06053f58b189b71c143eed7c154bb8e406d0ac6 Mon Sep 17 00:00:00 2001 From: Marketen Date: Fri, 10 May 2024 11:59:29 +0200 Subject: [PATCH 2/3] add dedicated datadirs --- docker-compose.yml | 1 - op-geth/entrypoint.sh | 54 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 282757a..bffa6ec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,6 @@ services: - EXTRA_FLAGS - P2P_PORT=33142 - SYNCMODE=snap - - HISTORICAL_RPC_URL=http://op-l2geth.dappnode:8545 - SEQUENCER_HTTP_URL=https://mainnet-sequencer.optimism.io/ image: geth.op-geth.dnp.dappnode.eth:0.1.1 ports: diff --git a/op-geth/entrypoint.sh b/op-geth/entrypoint.sh index 5e4184d..39652c0 100755 --- a/op-geth/entrypoint.sh +++ b/op-geth/entrypoint.sh @@ -1,6 +1,9 @@ #!/bin/sh -DATA_DIR=/data +SNAP_DATA_DIR=/data/snap +ARCHIVAL_DATA_DIR=/data/archive + +HISTORICAL_RPC_URL=http://op-l2geth.dappnode:8545 PRELOADED_DATA_FILE=/mainnet-bedrock.tar.zst # Configuration defined in https://community.optimism.io/docs/developers/bedrock/node-operator-guide/#configuring-op-geth @@ -9,9 +12,51 @@ PRELOADED_DATA_FILE=/mainnet-bedrock.tar.zst # TODO: Should we add --http.api and --ws.api flags? +if [ "$_DAPPNODE_GLOBAL_OP_ENABLE_HISTORICAL_RPC" = "true" ]; then + + if [ -z "$HISTORICAL_RPC_URL" ]; then + echo "[ERROR - entrypoint] ENABLE_HISTORICAL_RPC is set to true but HISTORICAL_RPC_URL is not defined" + sleep 60 + exit 1 + fi + + echo "[INFO - entrypoint] Enabling historical RPC" + rm -rf $SNAP_DATA_DIR + + # Before starting the download, check if a partial file exists. + if [ -f "$PRELOADED_DATA_FILE" ]; then + echo "[WARNING - entrypoint] Found a partial preloaded data file. Removing it..." + rm -f $PRELOADED_DATA_FILE + fi + + # Start the download. + wget -O $PRELOADED_DATA_FILE https://datadirs.optimism.io$PRELOADED_DATA_FILE + if [ $? -ne 0 ]; then + echo "[ERROR - entrypoint] Failed to download preloaded data." + exit 1 + fi + + echo "[INFO - entrypoint] Decompressing preloaded data. This can take a while..." + zstd -d --stdout $PRELOADED_DATA_FILE | tar xvf - -C $ARCHIVAL_DATA_DIR + if [ $? -ne 0 ]; then + echo "[ERROR - entrypoint] Failed to decompress preloaded data." + rm -f $PRELOADED_DATA_FILE # Remove the faulty file + exit 1 + fi + + echo "[INFO - entrypoint] Removing preloaded data file. Not needed anymore." + rm -rf $PRELOADED_DATA_FILE + EXTRA_FLAGS="--rollup.historicalrpc $HISTORICAL_RPC_URL --gcmode archive --syncmode full --datadir $ARCHIVAL_DATA_DIR" + # EXTRA_FLAGS="--datadir.ancient $ARCHIVAL_DATA_DIR/geth/chaindata/ancient" + +else + echo "[INFO - entrypoint] Historical RPC is disabled" + EXTRA_FLAGS="--gcmode full --syncmode snap --datadir $SNAP_DATA_DIR" + rm -rf $ARCHIVAL_DATA_DIR +fi + echo "[INFO - entrypoint] Starting Geth" -exec geth --datadir $DATA_DIR \ - --rollup.sequencerhttp $SEQUENCER_HTTP_URL \ +exec geth --rollup.sequencerhttp $SEQUENCER_HTTP_URL \ --rollup.disabletxpoolgossip \ --ws \ --ws.port 8546 \ @@ -27,8 +72,7 @@ exec geth --datadir $DATA_DIR \ --authrpc.vhosts "*" \ --authrpc.jwtsecret /config/jwtsecret.hex \ --verbosity 3 \ - --syncmode=snap \ --port ${P2P_PORT} \ - --networkid=10 \ + --networkid 10 \ --op-network=op-mainnet \ ${EXTRA_FLAGS} From 664eb26b1ef5da15aa84e1e07e30b57f5c0c9c3d Mon Sep 17 00:00:00 2001 From: Marketen Date: Mon, 13 May 2024 11:39:27 +0200 Subject: [PATCH 3/3] remove "=" in docker compose --- op-geth/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/op-geth/entrypoint.sh b/op-geth/entrypoint.sh index 39652c0..495e3a9 100755 --- a/op-geth/entrypoint.sh +++ b/op-geth/entrypoint.sh @@ -74,5 +74,5 @@ exec geth --rollup.sequencerhttp $SEQUENCER_HTTP_URL \ --verbosity 3 \ --port ${P2P_PORT} \ --networkid 10 \ - --op-network=op-mainnet \ + --op-network op-mainnet \ ${EXTRA_FLAGS}