Skip to content
Closed

0.21 #2182

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
8 changes: 7 additions & 1 deletion .github/workflows/build-and-test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ jobs:

- name: Build Merkle Tree bindings
run: make build_merkle_tree_linux


- name: Build Mina bindings
run: make build_mina_linux

- name: Build Mina Account bindings
run: make build_mina_account_linux

- name: Build operator
run: go build operator/cmd/main.go

Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/test-mina.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: test-mina

on:
merge_group:
push:
branches: [main]
pull_request:
branches: ["*"]
paths:
- 'operator/mina/**'
- 'operator/mina_account/**'
- '.github/workflows/test-mina.yml'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Test Mina Rust
run: make test_mina_rust_ffi
- name: Test Mina go bindings
run: make test_mina_go_bindings_linux
- name: Test Mina Account Rust
run: make test_mina_account_rust_ffi
- name: Test Mina Account go bindings
run: make test_mina_account_go_bindings_linux
130 changes: 127 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ ifeq ($(OS),Darwin)
endif

ifeq ($(OS),Linux)
export LD_LIBRARY_PATH+=$(CURDIR)/operator/risc_zero/lib:$(CURDIR)/operator/sp1/lib
OPERATOR_FFIS=$(CURDIR)/operator/risc_zero/lib:$(CURDIR)/operator/sp1/lib
export LD_LIBRARY_PATH+=$(CURDIR)/operator/risc_zero/lib:$(CURDIR)/operator/sp1/lib:$(CURDIR)/operator/mina/lib:$(CURDIR)/operator/mina_account/lib
OPERATOR_FFIS=$(CURDIR)/operator/risc_zero/lib:$(CURDIR)/operator/sp1/lib:$(CURDIR)/operator/mina/lib:$(CURDIR)/operator/mina_account/lib
endif

ifeq ($(OS),Linux)
Expand Down Expand Up @@ -703,6 +703,58 @@ batcher_send_circom_groth16_bn256_no_pub_input_burst: crates/target/release/alig
--rpc_url $(RPC_URL) \
--network $(NETWORK)

batcher_send_mina_task:
@echo "Sending Mina state task to Batcher..."
@cd crates/cli/ && cargo run --release -- submit \
--proving_system Mina \
--proof ../../scripts/test_files/mina/devnet_mina_state.proof \
--public_input ../../scripts/test_files/mina/devnet_mina_state.pub \
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
--rpc_url $(RPC_URL) \
--network $(NETWORK)

batcher_send_mina_task_bad_hash:
@echo "Sending Mina state task to Batcher..."
@cd crates/cli/ && cargo run --release -- submit \
--proving_system Mina \
--proof ../../scripts/test_files/mina/devnet_mina_state.proof \
--public_input ../../scripts/test_files/mina/mina_state_bad_hash.pub \
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
--rpc_url $(RPC_URL) \
--network $(NETWORK)

batcher_send_mina_burst:
@echo "Sending Mina state task to Batcher..."
@cd crates/cli/ && cargo run --release -- submit \
--proving_system Mina \
--proof ../../scripts/test_files/mina/devnet_mina_state.proof \
--public_input ../../scripts/test_files/mina/devnet_mina_state.pub \
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
--repetitions $(BURST_SIZE) \
--rpc_url $(RPC_URL) \
--network $(NETWORK)

batcher_send_mina_account_task:
@echo "Sending Mina account task to Batcher..."
@cd crates/cli/ && cargo run --release -- submit \
--proving_system MinaAccount \
--proof ../../scripts/test_files/mina_account/mina_account.proof \
--public_input ../../scripts/test_files/mina_account/mina_account.pub \
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
--rpc_url $(RPC_URL) \
--network $(NETWORK)

batcher_send_mina_account_burst:
@echo "Sending Mina account task to Batcher..."
@cd crates/cli/ && cargo run --release -- submit \
--proving_system MinaAccount \
--proof ../../scripts/test_files/mina_account/mina_account.proof \
--public_input ../../scripts/test_files/mina_account/mina_account.pub \
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
--repetitions $(BURST_SIZE) \
--rpc_url $(RPC_URL) \
--network $(NETWORK)

