Skip to content

Commit 56122ad

Browse files
committed
feat: binary to get the programs ids
1 parent 99b447d commit 56122ad

File tree

5 files changed

+58
-5
lines changed

5 files changed

+58
-5
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ is_aggregator_set:
167167
fi
168168

169169
start_proof_aggregator_dev: is_aggregator_set ## Starts proof aggregator with mock proofs (DEV mode)
170-
AGGREGATOR=$(AGGREGATOR) RISC0_DEV_MODE=1 cargo run --manifest-path ./aggregation_mode/Cargo.toml --release -- config-files/config-proof-aggregator-mock.yaml
170+
AGGREGATOR=$(AGGREGATOR) RISC0_DEV_MODE=1 cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin proof_aggregator -- config-files/config-proof-aggregator-mock.yaml
171171

172172
start_proof_aggregator: is_aggregator_set ## Starts proof aggregator with proving activated
173-
AGGREGATOR=$(AGGREGATOR) cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove -- config-files/config-proof-aggregator.yaml
173+
AGGREGATOR=$(AGGREGATOR) cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove --bin proof_aggregator -- config-files/config-proof-aggregator.yaml
174174

175175
start_proof_aggregator_gpu: is_aggregator_set ## Starts proof aggregator with proving + GPU acceleration (CUDA)
176-
AGGREGATOR=$(AGGREGATOR) SP1_PROVER=cuda cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove,gpu -- config-files/config-proof-aggregator.yaml
176+
AGGREGATOR=$(AGGREGATOR) SP1_PROVER=cuda cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove,gpu --bin proof_aggregator -- config-files/config-proof-aggregator.yaml
177177

178178
verify_aggregated_proof_sp1_holesky_stage:
179179
@echo "Verifying SP1 in aggregated proofs on holesky..."

aggregation_mode/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name = "proof_aggregator"
33
version = "0.1.0"
44
edition = "2021"
55

6-
76
[dependencies]
87
serde = { version = "1.0.203", features = ["derive"] }
98
serde_json = "1.0.117"
@@ -41,3 +40,11 @@ opt-level = 3
4140
default = []
4241
prove = []
4342
gpu = ["risc0-zkvm/cuda"]
43+
44+
[[bin]]
45+
name = "proof_aggregator"
46+
path = "./src/main.rs"
47+
48+
[[bin]]
49+
name = "write_program_image_id_vk_hash"
50+
path = "./bin/write_program_image_id_vk_hash.rs"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use alloy::hex::hex;
2+
use proof_aggregator::aggregators::{
3+
risc0_aggregator::RISC0_AGGREGATOR_PROGRAM_ID_BYTES, sp1_aggregator,
4+
};
5+
use serde_json::json;
6+
use sp1_sdk::HashableKey;
7+
use std::{env, fs, path::Path};
8+
use tracing::info;
9+
use tracing_subscriber::FmtSubscriber;
10+
11+
const SP1_PROGRAM_ELF: &[u8] =
12+
include_bytes!("../aggregation_programs/sp1/elf/sp1_aggregator_program");
13+
14+
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
15+
16+
fn main() {
17+
let subscriber = FmtSubscriber::builder().finish();
18+
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
19+
20+
info!("About to write sp1 programs vk hash bytes + risc0 programs image id bytes");
21+
let sp1_vk_hash = sp1_aggregator::vk_from_elf(SP1_PROGRAM_ELF).bytes32_raw();
22+
let risc0_image_id_bytes = RISC0_AGGREGATOR_PROGRAM_ID_BYTES;
23+
24+
let sp1_vk_hash_hex = hex::encode(sp1_vk_hash);
25+
let risc0_image_id_hex = hex::encode(risc0_image_id_bytes);
26+
27+
let dest_path = Path::new("programs_ids.json");
28+
29+
let json_data = json!({
30+
"sp1_vk_hash": format!("0x{}", sp1_vk_hash_hex),
31+
"risc0_image_id": format!("0x{}", risc0_image_id_hex),
32+
});
33+
34+
// Write to the file
35+
fs::write(
36+
&dest_path,
37+
serde_json::to_string_pretty(&json_data).unwrap(),
38+
)
39+
.unwrap();
40+
41+
info!("Program ids written to {:?}", dest_path);
42+
}

aggregation_mode/programs_ids.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"risc0_image_id": "0x616eccca41e741062c79481078c0cbaa034da436c2ba254b09de8c2cf20bdd86",
3+
"sp1_vk_hash": "0x00964e05feb8c81d33714c9a9d66d0941210996853b8886d40e8c85ed3a4fa39"
4+
}

aggregation_mode/src/aggregators/risc0_aggregator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use risc0_zkvm::{default_prover, ExecutorEnv, ProverOpts, Receipt};
44
use sha3::{Digest, Keccak256};
55

66
/// Byte representation of the aggregator image_id, converted from `[u32; 8]` to `[u8; 32]`.
7-
const RISC0_AGGREGATOR_PROGRAM_ID_BYTES: [u8; 32] = {
7+
pub const RISC0_AGGREGATOR_PROGRAM_ID_BYTES: [u8; 32] = {
88
let mut res = [0u8; 32];
99
let mut i = 0;
1010
while i < 8 {

0 commit comments

Comments
 (0)