Add a stack to run a BSC node #1

Merged
ashwin merged 16 commits from pm-bsc-stack into main 2024-06-05 12:28:20 +00:00
2 changed files with 22 additions and 10 deletions
Showing only changes of commit 2b1fcebab2 - Show all commits

View File

@ -21,19 +21,31 @@ else
fi fi
# Use snapshot if provided # Use snapshot if provided
# Take first file with extension .tar.lz4 from the snapshot dir # Take first file from the snapshot dir
snapshot_file=$((ls /var/tmp/snapshot/*.tar.lz4) 2>/dev/null | head -1) snapshot_file=$((ls /var/tmp/snapshot/) 2>/dev/null | head -1)
geth_dir=${DATA_DIR}/geth geth_dir=${DATA_DIR}/geth
ADDITIONAL_FLAGS="" 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 [ "$CERC_BSC_NETWORK" = "testnet" ]; then temp_dir=$(mktemp -d)
# Snapshot dir structure for testnet is different than that for mainnet case $snapshot_file in
lz4 -d ${snapshot_file} | tar -C ${DATA_DIR}/ -xvf - --strip-components=3 server/testnet/dataseed/geth *.lz4)
else lz4 -d $snapshot_file | tar -C $temp_dir -xvf -
lz4 -d ${snapshot_file} | tar -C ${DATA_DIR}/ -xvf - --strip-components=2 server/data-seed/geth ;;
fi *.zst)
zstd -c -d $snapshot_file | tar -C $temp_dir -xvf -
;;
*)
echo "Unsupported archive format for the snapshot file: $snapshot_file"
exit 1
;;
esac
# Move geth data to data dir
extracted_geth_dir=$(find $temp_dir -type d -name "geth" -print -quit)
mv $extracted_geth_dir ${DATA_DIR}/
rm -rf $temp_dir
if [ "${CERC_FAST_NODE}" = "true" ]; then if [ "${CERC_FAST_NODE}" = "true" ]; then
echo "Pruning trie data and turning snapshot verification off" echo "Pruning trie data and turning snapshot verification off"

View File

@ -2,7 +2,7 @@ FROM ghcr.io/bnb-chain/bsc:1.4.8
USER root USER root
# Add lz4 for extracting files from a lz4 snapshot # Add lz4, zstd and tar for extracting snapshot files
RUN apk add lz4 RUN apk add lz4 zstd tar
USER bsc USER bsc