batcher_send_proof_with_random_address: ## Send a proof with a random address to Batcher. Parameters: RPC_URL, NETWORK, PROOF_TYPE, REPETITIONS
@cd crates/cli/ && ./send_proof_with_random_address.sh

Expand Down Expand Up @@ -968,6 +1020,48 @@ test_merkle_tree_go_bindings_linux: build_merkle_tree_linux
@echo "Testing Merkle Tree Go bindings..."
go test ./operator/merkle_tree/... -v

__MINA_FFI__: ##
build_mina_macos:
@cd operator/mina/lib && cargo build --release ${MINA_FEATURES_FLAG}
@cp operator/mina/lib/target/release/libmina_state_verifier_ffi.dylib operator/mina/lib/libmina_state_verifier_ffi.dylib

build_mina_linux:
@cd operator/mina/lib && cargo build --release ${MINA_FEATURES_FLAG}
@cp operator/mina/lib/target/release/libmina_state_verifier_ffi.so operator/mina/lib/libmina_state_verifier_ffi.so

test_mina_rust_ffi:
@echo "Testing Mina Rust FFI source code..."
@cd operator/mina/lib && cargo t --release

test_mina_go_bindings_macos: build_mina_macos
@echo "Testing Mina Go bindings..."
go test ./operator/mina/... -v

test_mina_go_bindings_linux: build_mina_linux
@echo "Testing Mina Go bindings..."
go test ./operator/mina/... -v

__MINA_ACCOUNT_FFI__: ##
build_mina_account_macos:
@cd operator/mina_account/lib && cargo build --release
@cp operator/mina_account/lib/target/release/libmina_account_verifier_ffi.dylib operator/mina_account/lib/libmina_account_verifier_ffi.dylib

build_mina_account_linux:
@cd operator/mina_account/lib && cargo build --release
@cp operator/mina_account/lib/target/release/libmina_account_verifier_ffi.so operator/mina_account/lib/libmina_account_verifier_ffi.so

test_mina_account_rust_ffi:
@echo "Testing Mina Account Rust FFI source code..."
@cd operator/mina_account/lib && cargo t --release

test_mina_account_go_bindings_macos: build_mina_account_macos
@echo "Testing Mina Account Go bindings..."
go test ./operator/mina_account/... -v

test_mina_account_go_bindings_linux: build_mina_account_linux
@echo "Testing Mina Account Go bindings..."
go test ./operator/mina_account/... -v

__FFI__: ## ____

build_all_ffi: ## Build all FFIs
Expand All @@ -979,13 +1073,17 @@ build_all_ffi_macos: ## Build all FFIs for macOS
@$(MAKE) build_sp1_macos
@$(MAKE) build_risc_zero_macos
@$(MAKE) build_merkle_tree_macos
@$(MAKE) build_mina_macos
@$(MAKE) build_mina_account_macos
@echo "All macOS FFIs built successfully."

build_all_ffi_linux: ## Build all FFIs for Linux
@echo "Building all FFIs for Linux..."
@$(MAKE) build_sp1_linux
@$(MAKE) build_risc_zero_linux
@$(MAKE) build_merkle_tree_linux
@$(MAKE) build_mina_linux
@$(MAKE) build_mina_account_linux
@echo "All Linux FFIs built successfully."

__EXPLORER__: ## ____
Expand Down Expand Up @@ -1193,6 +1291,30 @@ docker_batcher_send_circom_groth16_bn256_no_pub_input_burst:
--rpc_url $(DOCKER_RPC_URL) \
--max_fee 0.1ether

docker_batcher_send_mina_burst:
@echo "Sending Mina state task to Batcher..."
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') aligned submit \
--private_key $(DOCKER_PROOFS_PRIVATE_KEY) \
--proving_system Mina \
--proof ./scripts/test_files/mina/devnet_mina_state.proof \
--public_input ./scripts/test_files/mina/devnet_mina_state.pub \
--repetitions $(DOCKER_BURST_SIZE) \
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
--rpc_url $(DOCKER_RPC_URL) \
--max_fee 0.1ether

