From 919380150861d0e9eefc543c8c648d4a48386d27 Mon Sep 17 00:00:00 2001 From: Mateu Miralles <52827122+mateumiralles@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:15:32 +0200 Subject: [PATCH] Update `syncmode` flag to `snap` (#25) * Update `syncmode` flag to `snap` Updating `syncmode` flag to `snap` to check if it syncs faster * p2p port exposure * adding op-network flag * deleting unnecessary config --- docker-compose.yml | 12 ++++----- op-geth/entrypoint.sh | 61 ++++--------------------------------------- 2 files changed, 11 insertions(+), 62 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d259d97..7080f1b 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://bedrock-beta-1-sequencer.optimism.io - image: geth.op-geth.dnp.dappnode.eth:0.1.0 + - "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 ed45f74..2176baa 100755 --- a/op-geth/entrypoint.sh +++ b/op-geth/entrypoint.sh @@ -6,61 +6,11 @@ PRELOADED_DATA_FILE=/mainnet-bedrock.tar.zst # Configuration defined in https://community.optimism.io/docs/developers/bedrock/node-operator-guide/#configuring-op-geth # Tx pool gossip is disabled as it is not supported yet -# Max peers set to 0 to disable peer discovery (will be enabled in the future for snap sync) -# 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" - EXTRA_FLAGS="--rollup.historicalrpc $HISTORICAL_RPC_URL --gcmode archive" -else - echo "[INFO - entrypoint] Historical RPC is disabled" - EXTRA_FLAGS="--gcmode full" -fi - -# If $DATA_DIR is not empty, then geth is already initialized -if [ "$(ls -A $DATA_DIR)" ]; then - echo "[INFO - entrypoint] Database already exists, skipping initialization" -else - echo "[INFO - entrypoint] $DATA_DIR is empty, initializing geth from preloaded data" - echo "[INFO - entrypoint] Downloading preloaded data from $PRELOADED_DATA_URL. This can take hours..." - mkdir -p $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 $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="--datadir.ancient $DATA_DIR/geth/chaindata/ancient" -fi +# TODO: Should we add --http.api and --ws.api flags? 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 \ @@ -76,8 +26,7 @@ exec geth --datadir $DATA_DIR \ --authrpc.vhosts "*" \ --authrpc.jwtsecret /config/jwtsecret.hex \ --verbosity 3 \ - --nodiscover \ - --maxpeers 0 \ - --syncmode full \ + --syncmode=snap \ + --port ${P2P_PORT} \ --networkid=10 \ - ${EXTRA_FLAGS} + --op-network=op-mainnet \ No newline at end of file