From 5a00b613551ef85cbf374c3c94aaaace5ad2eacb Mon Sep 17 00:00:00 2001 From: Andrey Khmuro Date: Tue, 30 Jan 2024 18:56:10 +0300 Subject: [PATCH] feat: enable tracing_forest as an option --- examples/Cargo.toml | 3 +- examples/src/fibonacci/fib2/mod.rs | 37 ++-- examples/src/fibonacci/fib8/mod.rs | 19 +- examples/src/fibonacci/fib_small/mod.rs | 19 +- examples/src/fibonacci/mulfib2/mod.rs | 19 +- examples/src/fibonacci/mulfib8/mod.rs | 19 +- examples/src/lamport/aggregate/mod.rs | 19 +- examples/src/lamport/threshold/mod.rs | 18 +- examples/src/main.rs | 25 ++- examples/src/merkle/mod.rs | 20 +-- examples/src/rescue/mod.rs | 20 +-- examples/src/rescue_raps/mod.rs | 20 +-- examples/src/vdf/exempt/mod.rs | 19 +- examples/src/vdf/regular/mod.rs | 19 +- prover/src/lib.rs | 208 +++++++++++----------- prover/src/trace/trace_lde/default/mod.rs | 42 +++-- 16 files changed, 281 insertions(+), 245 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 363242925..43d7e9daf 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -23,6 +23,7 @@ doc = false [features] concurrent = ["winterfell/concurrent", "std"] default = ["std"] +tree = ["std", "tracing-forest"] std = ["core-utils/std", "hex/std", "rand-utils", "winterfell/std"] [dependencies] @@ -33,7 +34,7 @@ rand-utils = { version = "0.7", path = "../utils/rand", package = "winter-rand-u structopt = { version = "0.3", default-features = false } tracing = { version = "0.1", default-features = false } tracing-subscriber = { version = "0.3", features = ["std", "env-filter"] } -tracing-forest = { version = "0.1", features = ["ansi", "smallvec"] } +tracing-forest = { version = "0.1", features = ["ansi", "smallvec"], optional = true } winterfell = { version="0.7", path = "../winterfell", default-features = false } [dev-dependencies] diff --git a/examples/src/fibonacci/fib2/mod.rs b/examples/src/fibonacci/fib2/mod.rs index ea5c76d77..7674d74c2 100644 --- a/examples/src/fibonacci/fib2/mod.rs +++ b/examples/src/fibonacci/fib2/mod.rs @@ -7,7 +7,7 @@ use super::utils::compute_fib_term; use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_256}; use core::marker::PhantomData; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -97,19 +97,36 @@ where let prover = FibProver::::new(self.options.clone()); // generate execution trace - let trace = info_span!("Generating execution trace").in_scope(|| { + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = prover.build_trace(self.sequence_length); - let trace_width = trace.width(); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace_width, - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); + // let span = info_span!("Generating execution trace", registers_num = field::Empty, steps = field::Empty); + // let trace = prover.build_trace(self.sequence_length); + // span.record("registers_num", &format!("{}", trace.width())); + // span.record("steps", &format!("2^{} steps", trace.length().ilog2())); + + // let trace = info_span!("Generating execution trace").in_scope(|| { + // let trace = prover.build_trace(self.sequence_length); + // let trace_width = trace.width(); + // let trace_length = trace.length(); + // event!( + // Level::DEBUG, + // "Generated execution trace of {} registers and 2^{} steps", + // trace_width, + // trace_length.ilog2(), + // ); + // trace + // }); + // generate the proof prover.prove(trace).unwrap() } diff --git a/examples/src/fibonacci/fib8/mod.rs b/examples/src/fibonacci/fib8/mod.rs index b09829f31..380026b67 100644 --- a/examples/src/fibonacci/fib8/mod.rs +++ b/examples/src/fibonacci/fib8/mod.rs @@ -7,7 +7,7 @@ use super::utils::compute_fib_term; use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_256}; use core::marker::PhantomData; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -97,16 +97,15 @@ where let prover = Fib8Prover::::new(self.options.clone()); // generate execution trace - let trace = info_span!("Generating execution trace").in_scope(|| { + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = prover.build_trace(self.sequence_length); - let trace_width = trace.width(); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace_width, - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); diff --git a/examples/src/fibonacci/fib_small/mod.rs b/examples/src/fibonacci/fib_small/mod.rs index e03393af1..a8c0f6fd6 100644 --- a/examples/src/fibonacci/fib_small/mod.rs +++ b/examples/src/fibonacci/fib_small/mod.rs @@ -7,7 +7,7 @@ use super::utils::compute_fib_term; use crate::{Example, ExampleOptions, HashFunction}; use core::marker::PhantomData; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f64::BaseElement, FieldElement}, @@ -112,16 +112,15 @@ where let prover = FibSmallProver::::new(self.options.clone()); // generate execution trace - let trace = info_span!("Generating execution trace").in_scope(|| { + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = prover.build_trace(self.sequence_length); - let trace_width = trace.width(); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace_width, - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); diff --git a/examples/src/fibonacci/mulfib2/mod.rs b/examples/src/fibonacci/mulfib2/mod.rs index d97da7d9d..b02cf1ff8 100644 --- a/examples/src/fibonacci/mulfib2/mod.rs +++ b/examples/src/fibonacci/mulfib2/mod.rs @@ -7,7 +7,7 @@ use super::utils::compute_mulfib_term; use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_256}; use core::marker::PhantomData; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -92,16 +92,15 @@ where let prover = MulFib2Prover::::new(self.options.clone()); // generate execution trace - let trace = info_span!("Generating execution trace").in_scope(|| { + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = prover.build_trace(sequence_length); - let trace_width = trace.width(); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace_width, - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); diff --git a/examples/src/fibonacci/mulfib8/mod.rs b/examples/src/fibonacci/mulfib8/mod.rs index 4b98feb06..0e829776b 100644 --- a/examples/src/fibonacci/mulfib8/mod.rs +++ b/examples/src/fibonacci/mulfib8/mod.rs @@ -7,7 +7,7 @@ use super::utils::compute_mulfib_term; use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_256}; use core::marker::PhantomData; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -93,16 +93,15 @@ where let prover = MulFib8Prover::::new(self.options.clone()); // generate execution trace - let trace = info_span!("Generating execution trace").in_scope(|| { + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = prover.build_trace(sequence_length); - let trace_width = trace.width(); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace_width, - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); diff --git a/examples/src/lamport/aggregate/mod.rs b/examples/src/lamport/aggregate/mod.rs index ab679831a..89ecbcd6f 100644 --- a/examples/src/lamport/aggregate/mod.rs +++ b/examples/src/lamport/aggregate/mod.rs @@ -9,7 +9,7 @@ use super::{ use crate::{Blake3_192, Blake3_256, ExampleOptions, HashFunction, Sha3_256}; use core::marker::PhantomData; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, get_power_series, FieldElement, StarkField}, @@ -122,15 +122,16 @@ where let prover = LamportAggregateProver::::new(&self.pub_keys, &self.messages, self.options.clone()); - let trace = info_span!("Generating execution trace").in_scope(|| { + // generate execution trace + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = prover.build_trace(&self.messages, &self.signatures); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace.width(), - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); diff --git a/examples/src/lamport/threshold/mod.rs b/examples/src/lamport/threshold/mod.rs index bc0e69bca..265e48562 100644 --- a/examples/src/lamport/threshold/mod.rs +++ b/examples/src/lamport/threshold/mod.rs @@ -10,7 +10,7 @@ use super::{ use crate::{Blake3_192, Blake3_256, ExampleOptions, HashFunction, Sha3_256}; use core::marker::PhantomData; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, get_power_series, FieldElement, StarkField}, @@ -129,15 +129,15 @@ where ); // generate execution trace - let trace = info_span!("Generating execution trace").in_scope(|| { + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = prover.build_trace(&self.pub_key, self.message, &self.signatures); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace.width(), - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); diff --git a/examples/src/main.rs b/examples/src/main.rs index ec96788bb..68251d8f9 100644 --- a/examples/src/main.rs +++ b/examples/src/main.rs @@ -6,7 +6,10 @@ use std::time::Instant; use structopt::StructOpt; use tracing::info_span; +#[cfg(feature = "tree")] use tracing_forest::ForestLayer; +#[cfg(not(feature = "tree"))] +use tracing_subscriber::fmt::format::FmtSpan; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; use winterfell::StarkProof; @@ -22,11 +25,25 @@ fn main() { if std::env::var("WINTER_LOG").is_err() { std::env::set_var("WINTER_LOG", "info"); } + let registry = + tracing_subscriber::registry::Registry::default().with(EnvFilter::from_env("WINTER_LOG")); - tracing_subscriber::registry::Registry::default() - .with(EnvFilter::from_env("WINTER_LOG")) - .with(ForestLayer::default()) - .init(); + #[cfg(feature = "tree")] + registry.with(ForestLayer::default()).init(); + + #[cfg(not(feature = "tree"))] + { + let format = tracing_subscriber::fmt::layer() + .with_level(false) + .with_target(false) + .with_thread_names(false) + .with_span_events(FmtSpan::CLOSE) + .with_ansi(false) + .with_timer(tracing_subscriber::fmt::time::SystemTime::default()) + .compact(); + + registry.with(format).init(); + } // read command-line args let options = ExampleOptions::from_args(); diff --git a/examples/src/merkle/mod.rs b/examples/src/merkle/mod.rs index 427c493b0..71bb979c4 100644 --- a/examples/src/merkle/mod.rs +++ b/examples/src/merkle/mod.rs @@ -14,7 +14,7 @@ use crate::{ use core::marker::PhantomData; use rand_utils::{rand_value, rand_vector}; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, Digest, ElementHasher, MerkleTree}, math::{fields::f128::BaseElement, FieldElement, StarkField}, @@ -116,16 +116,16 @@ where // create the prover let prover = MerkleProver::::new(self.options.clone()); - // generate the execution trace - let trace = info_span!("Generating execution trace").in_scope(|| { + // generate execution trace + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = prover.build_trace(self.value, &self.path, self.index); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace.width(), - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); diff --git a/examples/src/rescue/mod.rs b/examples/src/rescue/mod.rs index 8efaf8907..efb9c834f 100644 --- a/examples/src/rescue/mod.rs +++ b/examples/src/rescue/mod.rs @@ -6,7 +6,7 @@ use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_256}; use core::marker::PhantomData; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -101,16 +101,16 @@ where // create a prover let prover = RescueProver::::new(self.options.clone()); - // generate the execution trace - let trace = info_span!("Generating execution trace").in_scope(|| { + // generate execution trace + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = prover.build_trace(self.seed, self.chain_length); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace.width(), - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); diff --git a/examples/src/rescue_raps/mod.rs b/examples/src/rescue_raps/mod.rs index 556661944..a3080ceec 100644 --- a/examples/src/rescue_raps/mod.rs +++ b/examples/src/rescue_raps/mod.rs @@ -7,7 +7,7 @@ use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_ use core::marker::PhantomData; use rand_utils::rand_array; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, ExtensionOf, FieldElement}, @@ -114,16 +114,16 @@ where // create a prover let prover = RescueRapsProver::::new(self.options.clone()); - // generate the execution trace - let trace = info_span!("Generating execution trace").in_scope(|| { + // generate execution trace + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = prover.build_trace(&self.seeds, &self.permuted_seeds, self.result); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace.width(), - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); diff --git a/examples/src/vdf/exempt/mod.rs b/examples/src/vdf/exempt/mod.rs index b5d445958..230469f0b 100644 --- a/examples/src/vdf/exempt/mod.rs +++ b/examples/src/vdf/exempt/mod.rs @@ -6,7 +6,7 @@ use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_256}; use core::marker::PhantomData; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -92,16 +92,15 @@ where let prover = VdfProver::::new(self.options.clone()); // generate execution trace - let trace = info_span!("Generating execution trace").in_scope(|| { + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = VdfProver::::build_trace(self.seed, self.num_steps + 1); - let trace_width = trace.width(); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace_width, - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); diff --git a/examples/src/vdf/regular/mod.rs b/examples/src/vdf/regular/mod.rs index e7ee2c70d..a005826cd 100644 --- a/examples/src/vdf/regular/mod.rs +++ b/examples/src/vdf/regular/mod.rs @@ -6,7 +6,7 @@ use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_256}; use core::marker::PhantomData; use std::time::Instant; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -89,16 +89,15 @@ where let prover = VdfProver::::new(self.options.clone()); // generate execution trace - let trace = info_span!("Generating execution trace").in_scope(|| { + let trace = info_span!( + "Generated execution trace", + registers_num = field::Empty, + steps = field::Empty + ) + .in_scope(|| { let trace = VdfProver::::build_trace(self.seed, self.num_steps); - let trace_width = trace.width(); - let trace_length = trace.length(); - event!( - Level::DEBUG, - "Generated execution trace of {} registers and 2^{} steps", - trace_width, - trace_length.ilog2(), - ); + tracing::Span::current().record("registers_num", &format!("{}", trace.width())); + tracing::Span::current().record("steps", &format!("2^{}", trace.length().ilog2())); trace }); diff --git a/prover/src/lib.rs b/prover/src/lib.rs index aa5eb2d6a..45012b8b0 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -49,7 +49,7 @@ pub use air::{ DeepCompositionCoefficients, EvaluationFrame, FieldExtension, ProofOptions, TraceInfo, TraceLayout, TransitionConstraintDegree, }; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; pub use utils::{ iterators, ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable, SliceReader, @@ -253,16 +253,13 @@ pub trait Prover { // 1 ----- Commit to the execution trace -------------------------------------------------- // build computation domain; this is used later for polynomial evaluations - let domain = - info_span!("Building domain").in_scope(|| { - let domain = StarkDomain::new(&air); - event!( - Level::DEBUG, - "Built domain of 2^{} elements", - domain.lde_domain_size().ilog2(), - ); - domain - }); + let domain = info_span!( + "Built domain", + elements_number = format!("2^{}", air.lde_domain_size().ilog2()) + ) + .in_scope(|| { + StarkDomain::new(&air) + }); // extend the main execution trace and build a Merkle tree from the extended trace let (mut trace_lde, mut trace_polys): (Self::TraceLde, TracePolyTable) = @@ -280,23 +277,24 @@ pub trait Prover { let mut aux_trace_segments = Vec::new(); let mut aux_trace_rand_elements = AuxTraceRandElements::new(); for i in 0..trace.layout().num_aux_segments() { - let (aux_segment, rand_elements) = info_span!("Built auxiliary trace segment") - .in_scope(|| { - // draw a set of random elements required to build an auxiliary trace segment - let rand_elements = channel.get_aux_trace_segment_rand_elements(i); - - // build the trace segment - let aux_segment = trace - .build_aux_segment(&aux_trace_segments, &rand_elements) - .expect("failed build auxiliary trace segment"); - event!( - Level::DEBUG, - "Built auxiliary trace segment of {} columns and 2^{} steps", - aux_segment.num_cols(), - aux_segment.num_rows().ilog2(), - ); - (aux_segment, rand_elements) - }); + let (aux_segment, rand_elements) = info_span!( + "Built auxiliary trace segment", + columns_number = field::Empty, + steps = field::Empty + ) + .in_scope(|| { + // draw a set of random elements required to build an auxiliary trace segment + let rand_elements = channel.get_aux_trace_segment_rand_elements(i); + + // build the trace segment + let aux_segment = trace + .build_aux_segment(&aux_trace_segments, &rand_elements) + .expect("failed build auxiliary trace segment"); + tracing::Span::current().record("columns_number", aux_segment.num_cols()); + tracing::Span::current() + .record("steps", &format!("2^{}", aux_segment.num_rows().ilog2())); + (aux_segment, rand_elements) + }); // extend the auxiliary trace segment and build a Merkle tree from the extended trace let (aux_segment_polys, aux_segment_root) = @@ -325,17 +323,18 @@ pub trait Prover { // evaluate constraints specified by the AIR over the constraint evaluation domain, and // compute random linear combinations of these evaluations using coefficients drawn from // the channel - let composition_poly_trace = info_span!("Evaluating constraints").in_scope(|| { - let constraint_coeffs = channel.get_constraint_composition_coeffs(); - let evaluator = self.new_evaluator(&air, aux_trace_rand_elements, constraint_coeffs); - let composition_poly_trace = evaluator.evaluate(&trace_lde, &domain); - event!( - Level::DEBUG, - "Evaluated constraints over domain of 2^{} elements", - composition_poly_trace.num_rows().ilog2(), - ); - composition_poly_trace - }); + let composition_poly_trace = + info_span!("Evaluated constraints", domain_size = field::Empty).in_scope(|| { + let constraint_coeffs = channel.get_constraint_composition_coeffs(); + let evaluator = + self.new_evaluator(&air, aux_trace_rand_elements, constraint_coeffs); + let composition_poly_trace = evaluator.evaluate(&trace_lde, &domain); + tracing::Span::current().record( + "domain_size", + &format!("2^{} elements", composition_poly_trace.num_rows().ilog2()), + ); + composition_poly_trace + }); // 3 ----- commit to constraint evaluations ----------------------------------------------- @@ -353,7 +352,7 @@ pub trait Prover { // 4 ----- build DEEP composition polynomial ---------------------------------------------- let deep_composition_poly = - info_span!("Building DEEP composition polynomial").in_scope(|| { + info_span!("Built DEEP composition polynomial", degree = field::Empty).in_scope(|| { // draw an out-of-domain point z. Depending on the type of E, the point is drawn either // from the base field or from an extension field defined by E. // @@ -384,11 +383,8 @@ pub trait Prover { // merge columns of constraint composition polynomial into the DEEP composition polynomial; deep_composition_poly.add_composition_poly(composition_poly, ood_evaluations); - event!( - Level::DEBUG, - "Built DEEP composition polynomial of degree {}", - deep_composition_poly.degree(), - ); + tracing::Span::current().record("degree", deep_composition_poly.degree()); + deep_composition_poly }); @@ -397,51 +393,53 @@ pub trait Prover { assert_eq!(domain.trace_length() - 2, deep_composition_poly.degree()); // 5 ----- evaluate DEEP composition polynomial over LDE domain --------------------------- - let deep_evaluations = info_span!("Evaluating DEEP composition polynomial over LDE domain") - .in_scope(|| { - let deep_evaluations = deep_composition_poly.evaluate(&domain); - // we check the following condition in debug mode only because infer_degree is an expensive - // operation - debug_assert_eq!( - domain.trace_length() - 2, - infer_degree(&deep_evaluations, domain.offset()) - ); - event!( - Level::DEBUG, - "Evaluated DEEP composition polynomial over LDE domain (2^{} elements)", - domain.lde_domain_size().ilog2(), - ); - deep_evaluations - }); + let deep_evaluations = info_span!( + "Evaluated DEEP composition polynomial over LDE domain", + domain_size = format!("2^{}", domain.lde_domain_size().ilog2()) + ) + .in_scope(|| { + let deep_evaluations = deep_composition_poly.evaluate(&domain); + // we check the following condition in debug mode only because infer_degree is an expensive + // operation + debug_assert_eq!( + domain.trace_length() - 2, + infer_degree(&deep_evaluations, domain.offset()) + ); + + deep_evaluations + }); // 6 ----- compute FRI layers for the composition polynomial ------------------------------ let mut fri_prover = info_span!( - "Computing FRI layers from composition polynomial evaluations" + "Computed FRI layers from composition polynomial evaluations", + layers_number = field::Empty ) .in_scope(|| { let mut fri_prover = FriProver::new(air.options().to_fri_options()); fri_prover.build_layers(&mut channel, deep_evaluations); - event!( - Level::DEBUG, - "Computed {} FRI layers from composition polynomial evaluations", - fri_prover.num_layers(), - ); + + tracing::Span::current().record("layers_number", fri_prover.num_layers()); + fri_prover }); // 7 ----- determine query positions ------------------------------------------------------ - let query_positions = info_span!("Determining unique query positions").in_scope(|| { - // apply proof-of-work to the query seed - channel.grind_query_seed(); - - // generate pseudo-random query positions - let query_positions = channel.get_query_positions(); - event!(Level::DEBUG, "Determined {} unique query positions", query_positions.len(),); - query_positions - }); + let query_positions = + info_span!("Determined unique query positions", positions_number = field::Empty) + .in_scope(|| { + // apply proof-of-work to the query seed + channel.grind_query_seed(); + + // generate pseudo-random query positions + let query_positions = channel.get_query_positions(); + + tracing::Span::current().record("positions_number", query_positions.len()); + + query_positions + }); // 8 ----- build proof object ------------------------------------------------------------- - let proof = info_span!("Building proof object").in_scope(|| { + let proof = info_span!("Built proof object").in_scope(|| { // generate FRI proof let fri_proof = fri_prover.build_proof(&query_positions); @@ -484,49 +482,53 @@ pub trait Prover { // - interpolate the trace into a polynomial in coefficient form // - "break" the polynomial into a set of column polynomials each of degree equal to // trace_length - 1 - let composition_poly = info_span!("Converting constraint evaluations into composition polynomial columns").in_scope(|| { + let composition_poly = info_span!( + "Converted constraint evaluations into composition polynomial columns", + columns_number = field::Empty, + degree = field::Empty + ) + .in_scope(|| { let composition_poly = CompositionPoly::new(composition_poly_trace, domain, num_trace_poly_columns); - event!( - Level::DEBUG, - "Converted constraint evaluations into {} composition polynomial columns of degree {}", - composition_poly.num_columns(), - composition_poly.column_degree(), - ); + + tracing::Span::current().record("columns_number", composition_poly.num_columns()); + tracing::Span::current().record("degree", composition_poly.column_degree()); + composition_poly }); // then, evaluate composition polynomial columns over the LDE domain let composed_evaluations = info_span!( - "Evaluating composition polynomial columns over LDE domain" + "Evaluated composition polynomial columns over LDE domain", + columns_number = field::Empty, + domain_size = field::Empty ) .in_scope(|| { let composed_evaluations = RowMatrix::evaluate_polys_over::( composition_poly.data(), domain, ); - event!( - Level::DEBUG, - "Evaluated {} composition polynomial columns over LDE domain (2^{} elements)", - composed_evaluations.num_cols(), - composed_evaluations.num_rows().ilog2(), - ); + + tracing::Span::current().record("columns_number", composed_evaluations.num_cols()); + tracing::Span::current().record("domain_size", composed_evaluations.num_rows().ilog2()); + composed_evaluations }); // finally, build constraint evaluation commitment - let constraint_commitment = info_span!("Computing constraint evaluation commitment") - .in_scope(|| { - let commitment = composed_evaluations.commit_to_rows(); - let constraint_commitment = - ConstraintCommitment::new(composed_evaluations, commitment); - event!( - Level::DEBUG, - "Computed constraint evaluation commitment (Merkle tree of depth {})", - constraint_commitment.tree_depth(), - ); - constraint_commitment - }); + let constraint_commitment = info_span!( + "Computed constraint evaluation commitment", + merkle_tree_depth = field::Empty + ) + .in_scope(|| { + let commitment = composed_evaluations.commit_to_rows(); + let constraint_commitment = ConstraintCommitment::new(composed_evaluations, commitment); + + tracing::Span::current() + .record("merkle_tree_depth", constraint_commitment.tree_depth()); + + constraint_commitment + }); (constraint_commitment, composition_poly) } diff --git a/prover/src/trace/trace_lde/default/mod.rs b/prover/src/trace/trace_lde/default/mod.rs index faf71b2c9..b18ab6a68 100644 --- a/prover/src/trace/trace_lde/default/mod.rs +++ b/prover/src/trace/trace_lde/default/mod.rs @@ -9,7 +9,7 @@ use super::{ }; use crate::{RowMatrix, DEFAULT_SEGMENT_WIDTH}; use crypto::MerkleTree; -use tracing::{event, info_span, Level}; +use tracing::{field, info_span}; #[cfg(test)] mod tests; @@ -230,31 +230,35 @@ where H: ElementHasher, { // extend the execution trace - let (trace_lde, trace_polys) = info_span!("Extending execution trace").in_scope(|| { + let (trace_lde, trace_polys) = info_span!( + "Extended execution trace", + columns_number = field::Empty, + from = field::Empty, + to = field::Empty, + blowup = field::Empty + ) + .in_scope(|| { let trace_polys = trace.interpolate_columns(); let trace_lde = RowMatrix::evaluate_polys_over::(&trace_polys, domain); - event!( - Level::DEBUG, - "Extended execution trace of {} columns from 2^{} to 2^{} steps ({}x blowup)", - trace_lde.num_cols(), - trace_polys.num_rows().ilog2(), - trace_lde.num_rows().ilog2(), - domain.trace_to_lde_blowup(), - ); + + tracing::Span::current().record("columns_number", &format!("{}", trace_lde.num_cols())); + tracing::Span::current().record("from", &format!("2^{}", trace_polys.num_rows().ilog2())); + tracing::Span::current().record("to", &format!("2^{}", trace_lde.num_rows().ilog2())); + tracing::Span::current().record("blowup", &format!("{}x", domain.trace_to_lde_blowup())); + (trace_lde, trace_polys) }); // build trace commitment - let trace_tree = info_span!("Computing execution trace commitment").in_scope(|| { - let trace_tree = trace_lde.commit_to_rows(); - event!( - Level::DEBUG, - "Computed execution trace commitment (Merkle tree of depth {})", - trace_tree.depth(), - ); - trace_tree - }); + let trace_tree = + info_span!("Computed execution trace commitment", merkle_tree_depth = field::Empty) + .in_scope(|| { + let trace_tree = trace_lde.commit_to_rows(); + tracing::Span::current() + .record("merkle_tree_depth", &format!("{}", trace_tree.depth())); + trace_tree + }); (trace_lde, trace_tree, trace_polys) }