Skip to content

Commit 9a8a88d

Browse files
fix: update periodic sender script conditions (#2162)
1 parent 895cd41 commit 9a8a88d

File tree

2 files changed

+41
-15
lines changed

2 files changed

+41
-15
lines changed

alerts/periodic_sender.sh

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ if [[ -z "$ENV_FILE" ]]; then
1010
exit 1
1111
fi
1212

13+
function send_proof_background() {
14+
./alerts/sender_with_alert.sh "$ENV_FILE" &
15+
}
16+
1317
# Fetches the current ETH gas price
1418
function fetch_gas_price() {
1519
gas_price=$(cast gas-price --rpc-url $RPC_URL)
@@ -23,8 +27,8 @@ function fetch_gas_price() {
2327

2428
source "$ENV_FILE"
2529

26-
# Each elapsed interval lasts for 30 minutes
27-
sleep_time=1800
30+
# Each elapsed interval lasts for 5 minutes
31+
sleep_time=300
2832
elapsed_intervals=0
2933

3034
./alerts/sender_with_alert.sh "$ENV_FILE"
@@ -45,29 +49,47 @@ while true; do
4549
echo "Current gas price: $current_gas_price wei"
4650

4751
# In case current and gas price meet the criteria, send a proof and reset counter
48-
if { [ $elapsed_intervals -ge 10 ] && [ $elapsed_intervals -lt 14 ] && [ $current_gas_price -lt 2000000000 ]; }; then
49-
# Between 10 and 14 elapsed intervals (5 to 7 hours), if gas price is below 2 gwei, send a proof
52+
if { [ $elapsed_intervals -ge 1 ] && [ $elapsed_intervals -lt 3 ] && [ $current_gas_price -lt 1500000000 ]; }; then
53+
# Between 1 and 3 elapsed intervals (5 to 15 minutes), if gas price is below 1.5 gwei, send a proof
54+
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
55+
echo "$message"
56+
send_proof_background
57+
elapsed_intervals=0
58+
elif { [ $elapsed_intervals -ge 3 ] && [ $elapsed_intervals -lt 6 ] && [ $current_gas_price -lt 4500000000 ]; }; then
59+
# Between 3 and 6 elapsed intervals (15 to 30 minutes), if gas price is below 4.5 gwei, send a proof
60+
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
61+
echo "$message"
62+
send_proof_background
63+
elapsed_intervals=0
64+
elif { [ $elapsed_intervals -ge 6 ] && [ $elapsed_intervals -lt 12 ] && [ $current_gas_price -lt 9000000000 ]; }; then
65+
# Between 6 and 12 elapsed intervals (30 minutes to 1 hour), if gas price is below 9 gwei, send a proof
66+
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
67+
echo "$message"
68+
send_proof_background
69+
elapsed_intervals=0
70+
elif { [ $elapsed_intervals -ge 12 ] && [ $elapsed_intervals -lt 24 ] && [ $current_gas_price -lt 24000000000 ]; }; then
71+
# Between 12 and 24 elapsed intervals (1 to 2 hours), if gas price is below 24 gwei, send a proof
5072
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
5173
echo "$message"
52-
./alerts/sender_with_alert.sh "$ENV_FILE"
74+
send_proof_background
5375
elapsed_intervals=0
54-
elif { [ $elapsed_intervals -ge 14 ] && [ $elapsed_intervals -lt 16 ] && [ $current_gas_price -lt 5000000000 ]; }; then
55-
# Between 14 and 16 elapsed intervals (7 to 8 hours), if gas price is below 5 gwei, send a proof
76+
elif { [ $elapsed_intervals -ge 24 ] && [ $elapsed_intervals -lt 48 ] && [ $current_gas_price -lt 48000000000 ]; }; then
77+
# Between 24 and 48 elapsed intervals (2 to 4 hours), if gas price is below 48 gwei, send a proof
5678
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
5779
echo "$message"
58-
./alerts/sender_with_alert.sh "$ENV_FILE"
80+
send_proof_background
5981
elapsed_intervals=0
60-
elif { [ $elapsed_intervals -ge 16 ] && [ $elapsed_intervals -lt 24 ] && [ $current_gas_price -lt 15000000000 ]; }; then
61-
# Between 16 and 24 elapsed intervals (8 to 12 hours), if gas price is below 15 gwei, send a proof
82+
elif { [ $elapsed_intervals -ge 48 ] && [ $elapsed_intervals -lt 96 ] && [ $current_gas_price -lt 96000000000 ]; }; then
83+
# Between 48 and 96 elapsed intervals (4 to 8 hours), if gas price is below 96 gwei, send a proof
6284
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
6385
echo "$message"
64-
./alerts/sender_with_alert.sh "$ENV_FILE"
86+
send_proof_background
6587
elapsed_intervals=0
66-
elif { [ $elapsed_intervals -ge 50 ]; }; then
67-
# After 50 elapsed intervals (25 hours) send a proof
88+
elif { [ $elapsed_intervals -ge 96 ] && [ $current_gas_price -lt 192000000000 ]; }; then
89+
# After 96 elapsed intervals (8 hours), if gas price is below 192 gwei, send a proof
6890
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
6991
echo "$message"
70-
./alerts/sender_with_alert.sh "$ENV_FILE"
92+
send_proof_background
7193
elapsed_intervals=0
7294
fi
7395

alerts/sender_with_alert.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ x=$((nonce + 1)) # So we don't have any issues with nonce = 0
100100
echo "Generating proof $x != 0, nonce: $nonce"
101101
go run ./scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go $x
102102

103+
verification_data_dir="./aligned_verification_data_$x"
104+
mkdir -p $verification_data_dir
105+
103106
## Send Proof
104107
echo "Submitting $REPETITIONS proofs $x != 0"
105108
submit=$(aligned submit \
@@ -113,6 +116,7 @@ submit=$(aligned submit \
113116
--network $NETWORK \
114117
--max_fee 0.004ether \
115118
--random_address \
119+
--aligned_verification_data_path $verification_data_dir \
116120
2>&1)
117121

118122
echo "$submit"
@@ -221,6 +225,6 @@ send_slack_message "$slack_message"
221225

222226
## Remove Proof Data
223227
rm -rf ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/*
224-
rm -rf ./aligned_verification_data/*
228+
rm -rf ./aligned_verification_data_$x
225229

226230
exit 0

0 commit comments

Comments
 (0)