Skip to content

Commit 7d8e37a

Browse files
Merge branch 'staging' into feat/aggregation-mode-rename-endpoints
2 parents e16d14c + 5844e61 commit 7d8e37a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+21092
-790
lines changed

.github/workflows/build-and-test-go.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ jobs:
3939

4040
- name: Build Merkle Tree bindings
4141
run: make build_merkle_tree_linux
42-
42+
43+
- name: Build Mina bindings
44+
run: make build_mina_linux
45+
46+
- name: Build Mina Account bindings
47+
run: make build_mina_account_linux
48+
4349
- name: Build operator
4450
run: go build operator/cmd/main.go
4551

.github/workflows/test-mina.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: test-mina
2+
3+
on:
4+
merge_group:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: ["*"]
9+
paths:
10+
- 'operator/mina/**'
11+
- 'operator/mina_account/**'
12+
- '.github/workflows/test-mina.yml'
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version: '1.22'
22+
cache: false
23+
- uses: actions-rs/toolchain@v1
24+
with:
25+
toolchain: stable
26+
- name: Test Mina Rust
27+
run: make test_mina_rust_ffi
28+
- name: Test Mina go bindings
29+
run: make test_mina_go_bindings_linux
30+
- name: Test Mina Account Rust
31+
run: make test_mina_account_rust_ffi
32+
- name: Test Mina Account go bindings
33+
run: make test_mina_account_go_bindings_linux

Makefile

Lines changed: 127 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ ifeq ($(OS),Darwin)
3232
endif
3333

3434
ifeq ($(OS),Linux)
35-
export LD_LIBRARY_PATH+=$(CURDIR)/operator/risc_zero/lib:$(CURDIR)/operator/sp1/lib
36-
OPERATOR_FFIS=$(CURDIR)/operator/risc_zero/lib:$(CURDIR)/operator/sp1/lib
35+
export LD_LIBRARY_PATH+=$(CURDIR)/operator/risc_zero/lib:$(CURDIR)/operator/sp1/lib:$(CURDIR)/operator/mina/lib:$(CURDIR)/operator/mina_account/lib
36+
OPERATOR_FFIS=$(CURDIR)/operator/risc_zero/lib:$(CURDIR)/operator/sp1/lib:$(CURDIR)/operator/mina/lib:$(CURDIR)/operator/mina_account/lib
3737
endif
3838

3939
ifeq ($(OS),Linux)
@@ -721,6 +721,58 @@ batcher_send_circom_groth16_bn256_no_pub_input_burst: crates/target/release/alig
721721
--rpc_url $(RPC_URL) \
722722
--network $(NETWORK)
723723

