Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-shashank committed May 17, 2024
1 parent 5f6cc57 commit 0a8137e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ansible/archival-snapshots/resources/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[client]
data_dir = "/mnt/md0/forest-data-new"
data_dir = "/mnt/md0/forest-archival-data"
encrypt_keystore = false
22 changes: 21 additions & 1 deletion ansible/archival-snapshots/resources/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ set -euxo pipefail
GENESIS_TIMESTAMP=1598306400
SECONDS_PER_EPOCH=30

FOREST="/mnt/md0/exported/archival/forest-v0.17.2/forest"
FOREST_CLI="/mnt/md0/exported/archival/forest-v0.17.2/forest-cli"
FOREST_TOOL="/mnt/md0/exported/archival/forest-v0.17.2/forest-tool"

CURRENT_SNAPSHOT=$(aws --profile prod --endpoint "$ENDPOINT" s3 ls "s3://forest-archive/mainnet/lite/" | sort | tail -n 1 | awk '{print $NF}')
CURRENT_EPOCH=$(echo "$CURRENT_SNAPSHOT" | awk -F'_' '{gsub(/[^0-9]/, "", $6); print $6}')
FULL_SNAPSHOTS_DIR=/mnt/md0/exported/snapshots
FULL_SNAPSHOTS_DIR=/mnt/md0/exported/archival/snapshots
CURRENT_FULL_SNAPSHOT_PATH="$FULL_SNAPSHOTS_DIR/$CURRENT_SNAPSHOT"
LITE_SNAPSHOT_DIR=/mnt/md0/exported/archival/lite_snapshots

Expand All @@ -20,6 +21,23 @@ if [ ! -d "$FULL_SNAPSHOTS_DIR" ]; then
mkdir -p "$FULL_SNAPSHOTS_DIR"
fi

if [ ! -f "$CURRENT_FULL_SNAPSHOT_PATH" ]; then
echo "Downloading last snapshot: $CURRENT_FULL_SNAPSHOT_PATH"
aws --profile prod --endpoint "$ENDPOINT" s3 cp "s3://forest-archive/mainnet/lite/$CURRENT_SNAPSHOT" "$CURRENT_FULL_SNAPSHOT_PATH"
echo "Last snapshot download: $CURRENT_FULL_SNAPSHOT_PATH"
else
echo "$CURRENT_FULL_SNAPSHOT_PATH snapshot already exists."
fi

echo "Starting forest daemon"
$FOREST --config ./config.toml --save-token ./admin_token --rpc-address 127.0.0.1:3456 --metrics-address 127.0.0.1:5000 --import-snapshot "$CURRENT_FULL_SNAPSHOT_PATH" &
FOREST_NODE_PID=$!

export FULLNODE_API_INFO="$(cat admin_token):/ip4/127.0.0.1/tcp/3456/http"

echo "Waiting for forest to sync to latest network head"
$FOREST_CLI sync wait

# Get latest epoch using sync status
echo "Current Height: $CURRENT_EPOCH"
LATEST_EPOCH=$($FOREST_CLI sync status | grep "Height:" | awk '{print $2}')
Expand Down Expand Up @@ -71,3 +89,5 @@ while ((LATEST_EPOCH - CURRENT_EPOCH > 30000)); do
CURRENT_EPOCH=$NEW_EPOCH
mv "$NEW_SNAPSHOT" "$FULL_SNAPSHOTS_DIR"
done

kill -KILL $FOREST_NODE_PID

0 comments on commit 0a8137e

Please sign in to comment.