Skip to content

Commit 9441244

Browse files
write each batch info to a daily log file
1 parent 9a8a88d commit 9441244

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

alerts/sender_with_alert.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,25 @@ function send_slack_message() {
7979
. alerts/slack.sh "$1"
8080
}
8181

82+
LOG_DIR_PATH="./alerts/notification_logs/log_$date_only.txt"
83+
# Creates a log entry in the daily log file
84+
function create_log_entry() {
85+
status="$1"
86+
reason="${2:-}"
87+
88+
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
89+
90+
# Keep the date to get the file name
91+
date_only=$(date +"%Y_%m_%d")
92+
93+
# Check if file exists, if not create it
94+
if [ ! -f "$LOG_DIR_PATH" ]; then
95+
touch "$LOG_DIR_PATH"
96+
fi
97+
98+
echo "[$timestamp] $status: - $reason" >> "$LOG_DIR_PATH"
99+
}
100+
82101
################# SEND LOGIC #################
83102

84103
## Remove Proof Data
@@ -91,8 +110,7 @@ mkdir -p ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proof
91110
nonce=$(aligned get-user-nonce --network $NETWORK --user_addr $SENDER_ADDRESS 2>&1 | awk '{print $9}')
92111
echo $nonce
93112
if ! [[ "$nonce" =~ ^[0-9]+$ ]]; then
94-
echo "Failed getting user nonce, retrying in 10 seconds"
95-
sleep 10
113+
echo "Failed getting user nonce, exiting"
96114
exit 0
97115
fi
98116

@@ -129,6 +147,7 @@ while IFS= read -r error; do
129147
if [[ -n "$error" ]]; then
130148
slack_error_message="Error submitting proof to $NETWORK: $error"
131149
send_slack_message "$slack_error_message"
150+
create_log_entry "ERROR" "Error submitting proof to $NETWORK: $error"
132151
is_error=1
133152
fi
134153
done <<< "$submit_errors"
@@ -207,6 +226,7 @@ for proof in ./aligned_verification_data/*.cbor; do
207226
echo "$message"
208227
send_pagerduty_alert "$message"
209228
verified=0 # Some proofs failed, so we should not send the success message
229+
create_log_entry "FAILURE" "Proof verification failed for $proof"
210230
break
211231
elif echo "$verification" | grep -q verified; then
212232
echo "Proof verification succeeded for $proof"
@@ -223,6 +243,12 @@ fi
223243
echo "$slack_message"
224244
send_slack_message "$slack_message"
225245

246+
if [ $verified -eq 1 ]; then
247+
create_log_entry "SUCCESS" "$total_number_proofs proofs submitted and verified ($REPETITIONS sent). Spent $spent_amount ETH ($ $spent_amount_usd) [ ${batch_explorer_urls[@]} ]"
248+
else
249+
create_log_entry "FAILURE" "$total_number_proofs proofs submitted but not verified ($REPETITIONS sent). Spent $spent_amount ETH ($ $spent_amount_usd) [ ${batch_explorer_urls[@]} ]"
250+
fi
251+
226252
## Remove Proof Data
227253
rm -rf ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/*
228254
rm -rf ./aligned_verification_data_$x

0 commit comments

Comments
 (0)