@@ -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
91110nonce=$( aligned get-user-nonce --network $NETWORK --user_addr $SENDER_ADDRESS 2>&1 | awk ' {print $9}' )
92111echo $nonce
93112if ! [[ " $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
97115fi
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
134153done <<< " $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 "
223243echo " $slack_message "
224244send_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
227253rm -rf ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/*
228254rm -rf ./aligned_verification_data_$x
0 commit comments