Skip to content

Commit cd96e6d

Browse files
Merge pull request #1 from ethscriptions-protocol/more_configurable_init
More configurable init
2 parents 4743d8c + 01b07cf commit cd96e6d

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

init-geth.sh

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,18 @@ else
5050
echo "GENESIS_MIX_HASH environment variable is not set, using existing value in genesis file"
5151
fi
5252

53+
ENABLE_PREIMAGES=${ENABLE_PREIMAGES:-true}
54+
55+
# Build preimages flag for init if enabled
56+
INIT_PREIMAGES_FLAG=""
57+
if [ "$ENABLE_PREIMAGES" = "true" ]; then
58+
INIT_PREIMAGES_FLAG="--cache.preimages"
59+
fi
60+
5361
# Check if the data directory is empty
5462
if [ ! "$(ls -A /root/ethereum)" ]; then
5563
echo "Initializing new blockchain..."
56-
geth init --cache.preimages --state.scheme=hash --datadir /root/ethereum "/$GENESIS_FILE"
64+
geth init $INIT_PREIMAGES_FLAG --state.scheme=hash --datadir /root/ethereum "/$GENESIS_FILE"
5765
else
5866
echo "Blockchain already initialized."
5967
fi
@@ -67,13 +75,36 @@ CACHE_SIZE=${CACHE_SIZE:-25000}
6775
# Set default auth RPC port if not provided
6876
AUTH_RPC_PORT=${AUTH_RPC_PORT:-8551}
6977

78+
GC_MODE=${GC_MODE:-archive}
79+
80+
STATE_HISTORY=${STATE_HISTORY:-0}
81+
TX_HISTORY=${TX_HISTORY:-0}
82+
83+
CACHE_GC=${CACHE_GC:-25}
84+
CACHE_TRIE=${CACHE_TRIE:-15}
85+
86+
7087
# Build override flags
7188
OVERRIDE_FLAGS=""
7289
if [ ! -z "$BLUEBIRD_TIMESTAMP" ]; then
7390
echo "Setting Bluebird fork timestamp to: $BLUEBIRD_TIMESTAMP"
7491
OVERRIDE_FLAGS="$OVERRIDE_FLAGS --override.bluebird=$BLUEBIRD_TIMESTAMP"
7592
fi
7693

94+
# Build preimages flag if enabled
95+
PREIMAGES_FLAG=""
96+
if [ "$ENABLE_PREIMAGES" = "true" ]; then
97+
PREIMAGES_FLAG="--cache.preimages"
98+
fi
99+
100+
# Log the configuration
101+
echo "Starting geth with:"
102+
echo " GC Mode: $GC_MODE"
103+
echo " State History: $STATE_HISTORY blocks"
104+
echo " Transaction History: $TX_HISTORY blocks"
105+
echo " Cache Size: $CACHE_SIZE MB"
106+
echo " Preimages: $ENABLE_PREIMAGES"
107+
77108
# Start geth in server mode without interactive console
78109
exec geth \
79110
--datadir /root/ethereum \
@@ -88,12 +119,14 @@ exec geth \
88119
--authrpc.jwtsecret /tmp/jwtsecret \
89120
--nodiscover \
90121
--cache $CACHE_SIZE \
91-
--cache.preimages \
122+
--cache.gc $CACHE_GC \
123+
--cache.trie $CACHE_TRIE \
124+
$PREIMAGES_FLAG \
92125
--maxpeers 0 \
93126
--rpc.gascap $RPC_GAS_CAP \
94127
--syncmode full \
95-
--gcmode archive \
128+
--gcmode $GC_MODE \
96129
--rollup.disabletxpoolgossip \
97130
--rollup.enabletxpooladmission=false \
98-
--history.state 0 \
99-
--history.transactions 0 $OVERRIDE_FLAGS
131+
--history.state $STATE_HISTORY \
132+
--history.transactions $TX_HISTORY $OVERRIDE_FLAGS

0 commit comments

Comments
 (0)