724+
batcher_send_mina_task:
725+
@echo "Sending Mina state task to Batcher..."
726+
@cd crates/cli/ && cargo run --release -- submit \
727+
--proving_system Mina \
728+
--proof ../../scripts/test_files/mina/devnet_mina_state.proof \
729+
--public_input ../../scripts/test_files/mina/devnet_mina_state.pub \
730+
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
731+
--rpc_url $(RPC_URL) \
732+
--network $(NETWORK)
733+
734+
batcher_send_mina_task_bad_hash:
735+
@echo "Sending Mina state task to Batcher..."
736+
@cd crates/cli/ && cargo run --release -- submit \
737+
--proving_system Mina \
738+
--proof ../../scripts/test_files/mina/devnet_mina_state.proof \
739+
--public_input ../../scripts/test_files/mina/mina_state_bad_hash.pub \
740+
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
741+
--rpc_url $(RPC_URL) \
742+
--network $(NETWORK)
743+
744+
batcher_send_mina_burst:
745+
@echo "Sending Mina state task to Batcher..."
746+
@cd crates/cli/ && cargo run --release -- submit \
747+
--proving_system Mina \
748+
--proof ../../scripts/test_files/mina/devnet_mina_state.proof \
749+
--public_input ../../scripts/test_files/mina/devnet_mina_state.pub \
750+
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
751+
--repetitions $(BURST_SIZE) \
752+
--rpc_url $(RPC_URL) \
753+
--network $(NETWORK)
754+
755+
batcher_send_mina_account_task:
756+
@echo "Sending Mina account task to Batcher..."
757+
@cd crates/cli/ && cargo run --release -- submit \
758+
--proving_system MinaAccount \
759+
--proof ../../scripts/test_files/mina_account/mina_account.proof \
760+
--public_input ../../scripts/test_files/mina_account/mina_account.pub \
761+
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
762+
--rpc_url $(RPC_URL) \
763+
--network $(NETWORK)
764+
765+
batcher_send_mina_account_burst:
766+
@echo "Sending Mina account task to Batcher..."
767+
@cd crates/cli/ && cargo run --release -- submit \
768+
--proving_system MinaAccount \
769+
--proof ../../scripts/test_files/mina_account/mina_account.proof \
770+
--public_input ../../scripts/test_files/mina_account/mina_account.pub \
771+
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
772+
--repetitions $(BURST_SIZE) \
773+
--rpc_url $(RPC_URL) \
774+
--network $(NETWORK)
775+
724776
batcher_send_proof_with_random_address: ## Send a proof with a random address to Batcher. Parameters: RPC_URL, NETWORK, PROOF_TYPE, REPETITIONS
725777
@cd crates/cli/ && ./send_proof_with_random_address.sh
726778

@@ -986,6 +1038,48 @@ test_merkle_tree_go_bindings_linux: build_merkle_tree_linux
9861038
@echo "Testing Merkle Tree Go bindings..."
9871039
go test ./operator/merkle_tree/... -v
9881040

1041+
__MINA_FFI__: ##
1042+
build_mina_macos:
1043+
@cd operator/mina/lib && cargo build --release ${MINA_FEATURES_FLAG}
1044+
@cp operator/mina/lib/target/release/libmina_state_verifier_ffi.dylib operator/mina/lib/libmina_state_verifier_ffi.dylib
1045+
1046+
build_mina_linux:
1047+
@cd operator/mina/lib && cargo build --release ${MINA_FEATURES_FLAG}
1048+
@cp operator/mina/lib/target/release/libmina_state_verifier_ffi.so operator/mina/lib/libmina_state_verifier_ffi.so
1049+
1050+
test_mina_rust_ffi:
1051+
@echo "Testing Mina Rust FFI source code..."
1052+
@cd operator/mina/lib && cargo t --release
1053+
1054+
test_mina_go_bindings_macos: build_mina_macos
1055+
@echo "Testing Mina Go bindings..."
1056+
go test ./operator/mina/... -v
1057+
1058+
test_mina_go_bindings_linux: build_mina_linux
1059+
@echo "Testing Mina Go bindings..."
1060+
go test ./operator/mina/... -v
1061+
1062+
__MINA_ACCOUNT_FFI__: ##
1063+
build_mina_account_macos:
1064+
@cd operator/mina_account/lib && cargo build --release
1065+
@cp operator/mina_account/lib/target/release/libmina_account_verifier_ffi.dylib operator/mina_account/lib/libmina_account_verifier_ffi.dylib
1066+
1067+
build_mina_account_linux:
1068+
@cd operator/mina_account/lib && cargo build --release
1069+
@cp operator/mina_account/lib/target/release/libmina_account_verifier_ffi.so operator/mina_account/lib/libmina_account_verifier_ffi.so
1070+
1071+
test_mina_account_rust_ffi:
1072+
@echo "Testing Mina Account Rust FFI source code..."
1073+
@cd operator/mina_account/lib && cargo t --release
1074+
1075+
test_mina_account_go_bindings_macos: build_mina_account_macos
1076+
@echo "Testing Mina Account Go bindings..."
1077+
go test ./operator/mina_account/... -v
1078+
1079+
test_mina_account_go_bindings_linux: build_mina_account_linux
1080+
@echo "Testing Mina Account Go bindings..."
1081+
go test ./operator/mina_account/... -v
1082+
9891083
__FFI__: ## ____
9901084

