diff --git a/phase1-cli/src/combine.rs b/phase1-cli/src/combine.rs index 9d1fcec0..783fb73e 100644 --- a/phase1-cli/src/combine.rs +++ b/phase1-cli/src/combine.rs @@ -73,7 +73,7 @@ pub fn combine( .open(combined_filename) .expect("unable to create new combined file in this directory"); - println!("parameters for output: {:?}", parameters_for_output); + tracing::debug!("Parameters for output: {:?}", parameters_for_output); writer .set_len(parameters_for_output.accumulator_size as u64) @@ -94,6 +94,7 @@ pub fn combine( parameters.total_size_in_log2, parameters.batch_size, ); + tracing::debug!("Parameters for aggregation: {:?}", parameters); let res = Phase1::aggregation( &readers .iter() diff --git a/phase1-cli/src/contribute.rs b/phase1-cli/src/contribute.rs index aed18c5b..4d5de454 100644 --- a/phase1-cli/src/contribute.rs +++ b/phase1-cli/src/contribute.rs @@ -40,6 +40,7 @@ pub fn contribute( metadata.len() ); } + dbg!(metadata.len()); } let readable_map = unsafe { diff --git a/phase1/src/aggregation.rs b/phase1/src/aggregation.rs index 20957cc2..f9be36f1 100644 --- a/phase1/src/aggregation.rs +++ b/phase1/src/aggregation.rs @@ -16,7 +16,7 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { let span = info_span!("phase1-aggregation"); let _enter = span.enter(); - info!("starting..."); + info!("Starting Aggregation"); for (chunk_index, (input, compressed_input)) in inputs.iter().enumerate() { let chunk_parameters = @@ -33,9 +33,10 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { let start = chunk_index * chunk_parameters.chunk_size; let end = (chunk_index + 1) * chunk_parameters.chunk_size; - debug!("combining chunk from {} to {}", start, end); + debug!("Combining chunk from {} to {}", start, end); + debug!("Chunk parameters: {:?}", chunk_parameters); - let span = info_span!("batch", start, end); + let span = info_span!("Batch", start, end); let _enter = span.enter(); match parameters.proving_system { @@ -53,16 +54,25 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { .write_batch(&elements, compressed_output) .expect("should have written batch"); - trace!("tau_g1 aggregation for chunk {} successful", chunk_index); + debug!( + "Tau G1 aggregation for chunk {} successful; {} G1 elements written", + chunk_index, + elements.len() + ); }); + debug!( + "`start = {}, chunk_parameters.powers_length = {}, start < chunk_parameters.powers_length = {}`", + start, + chunk_parameters.powers_length, + start < chunk_parameters.powers_length + ); if start < chunk_parameters.powers_length { rayon::scope(|t| { let _enter = span.enter(); t.spawn(|_| { let _enter = span.enter(); - let elements: Vec = in_tau_g2 .read_batch(compressed_input, CheckForCorrectness::No) .expect("should have read batch"); @@ -70,7 +80,11 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { .write_batch(&elements, compressed_output) .expect("should have written batch"); - trace!("tau_g2 aggregation for chunk {} successful", chunk_index); + debug!( + "Tau G2 aggregation for chunk {} successful; {} G2 elements written", + chunk_index, + elements.len() + ); }); t.spawn(|_| { @@ -83,7 +97,11 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { .write_batch(&elements, compressed_output) .expect("should have written batch"); - trace!("alpha_g1 aggregation for chunk {} successful", chunk_index); + debug!( + "alpha_g1 aggregation for chunk {} successful; {} G1 elements written", + chunk_index, + elements.len() + ); }); t.spawn(|_| { @@ -96,7 +114,11 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { .write_batch(&elements, compressed_output) .expect("should have written batch"); - trace!("beta_g1 aggregation for chunk {} successful", chunk_index); + debug!( + "beta_g1 aggregation for chunk {} successful; {} G1 elements written", + chunk_index, + elements.len() + ); }); }); } @@ -108,7 +130,7 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { beta_g2 .write_element(&element, compressed_output) .expect("should have written element"); - trace!("beta_g2 aggregation for chunk {} successful", chunk_index); + debug!("beta_g2 aggregation for chunk {} successful", chunk_index); } }); } diff --git a/phase1/src/computation.rs b/phase1/src/computation.rs index 1bdc4741..3ba4613f 100644 --- a/phase1/src/computation.rs +++ b/phase1/src/computation.rs @@ -20,7 +20,7 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { parameters: &'a Phase1Parameters, ) -> Result<()> { let span = info_span!("phase1-computation"); - let _ = span.enter(); + let _enter = span.enter(); info!("starting..."); @@ -31,6 +31,7 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { // Get mutable references of the outputs. let (tau_g1_outputs, tau_g2_outputs, alpha_g1_outputs, beta_g1_outputs, beta_g2_outputs) = split_mut(output, parameters, compressed_output); + info!("Parameters for contribution: {:?}", parameters); match parameters.proving_system { ProvingSystem::Groth16 => { @@ -50,7 +51,7 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { debug!("contributing to chunk from {} to {}", start, end); let span = info_span!("batch", start, end); - let _ = span.enter(); + let _enter = span.enter(); // Determine the chunk start and end indices based on the contribution mode. let (start_chunk, end_chunk) = match parameters.contribution_mode { @@ -62,10 +63,10 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { }; rayon_cfg::scope(|t| { - let _ = span.enter(); + let _enter = span.enter(); t.spawn(|_| { - let _ = span.enter(); + let _enter = span.enter(); // Generate powers from `start` to `end` (e.g. [0,4) then [4, 8) etc.) let powers = generate_powers_of_tau::(&key.tau, start, end); @@ -76,10 +77,11 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { // and write the updated value (without allocating) to the // output buffer rayon_cfg::scope(|t| { - let _ = span.enter(); + let _enter = span.enter(); + info!("Starting powers of Tau in G1"); t.spawn(|_| { - let _ = span.enter(); + let _enter = span.enter(); // Check that the chunk is of nonzero length. assert!(tau_g1_inputs.len() > 0); @@ -93,7 +95,7 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { ) .expect("could not apply powers of tau to tau_g1 elements"); - trace!("applied powers to tau_g1 elements"); + info!("Applied powers to tau_g1 elements"); }); if start < parameters.powers_length { // if the `end` would be out of bounds, then just process until @@ -118,10 +120,11 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { }; rayon_cfg::scope(|t| { - let _ = span.enter(); + let _enter = span.enter(); t.spawn(|_| { - let _ = span.enter(); + let _enter = span.enter(); + info!("Starting powers of Tau in G2"); // Check that the chunk is of nonzero length. assert!(tau_g2_inputs.len() > 0); @@ -135,11 +138,12 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { ) .expect("could not apply powers of tau to tau_g2 elements"); - trace!("applied powers to tau_g2 elements"); + trace!("Applied powers of Tau in G2"); }); t.spawn(|_| { - let _ = span.enter(); + let _enter = span.enter(); + info!("Starting Alpha G1 elements"); // Check that the chunk is of nonzero length. assert!(alpha_g1_inputs.len() > 0); @@ -153,11 +157,12 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { ) .expect("could not apply powers of tau to alpha_g1 elements"); - trace!("applied powers to alpha_g1 elements"); + info!("Applied powers to Alpha G1 elements"); }); t.spawn(|_| { - let _ = span.enter(); + info!("Starting beta G1 elements"); + let _enter = span.enter(); // Check that the chunk is of nonzero length. assert!(beta_g1_inputs.len() > 0); @@ -171,7 +176,7 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { ) .expect("could not apply powers of tau to beta_g1 elements"); - trace!("applied powers to beta_g1 elements"); + trace!("Applied powers to Beta G1 elements"); }); }); } @@ -249,7 +254,7 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { debug!("contributing to chunk from {} to {}", start, end); let span = info_span!("batch", start, end); - let _ = span.enter(); + let _enter = span.enter(); // Determine the chunk start and end indices based on the contribution mode. let (start_chunk, end_chunk) = match parameters.contribution_mode { @@ -261,10 +266,10 @@ impl<'a, E: PairingEngine + Sync> Phase1<'a, E> { }; rayon_cfg::scope(|t| { - let _ = span.enter(); + let _enter = span.enter(); t.spawn(|_| { - let _ = span.enter(); + let _enter = span.enter(); // Generate powers from `start` to `end` (e.g. [0,4) then [4, 8) etc.) let powers = generate_powers_of_tau::(&key.tau, start, end); diff --git a/phase1/src/helpers/buffers.rs b/phase1/src/helpers/buffers.rs index c78ebedf..b0e5a4a6 100644 --- a/phase1/src/helpers/buffers.rs +++ b/phase1/src/helpers/buffers.rs @@ -68,16 +68,17 @@ pub(crate) fn apply_powers( powers: &[C::ScalarField], coeff: Option<&C::ScalarField>, ) -> Result<()> { + tracing::debug!("Applying powers {} to {}", start, end); let in_size = buffer_size::(input_compressed); let out_size = buffer_size::(output_compressed); // Read the input - let mut elements = + let elements = &mut input[start * in_size..end * in_size].read_batch::(input_compressed, check_input_for_correctness)?; // calculate the powers - batch_exp(&mut elements, &powers[..end - start], coeff)?; + batch_exp(elements, &powers[..(end - start)], coeff)?; // write back - output[start * out_size..end * out_size].write_batch(&elements, output_compressed)?; + output[(start * out_size)..(end * out_size)].write_batch(elements, output_compressed)?; Ok(()) }