docker_batcher_send_mina_account_burst:
@echo "Sending Mina account task to Batcher..."
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') aligned submit \
--private_key $(DOCKER_PROOFS_PRIVATE_KEY) \
--proving_system MinaAccount \
--proof ./scripts/test_files/mina_account/mina_account.proof \
--public_input ./scripts/test_files/mina_account/mina_account.pub \
--repetitions $(DOCKER_BURST_SIZE) \
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
--rpc_url $(DOCKER_RPC_URL) \
--max_fee 0.1ether

# Update target as new proofs are supported.
docker_batcher_send_all_proofs_burst:
@$(MAKE) docker_batcher_send_sp1_burst
Expand All @@ -1202,6 +1324,8 @@ docker_batcher_send_all_proofs_burst:
@$(MAKE) docker_batcher_send_gnark_groth16_burst
@$(MAKE) docker_batcher_send_circom_groth16_bn256_burst
@$(MAKE) docker_batcher_send_circom_groth16_bn256_no_pub_input_burst
@$(MAKE) docker_batcher_send_mina_burst
@$(MAKE) docker_batcher_send_mina_account_burst

docker_batcher_send_infinite_groth16:
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') \
Expand Down Expand Up @@ -1239,7 +1363,7 @@ docker_verify_proofs_onchain:
'

DOCKER_PROOFS_WAIT_TIME=60
DOCKER_SENT_PROOFS=7
DOCKER_SENT_PROOFS=9

docker_verify_proof_submission_success:
@echo "Verifying proofs were successfully submitted..."
Expand Down
1 change: 1 addition & 0 deletions aggregator/pkg/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
txHash = receipt.TxHash.String()
effectiveGasPrice = receipt.EffectiveGasPrice.String()
}
agg.logger.Info("Gas cost used to send aggregated response", "gasUsed", receipt.GasUsed)
agg.telemetry.TaskSentToEthereum(batchData.BatchMerkleRoot, txHash, effectiveGasPrice)
agg.logger.Info("Aggregator successfully responded to task",
"taskIndex", blsAggServiceResp.TaskIndex,
Expand Down
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
148 changes: 148 additions & 0 deletions alerts/generate_send_summary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#!/bin/bash

# ENV VARIABLES:
# - REPETITIONS
# - EXPLORER_URL
# - SENDER_ADDRESS
# - RPC_URL
# - EXPLORER_URL
# - NETWORK
# - PRIVATE_KEY
# - VERIFICATION_WAIT_TIME
# - LOGS_BLOCK_RANGE
# - PAGER_DUTY_KEY
# - PAGER_DUTY_EMAIL
# - PAGER_DUTY_SERVICE_ID
# - SLACK_WEBHOOK_URL

# Load env file from $1 path
source "$1"

DATE=$(date -d "yesterday" +"%Y_%m_%d")

# Determine log file name based on current date
LOG_FILE="./alerts/notification_logs/log_$DATE.txt"

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
cd ..

batches=0
submitted_total=0
submitted_by_aligned=0
verified_total=0
unverified_total=0
eth_by_aligned="0"
usd_by_aligned="0"
eth_total="0"
usd_total="0"

# Read the log file entries and generate a summary
if [[ -f "$LOG_FILE" ]]; then
while IFS= read -r line; do
case "$line" in
*"SUCCESS:"*)
batches=$((batches + 1))

proofs_submitted=$(printf '%s\n' "$line" \
| grep -oE '[0-9]+ proofs submitted' \
| head -1 \
| cut -d' ' -f1)
if [[ -n "$proofs_submitted" ]]; then
submitted_total=$((submitted_total + proofs_submitted))
verified_total=$((verified_total + proofs_submitted))
fi

proofs_submitted_by_aligned=$(printf '%s\n' "$line" \
| grep -oE '\([0-9]+ sent\)' \
| grep -oE '[0-9]+' \
| head -1)
if [[ -n "$proofs_submitted_by_aligned" ]]; then
submitted_by_aligned=$((submitted_by_aligned + proofs_submitted_by_aligned))
fi

eth_spent=$(printf '%s\n' "$line" \
| sed -n 's/.*Spent \([0-9.]*\) ETH.*/\1/p')
if [[ -n "$eth_spent" ]]; then
eth_total=$(echo "$eth_total + $eth_spent" | bc -l)
eth_by_aligned=$(echo "$eth_by_aligned + $eth_spent / $proofs_submitted * $proofs_submitted_by_aligned" | bc -l)
fi

