@@ -36,7 +36,6 @@ fn main() {
3636 ] ,
3737 // We use Docker to generate a reproducible ELF that will be identical across all platforms
3838 // (https://docs.succinct.xyz/docs/sp1/writing-programs/compiling#production-builds)
39- docker : true ,
4039 ..Default :: default ( )
4140 }
4241 } ) ;
@@ -45,13 +44,90 @@ fn main() {
4544 // regardless of the machine or local environment, will produce the same ImageID
4645 let docker_options = DockerOptionsBuilder :: default ( ) . build ( ) . unwrap ( ) ;
4746 // Reference: https://github.com/risc0/risc0/blob/main/risc0/build/src/config.rs#L73-L90
48- let guest_options = GuestOptionsBuilder :: default ( )
49- . use_docker ( docker_options)
50- . build ( )
51- . unwrap ( ) ;
47+ let guest_options = GuestOptionsBuilder :: default ( ) . build ( ) . unwrap ( ) ;
5248
5349 risc0_build:: embed_methods_with_options ( HashMap :: from ( [ (
5450 "risc0_aggregation_program" ,
5551 guest_options,
5652 ) ] ) ) ;
53+
54+ // Steps followed from https://0xpolygonhermez.github.io/zisk/getting_started/writing_programs.html#build
55+
56+ // build.rs runs a subprocess without the shell's rustup selection; set the toolchain
57+ // explicitly so cargo-zisk uses Zisk's rustc instead of the host toolchain.
58+ let zisk_rustc_path = rustc_path_for ( "zisk" ) ;
59+
60+ let mut build_command = std:: process:: Command :: new ( "cargo-zisk" ) ;
61+ let mut user_proof_aggregator_rom_setup_command = std:: process:: Command :: new ( "cargo-zisk" ) ;
62+ let mut chunk_aggregator_rom_setup_command = std:: process:: Command :: new ( "cargo-zisk" ) ;
63+
64+ build_command
65+ . env ( "RUSTC" , & zisk_rustc_path)
66+ . args ( [ "build" , "--release" ] )
67+ . current_dir ( "aggregation_programs/zisk/" ) ;
68+
69+ let build_status = build_command
70+ . status ( )
71+ . expect ( "Failed to execute zisk build command" ) ;
72+
73+ if !build_status. success ( ) {
74+ panic ! ( "Failed to build zisk elfs" ) ;
75+ }
76+
77+ let user_proof_aggregator_rom_setup_status = user_proof_aggregator_rom_setup_command
78+ . args ( [
79+ "rom-setup" ,
80+ "--elf" ,
81+ "./target/riscv64ima-zisk-zkvm-elf/release/zisk_user_proofs_aggregator_program" ,
82+ ] )
83+ . env ( "RUSTC" , & zisk_rustc_path)
84+ . current_dir ( "./aggregation_programs/" )
85+ . status ( )
86+ . unwrap ( ) ;
87+
88+ if !user_proof_aggregator_rom_setup_status. success ( ) {
89+ panic ! ( "Failed to execute rom-setup command on user proof aggregator program" ) ;
90+ }
91+
92+ let chunk_aggregator_rom_setup_status = chunk_aggregator_rom_setup_command
93+ . args ( [
94+ "rom-setup" ,
95+ "--elf" ,
96+ "./target/riscv64ima-zisk-zkvm-elf/release/zisk_chunk_aggregator_program" ,
97+ ] )
98+ . env ( "RUSTC" , & zisk_rustc_path)
99+ . current_dir ( "./aggregation_programs/" )
100+ . status ( )
101+ . unwrap ( ) ;
102+
103+ if !chunk_aggregator_rom_setup_status. success ( ) {
104+ panic ! ( "Failed to execute rom-setup command on chunk aggregator program" ) ;
105+ }
106+
107+ let _ = std:: fs:: create_dir ( "./aggregation_programs/zisk/elf" ) ;
108+
109+ std:: fs:: copy (
110+ "./aggregation_programs/target/riscv64ima-zisk-zkvm-elf/release/zisk_user_proofs_aggregator_program" ,
111+ "./aggregation_programs/zisk/elf/zisk_user_proofs_aggregator_program" ,
112+ )
113+ . expect ( "Could not zisk_user_proofs_aggregator_program elf to aggregation_programs/zisk/elf directory" ) ;
114+
115+ std:: fs:: copy (
116+ "./aggregation_programs/target/riscv64ima-zisk-zkvm-elf/release/zisk_chunk_aggregator_program" ,
117+ "./aggregation_programs/zisk/elf/zisk_chunk_aggregator_program" ,
118+ )
119+ . expect ( "Could not zisk_chunk_aggregator_program elf to aggregation_programs/zisk/elf directory" ) ;
120+ }
121+
122+ fn rustc_path_for ( toolchain : & str ) -> std:: path:: PathBuf {
123+ let output = std:: process:: Command :: new ( "rustup" )
124+ . args ( [ "which" , "rustc" , "--toolchain" , toolchain] )
125+ . output ( )
126+ . expect ( "failed to execute rustup" ) ;
127+
128+ if !output. status . success ( ) {
129+ panic ! ( "rustup which rustc failed for toolchain {toolchain}" ) ;
130+ }
131+
132+ std:: path:: PathBuf :: from ( String :: from_utf8_lossy ( & output. stdout ) . trim ( ) )
57133}
0 commit comments