Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions alerts/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ NETWORK=<NETWORK>
PRIVATE_KEY=<SENDER_PRIVATE_KEY>
VERIFICATION_WAIT_TIME=<TIME_TO_WAIT_FOR_VERIFICATION>
LOGS_BLOCK_RANGE=<LOGS_BLOCK_RANGE>
BATCHER_METRICS_URL=<BATCHER_METRICS_URL>

# Variables for aggregation_mode_alerts.sh
CONTRACT_ADDRESS=<YOUR_CONTRACT_ADDRESS>
Expand Down
14 changes: 14 additions & 0 deletions alerts/periodic_sender.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ function fetch_gas_price() {
echo $gas_price
}

# Get batcher queue len
function get_queue_length() {
queue_len=$(curl $BATCHER_METRICS_URL -s | grep queue_len | awk '{print $2}' | tail -n 1)
echo $queue_len
}

source "$ENV_FILE"

# Each elapsed interval lasts for 5 minutes
Expand All @@ -48,6 +54,14 @@ while true; do
fi
echo "Current gas price: $current_gas_price wei"

queue_len=$(get_queue_length)
if [ "$queue_len" -eq 0 ]; then
echo "There are no pending proofs in the queue, skipping this pass."
echo "Sleeping $sleep_time seconds (($((sleep_time / 60)) minutes))"
sleep "$sleep_time"
continue
fi

# In case current and gas price meet the criteria, send a proof and reset counter
if { [ $elapsed_intervals -ge 1 ] && [ $elapsed_intervals -lt 3 ] && [ $current_gas_price -lt 1500000000 ]; }; then
# Between 1 and 3 elapsed intervals (5 to 15 minutes), if gas price is below 1.5 gwei, send a proof
Expand Down