usd_spent=$(printf '%s\n' "$line" \
| sed -n 's/.*(\$ *\([0-9.]*\)).*/\1/p')
if [[ -n "$usd_spent" ]]; then
usd_total=$(echo "$usd_total + $usd_spent" | bc -l)
usd_by_aligned=$(echo "$usd_by_aligned + $usd_spent / $proofs_submitted * $proofs_submitted_by_aligned" | bc -l)
fi
;;
*"FAILURE:"*)
batches=$((batches + 1))

proofs_submitted=$(printf '%s\n' "$line" \
| grep -oE '[0-9]+ proofs submitted' \
| head -1 \
| cut -d' ' -f1)
if [[ -n "$proofs_submitted" ]]; then
submitted_total=$((submitted_total + proofs_submitted))
unverified_total=$((unverified_total + proofs_submitted))
fi

proofs_submitted_by_aligned=$(printf '%s\n' "$line" \
| grep -oE '\([0-9]+ sent\)' \
| grep -oE '[0-9]+' \
| head -1)
if [[ -n "$proofs_submitted_by_aligned" ]]; then
submitted_by_aligned=$((submitted_by_aligned + proofs_submitted_by_aligned))
fi

eth_spent=$(printf '%s\n' "$line" \
| sed -n 's/.*Spent \([0-9.]*\) ETH.*/\1/p')
if [[ -n "$eth_spent" ]]; then
eth_total=$(echo "$eth_total + $eth_spent" | bc -l)
eth_by_aligned=$(echo "$eth_by_aligned + $eth_spent / $proofs_submitted * $proofs_submitted_by_aligned" | bc -l)
fi

usd_spent=$(printf '%s\n' "$line" \
| sed -n 's/.*(\$ *\([0-9.]*\)).*/\1/p')
if [[ -n "$usd_spent" ]]; then
usd_total=$(echo "$usd_total + $usd_spent" | bc -l)
usd_by_aligned=$(echo "$usd_by_aligned + $usd_spent / $proofs_submitted * $proofs_submitted_by_aligned" | bc -l)
fi
esac
done < "$LOG_FILE"

summary=$(
printf "Daily Proof Submission Summary\n"
printf "From %s 00:00 to %s 23:59\n" "$DATE" "$DATE"
echo "----------------------------------------------------"
printf "Processed batches: %d\n" "$batches"
printf "Total Proofs submitted: %d\n" "$submitted_total"
printf "Total Proofs verified: %d\n" "$verified_total"
printf "Total Proofs not verified: %d\n" "$unverified_total"
printf "Submitted by Aligned: %d\n" "$submitted_by_aligned"
printf "Submitted by 3rd parties: %d\n" "$((submitted_total - submitted_by_aligned))"
echo "----------------------------------------------------"
printf "Spent by Aligned (ETH): %.12f ETH\n" "$eth_by_aligned"
printf "Spent by Aligned (USD): $ %.2f\n" "$usd_by_aligned"
printf "Spent by 3rd parties (ETH): %.12f ETH\n" "$(echo "$eth_total - $eth_by_aligned" | bc -l)"
printf "Spent by 3rd parties (USD): $ %.2f\n" "$(echo "$usd_total - $usd_by_aligned" | bc -l)"
printf "Total spent (ETH): %.12f ETH\n" "$eth_total"
printf "Total spent (USD): $ %.2f\n" "$usd_total"
echo "----------------------------------------------------"
)

echo "$summary"

# Send the summary to Slack
if [[ -n "$SLACK_WEBHOOK_URL" ]]; then
safe_summary=$(printf '%s\n' "$summary" | sed 's/"/\\"/g')
curl -s -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"\`\`\`$safe_summary\`\`\`\"}" \
"$SLACK_WEBHOOK_URL" >/dev/null 2>&1
fi
else
echo "Proof Submission Summary - $DATE"
echo "----------------------------------------"
echo "No log file found for today: $LOG_FILE"
echo "----------------------------------------"
fi
Empty file.
Loading
Loading