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
# Use snapshot if provided
# Take first file with extension .tar.lz4 from the snapshot dir
snapshot_file=$((ls /var/tmp/snapshot/*.tar.lz4) 2>/dev/null | head -1)
# Take first file from the snapshot dir
snapshot_file=$((ls /var/tmp/snapshot/) 2>/dev/null | head -1)
geth_dir=${DATA_DIR}/geth
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 is different than that for mainnet
lz4 -d ${snapshot_file} | tar -C ${DATA_DIR}/ -xvf - --strip-components=3 server/testnet/dataseed/geth
else
lz4 -d ${snapshot_file} | tar -C ${DATA_DIR}/ -xvf - --strip-components=2 server/data-seed/geth
fi
temp_dir=$(mktemp -d)
case $snapshot_file in
*.lz4)
lz4 -d $snapshot_file | tar -C $temp_dir -xvf -
;;
*.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
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
# Add lz4 for extracting files from a lz4 snapshot
RUN apk add lz4
# Add lz4, zstd and tar for extracting snapshot files
RUN apk add lz4 zstd tar
USER bsc