Add support for fast node
This commit is contained in:
parent
aa04f65468
commit
d9210326d0
@ -4,6 +4,8 @@ services:
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
CERC_BSC_NETWORK: ${CERC_BSC_NETWORK:-mainnet}
|
||||
CERC_USE_SNAPSHOT: ${CERC_USE_SNAPSHOT:-false}
|
||||
CERC_FAST_NODE: ${CERC_FAST_NODE:-false}
|
||||
CERC_GETH_GCMODE: ${CERC_GETH_GCMODE:-full}
|
||||
CERC_GETH_VERBOSITY: ${CERC_GETH_VERBOSITY:-3}
|
||||
volumes:
|
||||
|
@ -2,10 +2,13 @@
|
||||
set -e
|
||||
|
||||
echo "Setting up BSC $CERC_BSC_NETWORK"
|
||||
echo DATA_DIR: ${DATA_DIR}
|
||||
echo BSC_HOME: ${BSC_HOME}
|
||||
|
||||
BSC_CONFIG=${BSC_HOME}/config/config.toml
|
||||
BSC_GENESIS=${BSC_HOME}/config/genesis.json
|
||||
|
||||
# Setup config
|
||||
if [ -f "$BSC_CONFIG" ]; then
|
||||
echo "Config file found at $BSC_CONFIG"
|
||||
else
|
||||
@ -19,15 +22,26 @@ fi
|
||||
# Use snapshot if provided
|
||||
geth_dir=${DATA_DIR}/geth
|
||||
snapshot_file=$((ls /var/dev/snapshot/*.tar.lz4) 2>/dev/null | head -1)
|
||||
if [ ! -d "$geth_dir" ] && [ -n "$snapshot_file" ]; then
|
||||
echo Using snapshot $snapshot_file
|
||||
ADDITIONAL_FLAGS=""
|
||||
if [ ! -d "$geth_dir" ] && [ "${CERC_USE_SNAPSHOT}" = "true" ] && [ -n "$snapshot_file" ]; then
|
||||
echo "Using snapshot $snapshot_file"
|
||||
|
||||
if [ "$CERC_BSC_NETWORK" = "testnet" ]; then
|
||||
# snapshot dir structure for testnet different than that for mainnet
|
||||
# Snapshot dir structure for testnet is different than that for mainnet
|
||||
tar -C /${DATA_DIR}/ -I lz4 -xvf ${snapshot_file} --strip-components=3 server/testnet/dataseed/geth
|
||||
else
|
||||
tar -C /${DATA_DIR}/ -I lz4 -xvf ${snapshot_file} --strip-components=2 server/data-seed/geth
|
||||
fi
|
||||
|
||||
if [ "${CERC_FAST_NODE}" = "true" ]; then
|
||||
echo "Pruning trie data and turning snapshot verification off"
|
||||
|
||||
# Prune all trie data from the snapshot
|
||||
geth snapshot insecure-prune-all --datadir ${DATA_DIR} ${BSC_GENESIS}
|
||||
|
||||
# Turn off snapshot verification
|
||||
ADDITIONAL_FLAGS="--tries-verify-mode none"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Init genesis state if geth sub dir does not exist
|
||||
@ -38,12 +52,11 @@ if [ ! -d "$geth_dir" ]; then
|
||||
STATE_SCHEME_OPTS="--state.scheme=hash"
|
||||
fi
|
||||
|
||||
echo Initializing geth...
|
||||
echo "Initializing geth..."
|
||||
geth --datadir ${DATA_DIR} ${STATE_SCHEME_OPTS} init ${BSC_GENESIS}
|
||||
echo Initialization done
|
||||
echo "Initialization done"
|
||||
fi
|
||||
|
||||
# TODO: Check for archive mode flag
|
||||
exec "geth" \
|
||||
--config="${BSC_CONFIG}" \
|
||||
--datadir="${DATA_DIR}" \
|
||||
@ -61,4 +74,5 @@ exec "geth" \
|
||||
--verbosity=${CERC_GETH_VERBOSITY} \
|
||||
--metrics \
|
||||
--metrics.addr="0.0.0.0" \
|
||||
${ADDITIONAL_FLAGS} \
|
||||
"$@"
|
||||
|
Loading…
Reference in New Issue
Block a user