@@ -96,22 +96,18 @@ fn sample_next_block<R: Rng + CryptoRng>(
9696// into actual deployments in various configurations (for instance, 4 deployments of size N vs. 2 deployments
9797// of size 2N vs. 1 deployment of size 4N)
9898fn main ( ) {
99-
10099 // One array element = one group of deployments checked together. Each such group is represented by a pair:
101100 // (number of programs in the deployment, size of the program). The size of the program is in actuality the number
102101 // of inputs to the program's only function, which simply hashes them. The total density of the program grows
103102 // essentially linearly with this value.
104103 let deployment_configs = [
105104 // Each set of configurations visually grouped together corresponds to approximately the same total density.
106105 ( 1 , 1 << 4 ) ,
107-
108106 ( 1 , 1 << 5 ) ,
109107 ( 2 , 1 << 4 ) ,
110-
111108 ( 1 , 1 << 6 ) ,
112109 ( 2 , 1 << 5 ) ,
113110 ( 4 , 1 << 4 ) ,
114-
115111 ( 1 , 1 << 7 ) ,
116112 ( 2 , 1 << 6 ) ,
117113 ( 4 , 1 << 5 ) ,
@@ -139,54 +135,62 @@ fn main() {
139135
140136 // Advance the ledger to the latest consensus version
141137 let transactions: [ Transaction < CurrentNetwork > ; 0 ] = [ ] ;
142- while vm. block_store ( ) . current_block_height ( ) < CurrentNetwork :: CONSENSUS_HEIGHT ( ConsensusVersion :: latest ( ) ) . unwrap ( ) {
138+ while vm. block_store ( ) . current_block_height ( )
139+ < CurrentNetwork :: CONSENSUS_HEIGHT ( ConsensusVersion :: latest ( ) ) . unwrap ( )
140+ {
143141 let next_block = sample_next_block ( & vm, & private_key, & transactions, rng) . unwrap ( ) ;
144142 vm. add_next_block ( & next_block) . unwrap ( ) ;
145143 }
146144
147145 for ( deployment_idx, ( num_progs, multiplier) ) in deployment_configs. into_iter ( ) . enumerate ( ) {
148-
149146 println ! ( "Processing deployment with {num_progs} program(s) with multiplier {multiplier}" ) ;
150147
151- let deployments = ( 0 ..num_progs) . map ( |i| {
152-
153- let mut program_str = format ! ( r"
148+ let deployments = ( 0 ..num_progs)
149+ . map ( |i| {
150+ let mut program_str = format ! (
151+ r"
154152 program test_{deployment_idx}_{i}.aleo;
155153
156154 function fun:
157155 input r0 as [field; 32u32].public;
158- " ) ;
156+ "
157+ ) ;
159158
160- for j in 1 ..multiplier {
161- program_str += & format ! ( r"
159+ for j in 1 ..multiplier {
160+ program_str += & format ! (
161+ r"
162162 hash.bhp256 r0 into r{j} as field;
163- " ) ;
164- }
165-
166- program_str += r"
163+ "
164+ ) ;
165+ }
166+
167+ program_str += r"
167168 constructor:
168169 assert.eq true true;
169170 " ;
170171
171- let program = Program :: from_str ( & program_str) . unwrap ( ) ;
172+ let program = Program :: from_str ( & program_str) . unwrap ( ) ;
172173
173- // Deploy the first program
174- let deployment_tx = vm. deploy ( & private_key, & program, None , 0 , None , rng) . unwrap ( ) ;
175- let deployment = deployment_tx. deployment ( ) . unwrap ( ) ;
174+ // Deploy the first program
175+ let deployment_tx = vm. deploy ( & private_key, & program, None , 0 , None , rng) . unwrap ( ) ;
176+ let deployment = deployment_tx. deployment ( ) . unwrap ( ) ;
176177
177- assert ! ( deployment. verifying_keys( ) . len( ) == 1 ) ;
178- let circuit_info = deployment. verifying_keys ( ) . first ( ) . unwrap ( ) . 1 . 0 . circuit_info ;
179- let combined_density = circuit_info. num_non_zero_a + circuit_info. num_non_zero_b + circuit_info. num_non_zero_c ;
180- println ! ( " - Program {:?}: total density: {combined_density:?}" , deployment. program( ) . id( ) ) ;
181-
182- ( deployment_tx, combined_density as usize )
183- } ) . collect :: < Vec < _ > > ( ) ;
178+ assert ! ( deployment. verifying_keys( ) . len( ) == 1 ) ;
179+ let circuit_info = deployment. verifying_keys ( ) . first ( ) . unwrap ( ) . 1 . 0 . circuit_info ;
180+ let combined_density =
181+ circuit_info. num_non_zero_a + circuit_info. num_non_zero_b + circuit_info. num_non_zero_c ;
182+ println ! ( " - Program {:?}: total density: {combined_density:?}" , deployment. program( ) . id( ) ) ;
183+
184+ ( deployment_tx, combined_density as usize )
185+ } )
186+ . collect :: < Vec < _ > > ( ) ;
184187
185188 let ( deployment_txs, combined_densities) : ( Vec < _ > , Vec < _ > ) = deployments. into_iter ( ) . unzip ( ) ;
186189 let total_density = combined_densities. iter ( ) . sum :: < usize > ( ) ;
187190
188191 let start = Instant :: now ( ) ;
189- vm. check_transactions ( & deployment_txs. iter ( ) . map ( |deployment| ( deployment, None ) ) . collect :: < Vec < _ > > ( ) , rng) . unwrap ( ) ;
192+ vm. check_transactions ( & deployment_txs. iter ( ) . map ( |deployment| ( deployment, None ) ) . collect :: < Vec < _ > > ( ) , rng)
193+ . unwrap ( ) ;
190194 let elapsed = start. elapsed ( ) . as_millis ( ) as f64 / 1000.0 ;
191195 println ! ( "Deployment(s) with total density {total_density} checked in {elapsed:.2} s\n " ) ;
192196 }
0 commit comments