Skip to content

Commit 0caa258

Browse files
committed
feat(task sender): send proofs if there are proofs queued in the batcher
1 parent 28c5660 commit 0caa258

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

alerts/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ NETWORK=<NETWORK>
3333
PRIVATE_KEY=<SENDER_PRIVATE_KEY>
3434
VERIFICATION_WAIT_TIME=<TIME_TO_WAIT_FOR_VERIFICATION>
3535
LOGS_BLOCK_RANGE=<LOGS_BLOCK_RANGE>
36+
BATCHER_METRICS_URL=<BATCHER_METRICS_URL>
3637

3738
# Variables for aggregation_mode_alerts.sh
3839
CONTRACT_ADDRESS=<YOUR_CONTRACT_ADDRESS>

alerts/periodic_sender.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ function fetch_gas_price() {
2525
echo $gas_price
2626
}
2727

28+
# Get batcher queue len
29+
function get_queue_length() {
30+
queue_len=$(curl $BATCHER_METRICS_URL -s | grep queue_len | awk '{print $2}' | tail -n 1)
31+
echo $queue_len
32+
}
33+
2834
source "$ENV_FILE"
2935

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

57+
queue_len=$(get_queue_length)
58+
if [ "$queue_len" -eq 0 ]; then
59+
echo "There are no pending proofs in the queue, skipping this pass."
60+
echo "Sleeping $sleep_time seconds (($((sleep_time / 60)) minutes))"
61+
sleep "$sleep_time"
62+
continue
63+
fi
64+
5165
# In case current and gas price meet the criteria, send a proof and reset counter
5266
if { [ $elapsed_intervals -ge 1 ] && [ $elapsed_intervals -lt 3 ] && [ $current_gas_price -lt 1500000000 ]; }; then
5367
# Between 1 and 3 elapsed intervals (5 to 15 minutes), if gas price is below 1.5 gwei, send a proof

0 commit comments

Comments
 (0)