9911085
build_all_ffi: ## Build all FFIs
@@ -997,13 +1091,17 @@ build_all_ffi_macos: ## Build all FFIs for macOS
9971091
@$(MAKE) build_sp1_macos
9981092
@$(MAKE) build_risc_zero_macos
9991093
@$(MAKE) build_merkle_tree_macos
1094+
@$(MAKE) build_mina_macos
1095+
@$(MAKE) build_mina_account_macos
10001096
@echo "All macOS FFIs built successfully."
10011097

10021098
build_all_ffi_linux: ## Build all FFIs for Linux
10031099
@echo "Building all FFIs for Linux..."
10041100
@$(MAKE) build_sp1_linux
10051101
@$(MAKE) build_risc_zero_linux
10061102
@$(MAKE) build_merkle_tree_linux
1103+
@$(MAKE) build_mina_linux
1104+
@$(MAKE) build_mina_account_linux
10071105
@echo "All Linux FFIs built successfully."
10081106

10091107
__EXPLORER__: ## ____
@@ -1211,6 +1309,30 @@ docker_batcher_send_circom_groth16_bn256_no_pub_input_burst:
12111309
--rpc_url $(DOCKER_RPC_URL) \
12121310
--max_fee 0.1ether
12131311

1312+
docker_batcher_send_mina_burst:
1313+
@echo "Sending Mina state task to Batcher..."
1314+
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') aligned submit \
1315+
--private_key $(DOCKER_PROOFS_PRIVATE_KEY) \
1316+
--proving_system Mina \
1317+
--proof ./scripts/test_files/mina/devnet_mina_state.proof \
1318+
--public_input ./scripts/test_files/mina/devnet_mina_state.pub \
1319+
--repetitions $(DOCKER_BURST_SIZE) \
1320+
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
1321+
--rpc_url $(DOCKER_RPC_URL) \
1322+
--max_fee 0.1ether
1323+
1324+
docker_batcher_send_mina_account_burst:
1325+
@echo "Sending Mina account task to Batcher..."
1326+
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') aligned submit \
1327+
--private_key $(DOCKER_PROOFS_PRIVATE_KEY) \
1328+
--proving_system MinaAccount \
1329+
--proof ./scripts/test_files/mina_account/mina_account.proof \
1330+
--public_input ./scripts/test_files/mina_account/mina_account.pub \
1331+
--repetitions $(DOCKER_BURST_SIZE) \
1332+
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
1333+
--rpc_url $(DOCKER_RPC_URL) \
1334+
--max_fee 0.1ether
1335+
12141336
# Update target as new proofs are supported.
12151337
docker_batcher_send_all_proofs_burst:
12161338
@$(MAKE) docker_batcher_send_sp1_burst
@@ -1220,6 +1342,8 @@ docker_batcher_send_all_proofs_burst:
12201342
@$(MAKE) docker_batcher_send_gnark_groth16_burst
12211343
@$(MAKE) docker_batcher_send_circom_groth16_bn256_burst
12221344
@$(MAKE) docker_batcher_send_circom_groth16_bn256_no_pub_input_burst
1345+
@$(MAKE) docker_batcher_send_mina_burst
1346+
@$(MAKE) docker_batcher_send_mina_account_burst
12231347

12241348
docker_batcher_send_infinite_groth16:
12251349
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') \
@@ -1257,7 +1381,7 @@ docker_verify_proofs_onchain:
12571381
'
12581382

12591383
DOCKER_PROOFS_WAIT_TIME=60
1260-
DOCKER_SENT_PROOFS=7
1384+
DOCKER_SENT_PROOFS=9
12611385

12621386
docker_verify_proof_submission_success:
12631387
@echo "Verifying proofs were successfully submitted..."

