Skip to content

Commit

Permalink
Update syncmode flag to snap (#25)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mateumiralles authored Apr 29, 2024
1 parent d54d1fa commit 9193801
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 62 deletions.
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
61 changes: 5 additions & 56 deletions op-geth/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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

0 comments on commit 9193801

Please sign in to comment.