Skip to content
Merged
Changes from all 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
43 changes: 38 additions & 5 deletions init-geth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,18 @@ else
echo "GENESIS_MIX_HASH environment variable is not set, using existing value in genesis file"
fi

ENABLE_PREIMAGES=${ENABLE_PREIMAGES:-true}

# Build preimages flag for init if enabled
INIT_PREIMAGES_FLAG=""
if [ "$ENABLE_PREIMAGES" = "true" ]; then
INIT_PREIMAGES_FLAG="--cache.preimages"
fi

# Check if the data directory is empty
if [ ! "$(ls -A /root/ethereum)" ]; then
echo "Initializing new blockchain..."
geth init --cache.preimages --state.scheme=hash --datadir /root/ethereum "/$GENESIS_FILE"
geth init $INIT_PREIMAGES_FLAG --state.scheme=hash --datadir /root/ethereum "/$GENESIS_FILE"
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The variable $INIT_PREIMAGES_FLAG should be quoted to prevent word splitting and pathname expansion. Use "$INIT_PREIMAGES_FLAG" instead.

Suggested change
geth init $INIT_PREIMAGES_FLAG --state.scheme=hash --datadir /root/ethereum "/$GENESIS_FILE"
geth init "$INIT_PREIMAGES_FLAG" --state.scheme=hash --datadir /root/ethereum "/$GENESIS_FILE"

Copilot uses AI. Check for mistakes.
else
echo "Blockchain already initialized."
fi
Expand All @@ -67,13 +75,36 @@ CACHE_SIZE=${CACHE_SIZE:-25000}
# Set default auth RPC port if not provided
AUTH_RPC_PORT=${AUTH_RPC_PORT:-8551}

GC_MODE=${GC_MODE:-archive}

STATE_HISTORY=${STATE_HISTORY:-0}
TX_HISTORY=${TX_HISTORY:-0}

CACHE_GC=${CACHE_GC:-25}
CACHE_TRIE=${CACHE_TRIE:-15}


Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

[nitpick] Remove the extra blank line to maintain consistent spacing in the script.

Suggested change

Copilot uses AI. Check for mistakes.
# Build override flags
OVERRIDE_FLAGS=""
if [ ! -z "$BLUEBIRD_TIMESTAMP" ]; then
echo "Setting Bluebird fork timestamp to: $BLUEBIRD_TIMESTAMP"
OVERRIDE_FLAGS="$OVERRIDE_FLAGS --override.bluebird=$BLUEBIRD_TIMESTAMP"
fi

# Build preimages flag if enabled
PREIMAGES_FLAG=""
if [ "$ENABLE_PREIMAGES" = "true" ]; then
PREIMAGES_FLAG="--cache.preimages"
fi

# Log the configuration
echo "Starting geth with:"
echo " GC Mode: $GC_MODE"
echo " State History: $STATE_HISTORY blocks"
echo " Transaction History: $TX_HISTORY blocks"
echo " Cache Size: $CACHE_SIZE MB"
echo " Preimages: $ENABLE_PREIMAGES"

# Start geth in server mode without interactive console
exec geth \
--datadir /root/ethereum \
Expand All @@ -88,12 +119,14 @@ exec geth \
--authrpc.jwtsecret /tmp/jwtsecret \
--nodiscover \
--cache $CACHE_SIZE \
--cache.preimages \
--cache.gc $CACHE_GC \
--cache.trie $CACHE_TRIE \
$PREIMAGES_FLAG \
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The variable $PREIMAGES_FLAG should be quoted to prevent word splitting and pathname expansion. Use "$PREIMAGES_FLAG" instead.

Suggested change
$PREIMAGES_FLAG \
"$PREIMAGES_FLAG" \

Copilot uses AI. Check for mistakes.
--maxpeers 0 \
--rpc.gascap $RPC_GAS_CAP \
--syncmode full \
--gcmode archive \
--gcmode $GC_MODE \
--rollup.disabletxpoolgossip \
--rollup.enabletxpooladmission=false \
--history.state 0 \
--history.transactions 0 $OVERRIDE_FLAGS
--history.state $STATE_HISTORY \
--history.transactions $TX_HISTORY $OVERRIDE_FLAGS