Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
50 changes: 36 additions & 14 deletions alerts/periodic_sender.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ if [[ -z "$ENV_FILE" ]]; then
exit 1
fi

function send_proof_background() {
./alerts/sender_with_alert.sh "$ENV_FILE" &
}

# Fetches the current ETH gas price
function fetch_gas_price() {
gas_price=$(cast gas-price --rpc-url $RPC_URL)
Expand All @@ -23,8 +27,8 @@ function fetch_gas_price() {

source "$ENV_FILE"

# Each elapsed interval lasts for 30 minutes
sleep_time=1800
# Each elapsed interval lasts for 5 minutes
sleep_time=300
elapsed_intervals=0

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

# In case current and gas price meet the criteria, send a proof and reset counter
if { [ $elapsed_intervals -ge 10 ] && [ $elapsed_intervals -lt 14 ] && [ $current_gas_price -lt 2000000000 ]; }; then
# Between 10 and 14 elapsed intervals (5 to 7 hours), if gas price is below 2 gwei, send a proof
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
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
echo "$message"
send_proof_background
elapsed_intervals=0
elif { [ $elapsed_intervals -ge 3 ] && [ $elapsed_intervals -lt 6 ] && [ $current_gas_price -lt 4500000000 ]; }; then
# Between 3 and 6 elapsed intervals (15 to 30 minutes), if gas price is below 4.5 gwei, send a proof
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
echo "$message"
send_proof_background
elapsed_intervals=0
elif { [ $elapsed_intervals -ge 6 ] && [ $elapsed_intervals -lt 12 ] && [ $current_gas_price -lt 9000000000 ]; }; then
# Between 6 and 12 elapsed intervals (30 minutes to 1 hour), if gas price is below 9 gwei, send a proof
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
echo "$message"
send_proof_background
elapsed_intervals=0
elif { [ $elapsed_intervals -ge 12 ] && [ $elapsed_intervals -lt 24 ] && [ $current_gas_price -lt 24000000000 ]; }; then
# Between 12 and 24 elapsed intervals (1 to 2 hours), if gas price is below 24 gwei, send a proof
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
echo "$message"
./alerts/sender_with_alert.sh "$ENV_FILE"
send_proof_background
elapsed_intervals=0
elif { [ $elapsed_intervals -ge 14 ] && [ $elapsed_intervals -lt 16 ] && [ $current_gas_price -lt 5000000000 ]; }; then
# Between 14 and 16 elapsed intervals (7 to 8 hours), if gas price is below 5 gwei, send a proof
elif { [ $elapsed_intervals -ge 24 ] && [ $elapsed_intervals -lt 48 ] && [ $current_gas_price -lt 48000000000 ]; }; then
# Between 24 and 48 elapsed intervals (2 to 4 hours), if gas price is below 48 gwei, send a proof
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
echo "$message"
./alerts/sender_with_alert.sh "$ENV_FILE"
send_proof_background
elapsed_intervals=0
elif { [ $elapsed_intervals -ge 16 ] && [ $elapsed_intervals -lt 24 ] && [ $current_gas_price -lt 15000000000 ]; }; then
# Between 16 and 24 elapsed intervals (8 to 12 hours), if gas price is below 15 gwei, send a proof
elif { [ $elapsed_intervals -ge 48 ] && [ $elapsed_intervals -lt 96 ] && [ $current_gas_price -lt 96000000000 ]; }; then
# Between 48 and 96 elapsed intervals (4 to 8 hours), if gas price is below 96 gwei, send a proof
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
echo "$message"
./alerts/sender_with_alert.sh "$ENV_FILE"
send_proof_background
elapsed_intervals=0
elif { [ $elapsed_intervals -ge 50 ]; }; then
# After 50 elapsed intervals (25 hours) send a proof
elif { [ $elapsed_intervals -ge 96 ] && [ $current_gas_price -lt 192000000000 ]; }; then
# After 96 elapsed intervals (8 hours), if gas price is below 192 gwei, send a proof
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
echo "$message"
./alerts/sender_with_alert.sh "$ENV_FILE"
send_proof_background
elapsed_intervals=0
fi

Expand Down
6 changes: 5 additions & 1 deletion alerts/sender_with_alert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ x=$((nonce + 1)) # So we don't have any issues with nonce = 0
echo "Generating proof $x != 0, nonce: $nonce"
go run ./scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go $x

verification_data_dir="./aligned_verification_data_$x"
mkdir -p $verification_data_dir

## Send Proof
echo "Submitting $REPETITIONS proofs $x != 0"
submit=$(aligned submit \
Expand All @@ -113,6 +116,7 @@ submit=$(aligned submit \
--network $NETWORK \
--max_fee 0.004ether \
--random_address \
--aligned_verification_data_path $verification_data_dir \
2>&1)

echo "$submit"
Expand Down Expand Up @@ -221,6 +225,6 @@ send_slack_message "$slack_message"

## Remove Proof Data
rm -rf ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/*
rm -rf ./aligned_verification_data/*
rm -rf ./aligned_verification_data_$x

exit 0