Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add legacy geth syncing #27

Merged
merged 4 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ 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"
- 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: {}
54 changes: 50 additions & 4 deletions op-geth/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +12,49 @@ 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must check if this is needed. I had to add it in the past to make the node work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added as an issue


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 --rollup.sequencerhttp $SEQUENCER_HTTP_URL \
--rollup.disabletxpoolgossip \
Expand All @@ -26,7 +72,7 @@ exec geth --rollup.sequencerhttp $SEQUENCER_HTTP_URL \
--authrpc.vhosts "*" \
--authrpc.jwtsecret /config/jwtsecret.hex \
--verbosity 3 \
--syncmode=snap \
--port ${P2P_PORT} \
--networkid=10 \
--op-network=op-mainnet
--networkid 10 \
Marketen marked this conversation as resolved.
Show resolved Hide resolved
--op-network=op-mainnet \
${EXTRA_FLAGS}
Loading