Add config for geth dir path in snapshot archive #2

Merged
ashwin merged 1 commits from pm-update-config into main 2024-06-06 04:33:26 +00:00
3 changed files with 17 additions and 9 deletions

View File

@ -5,6 +5,7 @@ services:
environment: environment:
CERC_BSC_NETWORK: ${CERC_BSC_NETWORK:-mainnet} CERC_BSC_NETWORK: ${CERC_BSC_NETWORK:-mainnet}
CERC_USE_SNAPSHOT: ${CERC_USE_SNAPSHOT:-false} CERC_USE_SNAPSHOT: ${CERC_USE_SNAPSHOT:-false}
CERC_SNAPSHOT_GETH_PATH: ${CERC_SNAPSHOT_GETH_PATH}
CERC_FAST_NODE: ${CERC_FAST_NODE:-false} CERC_FAST_NODE: ${CERC_FAST_NODE:-false}
CERC_GETH_GCMODE: ${CERC_GETH_GCMODE:-full} CERC_GETH_GCMODE: ${CERC_GETH_GCMODE:-full}
CERC_GETH_VERBOSITY: ${CERC_GETH_VERBOSITY:-3} CERC_GETH_VERBOSITY: ${CERC_GETH_VERBOSITY:-3}

View File

@ -28,20 +28,23 @@ ADDITIONAL_FLAGS=""
if [ ! -d "$geth_dir" ] && [ "${CERC_USE_SNAPSHOT}" = "true" ] && [ -n "$snapshot_file" ]; then if [ ! -d "$geth_dir" ] && [ "${CERC_USE_SNAPSHOT}" = "true" ] && [ -n "$snapshot_file" ]; then
echo "Using snapshot $snapshot_file" echo "Using snapshot $snapshot_file"
if [ -z "$CERC_SNAPSHOT_GETH_PATH" ]; then
echo CERC_SNAPSHOT_GETH_PATH not set
exit 1
else
# Remove any trailing / from the given path
archive_geth_path=$(echo "$CERC_SNAPSHOT_GETH_PATH" | sed 's:/*$::')
# Determine strip-components count from the geth dir path
to_strip=$(echo "$archive_geth_path" | grep -o '/' | wc -l)
fi
case $snapshot_file in case $snapshot_file in
*.lz4) *.lz4)
# Determine where geth dir is located # Extract geth data directly to destination directory
archive_geth_path=$(lz4 -c -d $snapshot_file | tar -tf - | grep -m1 -E 'geth/?$')
# Determine strip-components count from the path
to_strip=$(($(echo "$archive_geth_path" | grep -o '/' | wc -l) - 1))
lz4 -c -d $snapshot_file | tar -C ${DATA_DIR}/ -xvf - --strip-components=$to_strip $archive_geth_path lz4 -c -d $snapshot_file | tar -C ${DATA_DIR}/ -xvf - --strip-components=$to_strip $archive_geth_path
;; ;;
*.zst) *.zst)
archive_geth_path=$(zstd -c -d $snapshot_file | tar -tf - | grep -m1 -E 'geth/?$')
to_strip=$(($(echo "$archive_geth_path" | grep -o '/' | wc -l) - 1))
zstd -c -d $snapshot_file | tar -C ${DATA_DIR}/ -xvf - --strip-components=$to_strip $archive_geth_path zstd -c -d $snapshot_file | tar -C ${DATA_DIR}/ -xvf - --strip-components=$to_strip $archive_geth_path
;; ;;
*) *)

View File

@ -64,6 +64,10 @@ Instructions for running a BSC node
# Requires snapshot file with extension .tar.lz4 or .tar.zst to be placed in the snapshot directory # Requires snapshot file with extension .tar.lz4 or .tar.zst to be placed in the snapshot directory
CERC_USE_SNAPSHOT= CERC_USE_SNAPSHOT=
# Path where geth dir is located in the snapshot archive
# Required when using a snapshot; example: "server/data-seed/geth"
CERC_SNAPSHOT_GETH_PATH=
# Whether to run as a fast node (true | false) (default: false) # Whether to run as a fast node (true | false) (default: false)
# Fast node does not generate trie data when syncing # Fast node does not generate trie data when syncing
CERC_FAST_NODE= CERC_FAST_NODE=