Skip to content

Commit 2163283

Browse files
committed
Merge branch 'staging' into feat/aggregation-mode-batcher
2 parents 3bf9e1a + 492ed20 commit 2163283

File tree

76 files changed

+23337
-2812
lines changed

Some content is hidden

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

76 files changed

+23337
-2812
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..."

aggregation_mode/proof_aggregator/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ make proof_aggregator_write_program_ids
7474

7575
We are using docker to produce deterministic builds so that the program ids are the same for all systems.
7676

77-
### Updating the program id in `AlignedProofAggregationService` contract
77+
### Updating the verifier program commitment in `AlignedProofAggregationService` contract
7878

79-
If the program ids have changed, you will also need to update them in the `AlignedProofAggregationService` contract.
79+
If the verifier program commitments have changed, you will also need to add the updated one to the `AlignedProofAggregationService` contract. You can do this by calling the `allowVerifyingProgram` method with the new commitment and the proving system ID as parameters (you can check the last parameter in the ProvingSystemId definition at `contracts/src/core/IAlignedProofAggregationService.sol`).
8080

81-
- Risc0: call `setRisc0AggregatorProgramImageId` method with the value of `risc0_root_aggregator_image_id` from `aggregation_mode/program_ids.json`.
82-
- SP1: call: `setSP1AggregatorProgramVKHash` method with the value of `sp1_root_aggregator_vk_hash` from `aggregation_mode/program_ids.json`.
81+
You can fetch the verifier program commitment values from the following:
82+
83+
- Risc0: Use the value of `risc0_chunk_aggregator_image_id` from `aggregation_mode/program_ids.json`.
84+
- SP1: Use the value of `sp1_chunk_aggregator_vk_hash` from `aggregation_mode/program_ids.json`.

aggregation_mode/proof_aggregator/abi/AlignedProofAggregationService.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

aggregation_mode/proof_aggregator/src/backend/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub struct Config {
2323
pub ecdsa: ECDSAConfig,
2424
pub proofs_per_chunk: u16,
2525
pub total_proofs_limit: u16,
26+
pub sp1_chunk_aggregator_vk_hash: String,
27+
pub risc0_chunk_aggregator_image_id: String,
2628
}
2729

2830
impl Config {

aggregation_mode/proof_aggregator/src/backend/mod.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ pub struct ProofAggregator {
4444
proof_aggregation_service: AlignedProofAggregationServiceContract,
4545
fetcher: ProofsFetcher,
4646
config: Config,
47+
sp1_chunk_aggregator_vk_hash_bytes: [u8; 32],
48+
risc0_chunk_aggregator_image_id_bytes: [u8; 32],
4749
}
4850

4951
impl ProofAggregator {
@@ -66,11 +68,25 @@ impl ProofAggregator {
6668
ZKVMEngine::from_env().expect("AGGREGATOR env variable to be set to one of sp1|risc0");
6769
let fetcher = ProofsFetcher::new(&config);
6870

71+
let sp1_chunk_aggregator_vk_hash_bytes: [u8; 32] =
72+
hex::decode(&config.sp1_chunk_aggregator_vk_hash)
73+
.expect("Failed to decode SP1 chunk aggregator VK hash")
74+
.try_into()
75+
.expect("SP1 chunk aggregator VK hash must be 32 bytes");
76+
77+
let risc0_chunk_aggregator_image_id_bytes: [u8; 32] =
78+
hex::decode(&config.risc0_chunk_aggregator_image_id)
79+
.expect("Failed to decode Risc0 chunk aggregator image id")
80+
.try_into()
81+
.expect("Risc0 chunk aggregator image id must be 32 bytes");
82+
6983
Self {
7084
engine,
7185
proof_aggregation_service,
7286
fetcher,
7387
config,
88+
sp1_chunk_aggregator_vk_hash_bytes,
89+
risc0_chunk_aggregator_image_id_bytes,
7490
}
7591
}
7692

@@ -157,10 +173,11 @@ impl ProofAggregator {
157173
let tx_req = match aggregated_proof {
158174
AlignedProof::SP1(proof) => self
159175
.proof_aggregation_service
160-
.verifySP1(
176+
.verifyAggregationSP1(
161177
blob_versioned_hash.into(),
162178
proof.proof_with_pub_values.public_values.to_vec().into(),
163179
proof.proof_with_pub_values.bytes().into(),
180+
self.sp1_chunk_aggregator_vk_hash_bytes.into(),
164181
)
165182
.sidecar(blob)
166183
.into_transaction_request(),
@@ -169,10 +186,11 @@ impl ProofAggregator {
169186
AggregatedProofSubmissionError::Risc0EncodingSeal(e.to_string())
170187
})?;
171188
self.proof_aggregation_service
172-
.verifyRisc0(
189+
.verifyAggregationRisc0(
173190
blob_versioned_hash.into(),
174191
encoded_seal.into(),
175192
proof.receipt.journal.bytes.into(),
193+
self.risc0_chunk_aggregator_image_id_bytes.into(),
176194
)
177195
.sidecar(blob)
178196
.into_transaction_request()

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>

0 commit comments

Comments
 (0)