aggregator/pkg/aggregator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
300300
txHash = receipt.TxHash.String()
301301
effectiveGasPrice = receipt.EffectiveGasPrice.String()
302302
}
303+
agg.logger.Info("Gas cost used to send aggregated response", "gasUsed", receipt.GasUsed)
303304
agg.telemetry.TaskSentToEthereum(batchData.BatchMerkleRoot, txHash, effectiveGasPrice)
304305
agg.logger.Info("Aggregator successfully responded to task",
305306
"taskIndex", blsAggServiceResp.TaskIndex,

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/generate_send_summary.sh

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#!/bin/bash
2+
3+
# ENV VARIABLES:
4+
# - REPETITIONS
5+
# - EXPLORER_URL
6+
# - SENDER_ADDRESS
7+
# - RPC_URL
8+
# - EXPLORER_URL
9+
# - NETWORK
10+
# - PRIVATE_KEY
11+
# - VERIFICATION_WAIT_TIME
12+
# - LOGS_BLOCK_RANGE
13+
# - PAGER_DUTY_KEY
14+
# - PAGER_DUTY_EMAIL
15+
# - PAGER_DUTY_SERVICE_ID
16+
# - SLACK_WEBHOOK_URL
17+
18+
# Load env file from $1 path
19+
source "$1"
20+
21+
DATE=$(date -d "yesterday" +"%Y_%m_%d")
22+
23+
# Determine log file name based on current date
24+
LOG_FILE="./alerts/notification_logs/log_$DATE.txt"
25+
26+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
27+
cd "$SCRIPT_DIR"
28+
cd ..
29+
30+
batches=0
31+
submitted_total=0
32+
submitted_by_aligned=0
33+
verified_total=0
34+
unverified_total=0
35+
eth_by_aligned="0"
36+
usd_by_aligned="0"
37+
eth_total="0"
38+
usd_total="0"
39+
40+
# Read the log file entries and generate a summary
41+
if [[ -f "$LOG_FILE" ]]; then
42+
while IFS= read -r line; do
43+
case "$line" in
44+
*"SUCCESS:"*)
45+
batches=$((batches + 1))
46+
47+
proofs_submitted=$(printf '%s\n' "$line" \
48+
| grep -oE '[0-9]+ proofs submitted' \
49+
| head -1 \
50+
| cut -d' ' -f1)
51+
if [[ -n "$proofs_submitted" ]]; then
52+
submitted_total=$((submitted_total + proofs_submitted))
53+
verified_total=$((verified_total + proofs_submitted))
54+
fi
55+
56+
proofs_submitted_by_aligned=$(printf '%s\n' "$line" \
57+
| grep -oE '\([0-9]+ sent\)' \
58+
| grep -oE '[0-9]+' \
59+
| head -1)
60+
if [[ -n "$proofs_submitted_by_aligned" ]]; then
61+
submitted_by_aligned=$((submitted_by_aligned + proofs_submitted_by_aligned))
62+
fi
63+
64+
eth_spent=$(printf '%s\n' "$line" \
65+
| sed -n 's/.*Spent \([0-9.]*\) ETH.*/\1/p')
66+
if [[ -n "$eth_spent" ]]; then
67+
eth_total=$(echo "$eth_total + $eth_spent" | bc -l)
68+
eth_by_aligned=$(echo "$eth_by_aligned + $eth_spent / $proofs_submitted * $proofs_submitted_by_aligned" | bc -l)
69+
fi
70+
71+
usd_spent=$(printf '%s\n' "$line" \
72+
| sed -n 's/.*(\$ *\([0-9.]*\)).*/\1/p')
73+
if [[ -n "$usd_spent" ]]; then
74+
usd_total=$(echo "$usd_total + $usd_spent" | bc -l)
75+
usd_by_aligned=$(echo "$usd_by_aligned + $usd_spent / $proofs_submitted * $proofs_submitted_by_aligned" | bc -l)
76+
fi
77+
;;
78+
*"FAILURE:"*)
79+
batches=$((batches + 1))
80+
81+
proofs_submitted=$(printf '%s\n' "$line" \
82+
| grep -oE '[0-9]+ proofs submitted' \
83+
| head -1 \
84+
| cut -d' ' -f1)
85+
if [[ -n "$proofs_submitted" ]]; then
86+
submitted_total=$((submitted_total + proofs_submitted))
87+
unverified_total=$((unverified_total + proofs_submitted))
88+
fi
89+
90+
proofs_submitted_by_aligned=$(printf '%s\n' "$line" \
91+
| grep -oE '\([0-9]+ sent\)' \
92+
| grep -oE '[0-9]+' \
93+
| head -1)
94+
if [[ -n "$proofs_submitted_by_aligned" ]]; then
95+
submitted_by_aligned=$((submitted_by_aligned + proofs_submitted_by_aligned))
96+
fi
97+
98+
eth_spent=$(printf '%s\n' "$line" \
99+
| sed -n 's/.*Spent \([0-9.]*\) ETH.*/\1/p')
100+
if [[ -n "$eth_spent" ]]; then
101+
eth_total=$(echo "$eth_total + $eth_spent" | bc -l)
102+
eth_by_aligned=$(echo "$eth_by_aligned + $eth_spent / $proofs_submitted * $proofs_submitted_by_aligned" | bc -l)
103+
fi
104+
105+
usd_spent=$(printf '%s\n' "$line" \
106+
| sed -n 's/.*(\$ *\([0-9.]*\)).*/\1/p')
107+
if [[ -n "$usd_spent" ]]; then
108+
usd_total=$(echo "$usd_total + $usd_spent" | bc -l)
109+
usd_by_aligned=$(echo "$usd_by_aligned + $usd_spent / $proofs_submitted * $proofs_submitted_by_aligned" | bc -l)
110+
fi
111+
esac
112+
done < "$LOG_FILE"
113+
114+
summary=$(
115+
printf "Daily Proof Submission Summary\n"
116+
printf "From %s 00:00 to %s 23:59\n" "$DATE" "$DATE"
117+
echo "----------------------------------------------------"
118+
printf "Processed batches: %d\n" "$batches"
119+
printf "Total Proofs submitted: %d\n" "$submitted_total"
120+
printf "Total Proofs verified: %d\n" "$verified_total"
121+
printf "Total Proofs not verified: %d\n" "$unverified_total"
122+
printf "Submitted by Aligned: %d\n" "$submitted_by_aligned"
123+
printf "Submitted by 3rd parties: %d\n" "$((submitted_total - submitted_by_aligned))"
124+
echo "----------------------------------------------------"
125+
printf "Spent by Aligned (ETH): %.12f ETH\n" "$eth_by_aligned"
126+
printf "Spent by Aligned (USD): $ %.2f\n" "$usd_by_aligned"
127+
printf "Spent by 3rd parties (ETH): %.12f ETH\n" "$(echo "$eth_total - $eth_by_aligned" | bc -l)"
128+
printf "Spent by 3rd parties (USD): $ %.2f\n" "$(echo "$usd_total - $usd_by_aligned" | bc -l)"
129+
printf "Total spent (ETH): %.12f ETH\n" "$eth_total"
130+
printf "Total spent (USD): $ %.2f\n" "$usd_total"
131+
echo "----------------------------------------------------"
132+
)
133+
134+
echo "$summary"
135+
136+
# Send the summary to Slack
137+
if [[ -n "$SLACK_WEBHOOK_URL" ]]; then
138+
safe_summary=$(printf '%s\n' "$summary" | sed 's/"/\\"/g')
139+
curl -s -X POST -H 'Content-type: application/json' \
140+
--data "{\"text\":\"\`\`\`$safe_summary\`\`\`\"}" \
141+
"$SLACK_WEBHOOK_URL" >/dev/null 2>&1
142+
fi
143+
else
144+
echo "Proof Submission Summary - $DATE"
145+
echo "----------------------------------------"
146+
echo "No log file found for today: $LOG_FILE"
147+
echo "----------------------------------------"
148+
fi

alerts/notification_logs/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)