From 985e78b89c60b3d6e628b46ca52dc2213bc0a1e8 Mon Sep 17 00:00:00 2001 From: Andrey Khmuro Date: Sun, 14 Jan 2024 14:41:48 +0300 Subject: [PATCH] feat: implement tree-like logger --- examples/Cargo.toml | 1 + examples/src/fibonacci/fib2/mod.rs | 32 +- examples/src/fibonacci/fib8/mod.rs | 31 +- examples/src/fibonacci/fib_small/mod.rs | 32 +- examples/src/fibonacci/mulfib2/mod.rs | 31 +- examples/src/fibonacci/mulfib8/mod.rs | 31 +- examples/src/lamport/aggregate/mod.rs | 43 +-- examples/src/lamport/threshold/mod.rs | 31 +- examples/src/main.rs | 65 ++-- examples/src/merkle/mod.rs | 36 +-- examples/src/rescue/mod.rs | 29 +- examples/src/rescue_raps/mod.rs | 29 +- examples/src/vdf/exempt/mod.rs | 32 +- examples/src/vdf/regular/mod.rs | 32 +- prover/src/lib.rs | 359 +++++++++++----------- prover/src/trace/trace_lde/default/mod.rs | 53 ++-- verifier/README.md | 4 +- 17 files changed, 398 insertions(+), 473 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 3c20da952..363242925 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -33,6 +33,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"] } 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 1b73a5fc2..73e8215e1 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -65,8 +65,7 @@ impl FibExample { // compute Fibonacci sequence let now = Instant::now(); let result = compute_fib_term(sequence_length); - event!( - Level::DEBUG, + println!( "Computed Fibonacci sequence up to {}th term in {} ms", sequence_length, now.elapsed().as_millis() @@ -91,8 +90,7 @@ where fn prove(&self) -> StarkProof { event!( Level::DEBUG, - "Generating proof for computing Fibonacci sequence (2 terms per step) up to {}th term\n\ - ---------------------", + "Generating proof for computing Fibonacci sequence (2 terms per step) up to {}th term", self.sequence_length ); @@ -100,18 +98,18 @@ where let prover = FibProver::::new(self.options.clone()); // generate execution trace - let now = Instant::now(); - 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 in {} ms", - trace_width, - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_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::TRACE, + "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 dd622bdc3..bf9d3673a 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -65,8 +65,7 @@ impl Fib8Example { // compute Fibonacci sequence let now = Instant::now(); let result = compute_fib_term(sequence_length); - event!( - Level::DEBUG, + println!( "Computed Fibonacci sequence up to {}th term in {} ms", sequence_length, now.elapsed().as_millis() @@ -91,8 +90,7 @@ where fn prove(&self) -> StarkProof { event!( Level::DEBUG, - "Generating proof for computing Fibonacci sequence (8 terms per step) up to {}th term\n\ - ---------------------", + "Generating proof for computing Fibonacci sequence (8 terms per step) up to {}th term", self.sequence_length ); @@ -100,17 +98,18 @@ where let prover = Fib8Prover::::new(self.options.clone()); // generate execution trace - let now = Instant::now(); - 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 in {} ms", - trace_width, - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_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::TRACE, + "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/fib_small/mod.rs b/examples/src/fibonacci/fib_small/mod.rs index 9be72c8e7..307e0ad9f 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f64::BaseElement, FieldElement}, @@ -80,8 +80,7 @@ impl FibExample { // compute Fibonacci sequence let now = Instant::now(); let result = compute_fib_term::(sequence_length); - event!( - Level::DEBUG, + println!( "Computed Fibonacci sequence up to {}th term in {} ms", sequence_length, now.elapsed().as_millis() @@ -106,8 +105,7 @@ where fn prove(&self) -> StarkProof { event!( Level::DEBUG, - "Generating proof for computing Fibonacci sequence (2 terms per step) up to {}th term\n\ - ---------------------", + "Generating proof for computing Fibonacci sequence (2 terms per step) up to {}th term", self.sequence_length ); @@ -115,18 +113,18 @@ where let prover = FibSmallProver::::new(self.options.clone()); // generate execution trace - let now = Instant::now(); - 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 in {} ms", - trace_width, - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_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::TRACE, + "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/mulfib2/mod.rs b/examples/src/fibonacci/mulfib2/mod.rs index afd487838..c71cbc9a7 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -59,8 +59,7 @@ impl MulFib2Example { // compute Fibonacci sequence let now = Instant::now(); let result = compute_mulfib_term(sequence_length); - event!( - Level::DEBUG, + println!( "Computed multiplicative Fibonacci sequence up to {}th term in {} ms", sequence_length, now.elapsed().as_millis() @@ -86,8 +85,7 @@ where let sequence_length = self.sequence_length; event!( Level::DEBUG, - "Generating proof for computing multiplicative Fibonacci sequence (8 terms per step) up to {}th term\n\ - ---------------------", + "Generating proof for computing multiplicative Fibonacci sequence (2 terms per step) up to {}th term", sequence_length ); @@ -95,17 +93,18 @@ where let prover = MulFib2Prover::::new(self.options.clone()); // generate execution trace - let now = Instant::now(); - 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 in {} ms", - trace_width, - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_span!("Generating execution trace").in_scope(|| { + let trace = prover.build_trace(sequence_length); + let trace_width = trace.width(); + let trace_length = trace.length(); + event!( + Level::TRACE, + "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/mulfib8/mod.rs b/examples/src/fibonacci/mulfib8/mod.rs index 5656ccc05..05aa6fa3d 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -60,8 +60,7 @@ impl MulFib8Example { // compute Fibonacci sequence let now = Instant::now(); let result = compute_mulfib_term(sequence_length); - event!( - Level::DEBUG, + println!( "Computed multiplicative Fibonacci sequence up to {}th term in {} ms", sequence_length, now.elapsed().as_millis() @@ -87,8 +86,7 @@ where let sequence_length = self.sequence_length; event!( Level::DEBUG, - "Generating proof for computing multiplicative Fibonacci sequence (2 terms per step) up to {}th term\n\ - ---------------------", + "Generating proof for computing multiplicative Fibonacci sequence (8 terms per step) up to {}th term", sequence_length ); @@ -96,17 +94,18 @@ where let prover = MulFib8Prover::::new(self.options.clone()); // generate execution trace - let now = Instant::now(); - 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 in {} ms", - trace_width, - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_span!("Generating execution trace").in_scope(|| { + let trace = prover.build_trace(sequence_length); + let trace_width = trace.width(); + let trace_length = trace.length(); + event!( + Level::TRACE, + "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/lamport/aggregate/mod.rs b/examples/src/lamport/aggregate/mod.rs index 39e0cfb08..2d6d14ba2 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, get_power_series, FieldElement, StarkField}, @@ -69,8 +69,7 @@ impl LamportAggregateExample { private_keys.push(PrivateKey::from_seed([i as u8; 32])); public_keys.push(private_keys[i].pub_key().to_elements()); } - event!( - Level::DEBUG, + println!( "Generated {} private-public key pairs in {} ms", num_signatures, now.elapsed().as_millis() @@ -85,12 +84,7 @@ impl LamportAggregateExample { signatures.push(private_key.sign(msg.as_bytes())); messages.push(message_to_elements(msg.as_bytes())); } - event!( - Level::DEBUG, - "Signed {} messages in {} ms", - num_signatures, - now.elapsed().as_millis() - ); + println!("Signed {} messages in {} ms", num_signatures, now.elapsed().as_millis()); // verify signature let now = Instant::now(); @@ -101,12 +95,7 @@ impl LamportAggregateExample { let msg = format!("test message {i}"); assert!(pk.verify(msg.as_bytes(), signature)); } - event!( - Level::DEBUG, - "Verified {} signature in {} ms", - num_signatures, - now.elapsed().as_millis() - ); + println!("Verified {} signature in {} ms", num_signatures, now.elapsed().as_millis()); LamportAggregateExample { options, @@ -129,8 +118,7 @@ where // generate the execution trace event!( Level::DEBUG, - "Generating proof for verifying {} Lamport+ signatures \n\ - ---------------------", + "Generating proof for verifying {} Lamport+ signatures", self.signatures.len(), ); @@ -138,16 +126,17 @@ where let prover = LamportAggregateProver::::new(&self.pub_keys, &self.messages, self.options.clone()); - let now = Instant::now(); - 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 in {} ms", - trace.width(), - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_span!("Generating execution trace").in_scope(|| { + let trace = prover.build_trace(&self.messages, &self.signatures); + let trace_length = trace.length(); + event!( + Level::TRACE, + "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/lamport/threshold/mod.rs b/examples/src/lamport/threshold/mod.rs index 66a385cf3..95f1e9513 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, get_power_series, FieldElement, StarkField}, @@ -72,8 +72,7 @@ impl LamportThresholdExample { // generate private/public key pairs for the specified number of signatures let now = Instant::now(); let private_keys = build_keys(num_signers); - event!( - Level::DEBUG, + println!( "Generated {} private-public key pairs in {} ms", num_signers, now.elapsed().as_millis() @@ -92,7 +91,7 @@ impl LamportThresholdExample { // build the aggregated public key let now = Instant::now(); let pub_key = AggPublicKey::new(public_keys); - event!(Level::DEBUG, "Built aggregated public key in {} ms", now.elapsed().as_millis()); + println!("Built aggregated public key in {} ms", now.elapsed().as_millis()); let (options, _) = options.to_proof_options(28, 8); @@ -117,8 +116,7 @@ where // generate the execution trace event!( Level::DEBUG, - "Generating proof for verifying {}-of-{} signature \n\ - ---------------------", + "Generating proof for verifying {}-of-{} signature", self.signatures.len(), self.pub_key.num_keys(), ); @@ -132,16 +130,17 @@ where ); // generate execution trace - let now = Instant::now(); - 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 in {} ms", - trace.width(), - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_span!("Generating execution trace").in_scope(|| { + let trace = prover.build_trace(&self.pub_key, self.message, &self.signatures); + let trace_length = trace.length(); + event!( + Level::TRACE, + "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/main.rs b/examples/src/main.rs index 5b45c64e0..aa696fe4d 100644 --- a/examples/src/main.rs +++ b/examples/src/main.rs @@ -3,10 +3,10 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. -use std::time::Instant; use structopt::StructOpt; -use tracing::{event, level_filters::LevelFilter, Level}; -use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, Layer}; +use tracing::info_span; +use tracing_forest::ForestLayer; +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; use winterfell::StarkProof; use examples::{fibonacci, rescue, vdf, ExampleOptions, ExampleType}; @@ -18,22 +18,18 @@ use examples::{lamport, merkle, rescue_raps}; fn main() { // configure logging - let format = tracing_subscriber::fmt::layer() - .with_level(false) - .with_target(false) - .with_thread_ids(false) - .with_thread_names(false) - .with_file(false) - .without_time() - .with_filter(LevelFilter::DEBUG); + if std::env::var("WINTER_LOG").is_err() { + std::env::set_var("WINTER_LOG", "info"); + } - tracing_subscriber::registry().with(format).init(); + tracing_subscriber::registry::Registry::default() + .with(EnvFilter::from_env("WINTER_LOG")) + .with(ForestLayer::default()) + .init(); // read command-line args let options = ExampleOptions::from_args(); - event!(Level::DEBUG, "============================================================"); - // instantiate and prepare the example let example = match options.example { ExampleType::Fib { sequence_length } => { @@ -72,52 +68,33 @@ fn main() { .expect("The example failed to initialize."); // generate proof - let now = Instant::now(); - let example = example.as_ref(); - let proof = example.prove(); - event!( - Level::DEBUG, - "---------------------\nProof generated in {} ms", - now.elapsed().as_millis() - ); + let proof = info_span!("Generating proof").in_scope(|| example.as_ref().prove()); let proof_bytes = proof.to_bytes(); - event!(Level::DEBUG, "Proof size: {:.1} KB", proof_bytes.len() as f64 / 1024f64); + println!("Proof size: {:.1} KB", proof_bytes.len() as f64 / 1024f64); let conjectured_security_level = options.get_proof_security_level(&proof, true); #[cfg(feature = "std")] { let proven_security_level = options.get_proof_security_level(&proof, false); - event!( - Level::DEBUG, + println!( "Proof security: {} bits ({} proven)", - conjectured_security_level, - proven_security_level, + conjectured_security_level, proven_security_level, ); } #[cfg(not(feature = "std"))] - event!(Level::DEBUG, "Proof security: {} bits", conjectured_security_level); + println!("Proof security: {} bits", conjectured_security_level); #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Proof hash: {}", - hex::encode(blake3::hash(&proof_bytes).as_bytes()) - ); + println!("Proof hash: {}", hex::encode(blake3::hash(&proof_bytes).as_bytes())); // verify the proof - event!(Level::DEBUG, "---------------------"); - let parsed_proof = StarkProof::from_bytes(&proof_bytes).unwrap(); + let parsed_proof = StarkProof::from_bytes(&proof.to_bytes()).unwrap(); assert_eq!(proof, parsed_proof); - let now = Instant::now(); - match example.verify(proof) { - Ok(_) => event!( - Level::DEBUG, - "Proof verified in {:.1} ms", - now.elapsed().as_micros() as f64 / 1000f64 - ), - Err(msg) => event!(Level::DEBUG, "Failed to verify proof: {}", msg), + let result = info_span!("Verifying proof").in_scope(|| example.verify(proof)); + match result { + Ok(_) => println!("Proof verified"), + Err(msg) => println!("Failed to verify proof: {}", msg), } - event!(Level::DEBUG, "============================================================"); } diff --git a/examples/src/merkle/mod.rs b/examples/src/merkle/mod.rs index 3d0e2689c..085ab92f7 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, Digest, ElementHasher, MerkleTree}, math::{fields::f128::BaseElement, FieldElement, StarkField}, @@ -77,18 +77,12 @@ impl MerkleExample { // build Merkle tree of the specified depth let now = Instant::now(); let tree = build_merkle_tree(tree_depth, value, index); - event!( - Level::DEBUG, - "Built Merkle tree of depth {} in {} ms", - tree_depth, - now.elapsed().as_millis(), - ); + println!("Built Merkle tree of depth {} in {} ms", tree_depth, now.elapsed().as_millis(),); // compute Merkle path form the leaf specified by the index let now = Instant::now(); let path = tree.prove(index).unwrap(); - event!( - Level::DEBUG, + println!( "Computed Merkle path from leaf {} to root {} in {} ms", index, hex::encode(tree.root().as_bytes()), @@ -117,24 +111,24 @@ where // generate the execution trace event!( Level::DEBUG, - "Generating proof for proving membership in a Merkle tree of depth {}\n\ - ---------------------", + "Generating proof for proving membership in a Merkle tree of depth {}", self.path.len() ); // create the prover let prover = MerkleProver::::new(self.options.clone()); // generate the execution trace - let now = Instant::now(); - 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 in {} ms", - trace.width(), - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_span!("Generating execution trace").in_scope(|| { + let trace = prover.build_trace(self.value, &self.path, self.index); + let trace_length = trace.length(); + event!( + Level::TRACE, + "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/rescue/mod.rs b/examples/src/rescue/mod.rs index 57d5a873f..fa786ec2d 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -71,8 +71,7 @@ impl RescueExample { // compute the sequence of hashes using external implementation of Rescue hash let now = Instant::now(); let result = compute_hash_chain(seed, chain_length); - event!( - Level::DEBUG, + println!( "Computed a chain of {} Rescue hashes in {} ms", chain_length, now.elapsed().as_millis(), @@ -99,8 +98,7 @@ where // generate the execution trace event!( Level::DEBUG, - "Generating proof for computing a chain of {} Rescue hashes\n\ - ---------------------", + "Generating proof for computing a chain of {} Rescue hashes", self.chain_length ); @@ -108,16 +106,17 @@ where let prover = RescueProver::::new(self.options.clone()); // generate the execution trace - let now = Instant::now(); - 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 in {} ms", - trace.width(), - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_span!("Generating execution trace").in_scope(|| { + let trace = prover.build_trace(self.seed, self.chain_length); + let trace_length = trace.length(); + event!( + Level::TRACE, + "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/rescue_raps/mod.rs b/examples/src/rescue_raps/mod.rs index f4acfea46..422cbd2a7 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, ExtensionOf, FieldElement}, @@ -83,8 +83,7 @@ impl RescueRapsExample { // compute the sequence of hashes using external implementation of Rescue hash let now = Instant::now(); let result = compute_permuted_hash_chains(&seeds, &permuted_seeds); - event!( - Level::DEBUG, + println!( "Computed two permuted chains of {} Rescue hashes in {} ms", chain_length, now.elapsed().as_millis(), @@ -112,8 +111,7 @@ where // generate the execution trace event!( Level::DEBUG, - "Generating proof for computing a chain of {} Rescue hashes\n\ - ---------------------", + "Generating proof for computing a chain of {} Rescue hashes", self.chain_length ); @@ -121,16 +119,17 @@ where let prover = RescueRapsProver::::new(self.options.clone()); // generate the execution trace - let now = Instant::now(); - 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 in {} ms", - trace.width(), - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_span!("Generating execution trace").in_scope(|| { + let trace = prover.build_trace(&self.seeds, &self.permuted_seeds, self.result); + let trace_length = trace.length(); + event!( + Level::TRACE, + "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/vdf/exempt/mod.rs b/examples/src/vdf/exempt/mod.rs index 307cc684d..ef7aabafd 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -62,8 +62,7 @@ impl VdfExample { let now = Instant::now(); let seed = BaseElement::new(123); let result = execute_vdf(seed, num_steps); - event!( - Level::DEBUG, + println!( "Executed the VDF function for {} steps in {} ms", num_steps, now.elapsed().as_millis() @@ -89,8 +88,7 @@ where fn prove(&self) -> StarkProof { event!( Level::DEBUG, - "Generating proof for executing a VDF function for {} steps\n\ - ---------------------", + "Generating proof for executing a VDF function for {} steps", self.num_steps ); @@ -98,18 +96,18 @@ where let prover = VdfProver::::new(self.options.clone()); // generate execution trace - let now = Instant::now(); - 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 in {} ms", - trace_width, - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_span!("Generating execution trace").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::TRACE, + "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/vdf/regular/mod.rs b/examples/src/vdf/regular/mod.rs index 24495b220..adc9a3cb3 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, Level}; +use tracing::{debug_span, event, Level}; use winterfell::{ crypto::{DefaultRandomCoin, ElementHasher}, math::{fields::f128::BaseElement, FieldElement}, @@ -59,8 +59,7 @@ impl VdfExample { let now = Instant::now(); let seed = BaseElement::new(123); let result = execute_vdf(seed, num_steps); - event!( - Level::DEBUG, + println!( "Executed the VDF function for {} steps in {} ms", num_steps, now.elapsed().as_millis() @@ -86,8 +85,7 @@ where fn prove(&self) -> StarkProof { event!( Level::DEBUG, - "Generating proof for executing a VDF function for {} steps\n\ - ---------------------", + "Generating proof for executing a VDF function for {} steps", self.num_steps ); @@ -95,18 +93,18 @@ where let prover = VdfProver::::new(self.options.clone()); // generate execution trace - let now = Instant::now(); - 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 in {} ms", - trace_width, - trace_length.ilog2(), - now.elapsed().as_millis() - ); + let trace = debug_span!("Generating execution trace").in_scope(|| { + let trace = VdfProver::::build_trace(self.seed, self.num_steps); + let trace_width = trace.width(); + let trace_length = trace.length(); + event!( + Level::TRACE, + "Generated execution trace of {} registers and 2^{} steps", + trace_width, + trace_length.ilog2(), + ); + trace + }); // generate the proof prover.prove(trace).unwrap() diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 81c50e96a..b6e4e2eb3 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -49,6 +49,7 @@ pub use air::{ DeepCompositionCoefficients, EvaluationFrame, FieldExtension, ProofOptions, TraceInfo, TraceLayout, TransitionConstraintDegree, }; +use tracing::{debug_span, event, Level}; pub use utils::{ iterators, ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable, SliceReader, @@ -67,11 +68,6 @@ use math::{ pub use crypto; use crypto::{ElementHasher, RandomCoin}; -#[cfg(feature = "std")] -use std::time::Instant; -#[cfg(feature = "std")] -use tracing::{event, Level}; - mod domain; pub use domain::StarkDomain; @@ -257,16 +253,16 @@ pub trait Prover { // 1 ----- Commit to the execution trace -------------------------------------------------- // build computation domain; this is used later for polynomial evaluations - #[cfg(feature = "std")] - let now = Instant::now(); - let domain = StarkDomain::new(&air); - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Built domain of 2^{} elements in {} ms", - domain.lde_domain_size().ilog2(), - now.elapsed().as_millis() - ); + let domain = + debug_span!("Building domain").in_scope(|| { + let domain = StarkDomain::new(&air); + event!( + Level::TRACE, + "Built domain of 2^{} elements", + domain.lde_domain_size().ilog2(), + ); + domain + }); // extend the main execution trace and build a Merkle tree from the extended trace let (mut trace_lde, mut trace_polys): (Self::TraceLde, TracePolyTable) = @@ -284,24 +280,23 @@ 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() { - #[cfg(feature = "std")] - let now = Instant::now(); - - // 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"); - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Built auxiliary trace segment of {} columns and 2^{} steps in {} ms", - aux_segment.num_cols(), - aux_segment.num_rows().ilog2(), - now.elapsed().as_millis() - ); + let (aux_segment, rand_elements) = debug_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::TRACE, + "Built auxiliary trace segment of {} columns and 2^{} steps", + aux_segment.num_cols(), + 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) = @@ -330,18 +325,17 @@ 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 - #[cfg(feature = "std")] - let now = Instant::now(); - 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); - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Evaluated constraints over domain of 2^{} elements in {} ms", - composition_poly_trace.num_rows().ilog2(), - now.elapsed().as_millis() - ); + let composition_poly_trace = debug_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::TRACE, + "Evaluated constraints over domain of 2^{} elements", + composition_poly_trace.num_rows().ilog2(), + ); + composition_poly_trace + }); // 3 ----- commit to constraint evaluations ----------------------------------------------- @@ -358,124 +352,111 @@ pub trait Prover { channel.commit_constraints(constraint_commitment.root()); // 4 ----- build DEEP composition polynomial ---------------------------------------------- - #[cfg(feature = "std")] - let now = Instant::now(); - - // 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. - // - // The purpose of sampling from the extension field here (instead of the base field) is to - // increase security. Soundness is limited by the size of the field that the random point - // is drawn from, and we can potentially save on performance by only drawing this point - // from an extension field, rather than increasing the size of the field overall. - let z = channel.get_ood_point(); - - // evaluate trace and constraint polynomials at the OOD point z, and send the results to - // the verifier. the trace polynomials are actually evaluated over two points: z and z * g, - // where g is the generator of the trace domain. - let ood_trace_states = trace_polys.get_ood_frame(z); - channel.send_ood_trace_states(&ood_trace_states); - - let ood_evaluations = composition_poly.evaluate_at(z); - channel.send_ood_constraint_evaluations(&ood_evaluations); - - // draw random coefficients to use during DEEP polynomial composition, and use them to - // initialize the DEEP composition polynomial - let deep_coefficients = channel.get_deep_composition_coeffs(); - let mut deep_composition_poly = DeepCompositionPoly::new(z, deep_coefficients); - - // combine all trace polynomials together and merge them into the DEEP composition - // polynomial - deep_composition_poly.add_trace_polys(trace_polys, ood_trace_states); - - // merge columns of constraint composition polynomial into the DEEP composition polynomial; - deep_composition_poly.add_composition_poly(composition_poly, ood_evaluations); - - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Built DEEP composition polynomial of degree {} in {} ms", - deep_composition_poly.degree(), - now.elapsed().as_millis() - ); + let deep_composition_poly = + debug_span!("Building DEEP composition polynomial").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. + // + // The purpose of sampling from the extension field here (instead of the base field) is to + // increase security. Soundness is limited by the size of the field that the random point + // is drawn from, and we can potentially save on performance by only drawing this point + // from an extension field, rather than increasing the size of the field overall. + let z = channel.get_ood_point(); + + // evaluate trace and constraint polynomials at the OOD point z, and send the results to + // the verifier. the trace polynomials are actually evaluated over two points: z and z * g, + // where g is the generator of the trace domain. + let ood_trace_states = trace_polys.get_ood_frame(z); + channel.send_ood_trace_states(&ood_trace_states); + + let ood_evaluations = composition_poly.evaluate_at(z); + channel.send_ood_constraint_evaluations(&ood_evaluations); + + // draw random coefficients to use during DEEP polynomial composition, and use them to + // initialize the DEEP composition polynomial + let deep_coefficients = channel.get_deep_composition_coeffs(); + let mut deep_composition_poly = DeepCompositionPoly::new(z, deep_coefficients); + + // combine all trace polynomials together and merge them into the DEEP composition + // polynomial + deep_composition_poly.add_trace_polys(trace_polys, ood_trace_states); + + // merge columns of constraint composition polynomial into the DEEP composition polynomial; + deep_composition_poly.add_composition_poly(composition_poly, ood_evaluations); + + event!( + Level::TRACE, + "Built DEEP composition polynomial of degree {}", + deep_composition_poly.degree(), + ); + deep_composition_poly + }); // make sure the degree of the DEEP composition polynomial is equal to trace polynomial // degree minus 1. assert_eq!(domain.trace_length() - 2, deep_composition_poly.degree()); // 5 ----- evaluate DEEP composition polynomial over LDE domain --------------------------- - #[cfg(feature = "std")] - let now = Instant::now(); - 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()) - ); - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Evaluated DEEP composition polynomial over LDE domain (2^{} elements) in {} ms", - domain.lde_domain_size().ilog2(), - now.elapsed().as_millis() - ); + let deep_evaluations = + debug_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::TRACE, + "Evaluated DEEP composition polynomial over LDE domain (2^{} elements)", + domain.lde_domain_size().ilog2(), + ); + deep_evaluations + }); // 6 ----- compute FRI layers for the composition polynomial ------------------------------ - #[cfg(feature = "std")] - let now = Instant::now(); - let mut fri_prover = FriProver::new(air.options().to_fri_options()); - fri_prover.build_layers(&mut channel, deep_evaluations); - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Computed {} FRI layers from composition polynomial evaluations in {} ms", - fri_prover.num_layers(), - now.elapsed().as_millis() - ); + let mut fri_prover = debug_span!( + "Computing FRI layers from composition polynomial evaluations" + ) + .in_scope(|| { + let mut fri_prover = FriProver::new(air.options().to_fri_options()); + fri_prover.build_layers(&mut channel, deep_evaluations); + event!( + Level::TRACE, + "Computed {} FRI layers from composition polynomial evaluations", + fri_prover.num_layers(), + ); + fri_prover + }); // 7 ----- determine query positions ------------------------------------------------------ - #[cfg(feature = "std")] - let now = Instant::now(); - - // apply proof-of-work to the query seed - channel.grind_query_seed(); - - // generate pseudo-random query positions - let query_positions = channel.get_query_positions(); - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Determined {} unique query positions in {} ms", - query_positions.len(), - now.elapsed().as_millis() - ); + let query_positions = debug_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::TRACE, "Determined {} unique query positions", query_positions.len(),); + query_positions + }); // 8 ----- build proof object ------------------------------------------------------------- - #[cfg(feature = "std")] - let now = Instant::now(); - - // generate FRI proof - let fri_proof = fri_prover.build_proof(&query_positions); - - // query the execution trace at the selected position; for each query, we need the - // state of the trace at that position + Merkle authentication path - let trace_queries = trace_lde.query(&query_positions); - - // query the constraint commitment at the selected positions; for each query, we need just - // a Merkle authentication path. this is because constraint evaluations for each step are - // merged into a single value and Merkle authentication paths contain these values already - let constraint_queries = constraint_commitment.query(&query_positions); - - // build the proof object - let proof = channel.build_proof( - trace_queries, - constraint_queries, - fri_proof, - query_positions.len(), - ); - #[cfg(feature = "std")] - event!(Level::DEBUG, "Built proof object in {} ms", now.elapsed().as_millis()); + let proof = debug_span!("Building proof object").in_scope(|| { + // generate FRI proof + let fri_proof = fri_prover.build_proof(&query_positions); + + // query the execution trace at the selected position; for each query, we need the + // state of the trace at that position + Merkle authentication path + let trace_queries = trace_lde.query(&query_positions); + + // query the constraint commitment at the selected positions; for each query, we need just + // a Merkle authentication path. this is because constraint evaluations for each step are + // merged into a single value and Merkle authentication paths contain these values already + let constraint_queries = constraint_commitment.query(&query_positions); + + // build the proof object + channel.build_proof(trace_queries, constraint_queries, fri_proof, query_positions.len()) + }); Ok(proof) } @@ -503,47 +484,49 @@ 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 - #[cfg(feature = "std")] - let now = Instant::now(); - let composition_poly = - CompositionPoly::new(composition_poly_trace, domain, num_trace_poly_columns); - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Converted constraint evaluations into {} composition polynomial columns of degree {} in {} ms", - composition_poly.num_columns(), - composition_poly.column_degree(), - now.elapsed().as_millis() - ); + let composition_poly = debug_span!("Converting constraint evaluations into composition polynomial columns").in_scope(|| { + let composition_poly = + CompositionPoly::new(composition_poly_trace, domain, num_trace_poly_columns); + event!( + Level::TRACE, + "Converted constraint evaluations into {} composition polynomial columns of degree {}", + composition_poly.num_columns(), + composition_poly.column_degree(), + ); + composition_poly + }); // then, evaluate composition polynomial columns over the LDE domain - #[cfg(feature = "std")] - let now = Instant::now(); - let composed_evaluations = RowMatrix::evaluate_polys_over::( - composition_poly.data(), - domain, - ); - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Evaluated {} composition polynomial columns over LDE domain (2^{} elements) in {} ms", - composed_evaluations.num_cols(), - composed_evaluations.num_rows().ilog2(), - now.elapsed().as_millis() - ); + let composed_evaluations = debug_span!( + "Evaluating composition polynomial columns over LDE domain" + ) + .in_scope(|| { + let composed_evaluations = RowMatrix::evaluate_polys_over::( + composition_poly.data(), + domain, + ); + event!( + Level::TRACE, + "Evaluated {} composition polynomial columns over LDE domain (2^{} elements)", + composed_evaluations.num_cols(), + composed_evaluations.num_rows().ilog2(), + ); + composed_evaluations + }); // finally, build constraint evaluation commitment - #[cfg(feature = "std")] - let now = Instant::now(); - let commitment = composed_evaluations.commit_to_rows(); - let constraint_commitment = ConstraintCommitment::new(composed_evaluations, commitment); - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Computed constraint evaluation commitment (Merkle tree of depth {}) in {} ms", - constraint_commitment.tree_depth(), - now.elapsed().as_millis() - ); + let constraint_commitment = debug_span!("Computing constraint evaluation commitment") + .in_scope(|| { + let commitment = composed_evaluations.commit_to_rows(); + let constraint_commitment = + ConstraintCommitment::new(composed_evaluations, commitment); + event!( + Level::TRACE, + "Computed constraint evaluation commitment (Merkle tree of 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 8017f2e8e..a0a0a8545 100644 --- a/prover/src/trace/trace_lde/default/mod.rs +++ b/prover/src/trace/trace_lde/default/mod.rs @@ -9,11 +9,7 @@ use super::{ }; use crate::{RowMatrix, DEFAULT_SEGMENT_WIDTH}; use crypto::MerkleTree; - -#[cfg(feature = "std")] -use std::time::Instant; -#[cfg(feature = "std")] -use tracing::{event, Level}; +use tracing::{debug_span, event, Level}; #[cfg(test)] mod tests; @@ -234,32 +230,31 @@ where H: ElementHasher, { // extend the execution trace - #[cfg(feature = "std")] - let now = Instant::now(); - let trace_polys = trace.interpolate_columns(); - let trace_lde = RowMatrix::evaluate_polys_over::(&trace_polys, domain); - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Extended execution trace of {} columns from 2^{} to 2^{} steps ({}x blowup) in {} ms", - trace_lde.num_cols(), - trace_polys.num_rows().ilog2(), - trace_lde.num_rows().ilog2(), - domain.trace_to_lde_blowup(), - now.elapsed().as_millis() - ); + let (trace_lde, trace_polys) = debug_span!("Extending execution trace").in_scope(|| { + let trace_polys = trace.interpolate_columns(); + let trace_lde = + RowMatrix::evaluate_polys_over::(&trace_polys, domain); + event!( + Level::TRACE, + "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(), + ); + (trace_lde, trace_polys) + }); // build trace commitment - #[cfg(feature = "std")] - let now = Instant::now(); - let trace_tree = trace_lde.commit_to_rows(); - #[cfg(feature = "std")] - event!( - Level::DEBUG, - "Computed execution trace commitment (Merkle tree of depth {}) in {} ms", - trace_tree.depth(), - now.elapsed().as_millis() - ); + let trace_tree = debug_span!("Computed execution trace commitment").in_scope(|| { + let trace_tree = trace_lde.commit_to_rows(); + event!( + Level::TRACE, + "Computed execution trace commitment (Merkle tree of depth {})", + trace_tree.depth(), + ); + trace_tree + }); (trace_lde, trace_tree, trace_polys) } diff --git a/verifier/README.md b/verifier/README.md index 107b19e0a..e129319b3 100644 --- a/verifier/README.md +++ b/verifier/README.md @@ -30,9 +30,9 @@ let min_sec = AcceptableOptions::MinConjecturedSecurity(95); let fib_result = BaseElement::new(226333832811148522147755045522163790995); match verifier::verify::>(proof, fib_result, &min_sec) { Ok(_) => event!( - Level::DEBUG,"Proof verified!"), + Level::TRACE,"Proof verified!"), Err(err) => event!( - Level::DEBUG,"Failed to verify proof: {}", err), + Level::TRACE,"Failed to verify proof: {}", err), } ``` where, `226333832811148522147755045522163790995` is the 1,048,576th term of the Fibonacci sequence when the sequence is computed in a 128-bit field with modulus 2128 - 45 * 240.