From 6c8e1f3810e49f05a7528f609f02ec23766c3ef7 Mon Sep 17 00:00:00 2001 From: KENDAL Date: Mon, 24 Aug 2026 11:37:59 +0300 Subject: [PATCH] fix(scripts): fix progress calculation message, handle fully synced state, and strip binary checksum prefix --- progress.sh | 33 ++++++++++++++++++--------------- scripts/utils.sh | 1 + 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/progress.sh b/progress.sh index 204d9ab..dc923ce 100755 --- a/progress.sh +++ b/progress.sh @@ -59,25 +59,28 @@ echo "Blocks per minute: $PER_MIN" # Get L2 head block with error handling HEAD=$(cast block-number --rpc-url "$L2_URL" 2>/dev/null) || error_exit "Failed to get L2 block number" BEHIND=$((HEAD - T1)) -[ $BEHIND -lt 0 ] && error_exit "L2 is ahead of local node" +if [ $BEHIND -lt 0 ]; then + error_exit "Local node is ahead of remote L2 RPC endpoint (local: $T1, remote: $HEAD)" +fi + +if [ $BEHIND -eq 0 ]; then + echo "Local node is fully synced with L2 head (block $HEAD)." + exit 0 +fi # Calculate time estimates echo "Calculating time estimates..." MINUTES=$((BEHIND / PER_MIN)) HOURS=$((MINUTES / 60)) -if [ $MINUTES -le 60 ] ; then - echo "Sync will complete in minutes" - echo "Minutes until sync completed: $MINUTES" -fi - -if [ $MINUTES -gt 60 ] ; then - echo "Sync will take hours" - echo "Hours until sync completed: $HOURS" -fi - -if [ $HOURS -gt 24 ] ; then - echo "Sync will take days" - DAYS=$((HOURS / 24)) - echo "Days until sync complete: $DAYS" +if [ $HOURS -ge 24 ]; then + DAYS=$((HOURS / 24)) + echo "Sync will take days" + echo "Days until sync complete: $DAYS (approx $HOURS hours)" +elif [ $MINUTES -ge 60 ]; then + echo "Sync will take hours" + echo "Hours until sync completed: $HOURS (approx $MINUTES minutes)" +else + echo "Sync will complete in minutes" + echo "Minutes until sync completed: $MINUTES" fi diff --git a/scripts/utils.sh b/scripts/utils.sh index fa5293c..2c72cc0 100755 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -52,6 +52,7 @@ function verify_sha256_checksum() { local expected_hash checksum_name extra actual_hash read -r expected_hash checksum_name extra < "$checksum_path" + checksum_name="${checksum_name#\*}" if [[ -z "$expected_hash" || -z "$checksum_name" || -n "$extra" ]]; then echo "Unexpected checksum file format: $checksum_path" >&2