Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Tracing logger #241

Merged
merged 7 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ doc = false
[features]
concurrent = ["winterfell/concurrent", "std"]
default = ["std"]
std = ["hex/std", "winterfell/std", "core-utils/std", "rand-utils"]
std = ["core-utils/std", "hex/std", "rand-utils", "winterfell/std"]

[dependencies]
winterfell = { version="0.7", path = "../winterfell", default-features = false }
blake3 = { version = "1.5", default-features = false }
core-utils = { version = "0.7", path = "../utils/core", package = "winter-utils", default-features = false }
rand-utils = { version = "0.7", path = "../utils/rand", package = "winter-rand-utils", optional = true }
hex = { version = "0.4", optional = true }
log = { version = "0.4", default-features = false }
blake3 = { version = "1.5", default-features = false }
env_logger = { version = "0.10", default-features = false }
rand-utils = { version = "0.7", path = "../utils/rand", package = "winter-rand-utils", optional = true }
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]
criterion = "0.5"
Expand Down
32 changes: 16 additions & 16 deletions examples/src/fibonacci/fib2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use super::utils::compute_fib_term;
use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_256};
use core::marker::PhantomData;
use log::debug;
use std::time::Instant;
use tracing::{event, info_span, Level};
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, FieldElement},
Expand Down Expand Up @@ -65,7 +65,7 @@ impl<H: ElementHasher> FibExample<H> {
// compute Fibonacci sequence
let now = Instant::now();
let result = compute_fib_term(sequence_length);
debug!(
println!(
"Computed Fibonacci sequence up to {}th term in {} ms",
sequence_length,
now.elapsed().as_millis()
Expand All @@ -88,27 +88,27 @@ where
H: ElementHasher<BaseField = BaseElement>,
{
fn prove(&self) -> StarkProof {
debug!(
"Generating proof for computing Fibonacci sequence (2 terms per step) up to {}th term\n\
---------------------",
println!(
"Generating proof for computing Fibonacci sequence (2 terms per step) up to {}th term",
self.sequence_length
);

// create a prover
let prover = FibProver::<H>::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();
debug!(
"Generated execution trace of {} registers and 2^{} steps in {} ms",
trace_width,
trace_length.ilog2(),
now.elapsed().as_millis()
);
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()
Expand Down
31 changes: 16 additions & 15 deletions examples/src/fibonacci/fib8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use super::utils::compute_fib_term;
use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_256};
use core::marker::PhantomData;
use log::debug;
use std::time::Instant;
use tracing::{event, info_span, Level};
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, FieldElement},
Expand Down Expand Up @@ -65,7 +65,7 @@ impl<H: ElementHasher> Fib8Example<H> {
// compute Fibonacci sequence
let now = Instant::now();
let result = compute_fib_term(sequence_length);
debug!(
println!(
"Computed Fibonacci sequence up to {}th term in {} ms",
sequence_length,
now.elapsed().as_millis()
Expand All @@ -88,26 +88,27 @@ where
H: ElementHasher<BaseField = BaseElement>,
{
fn prove(&self) -> StarkProof {
debug!(
"Generating proof for computing Fibonacci sequence (8 terms per step) up to {}th term\n\
---------------------",
println!(
"Generating proof for computing Fibonacci sequence (8 terms per step) up to {}th term",
self.sequence_length
);

// create a prover
let prover = Fib8Prover::<H>::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();
debug!(
"Generated execution trace of {} registers and 2^{} steps in {} ms",
trace_width,
trace_length.ilog2(),
now.elapsed().as_millis()
);
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()
Expand Down
32 changes: 16 additions & 16 deletions examples/src/fibonacci/fib_small/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use super::utils::compute_fib_term;
use crate::{Example, ExampleOptions, HashFunction};
use core::marker::PhantomData;
use log::debug;
use std::time::Instant;
use tracing::{event, info_span, Level};
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f64::BaseElement, FieldElement},
Expand Down Expand Up @@ -80,7 +80,7 @@ impl<H: ElementHasher> FibExample<H> {
// compute Fibonacci sequence
let now = Instant::now();
let result = compute_fib_term::<BaseElement>(sequence_length);
debug!(
println!(
"Computed Fibonacci sequence up to {}th term in {} ms",
sequence_length,
now.elapsed().as_millis()
Expand All @@ -103,27 +103,27 @@ where
H: ElementHasher<BaseField = BaseElement>,
{
fn prove(&self) -> StarkProof {
debug!(
"Generating proof for computing Fibonacci sequence (2 terms per step) up to {}th term\n\
---------------------",
println!(
"Generating proof for computing Fibonacci sequence (2 terms per step) up to {}th term",
self.sequence_length
);

// create a prover
let prover = FibSmallProver::<H>::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();
debug!(
"Generated execution trace of {} registers and 2^{} steps in {} ms",
trace_width,
trace_length.ilog2(),
now.elapsed().as_millis()
);
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()
Expand Down
31 changes: 16 additions & 15 deletions examples/src/fibonacci/mulfib2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use super::utils::compute_mulfib_term;
use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_256};
use core::marker::PhantomData;
use log::debug;
use std::time::Instant;
use tracing::{event, info_span, Level};
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, FieldElement},
Expand Down Expand Up @@ -59,7 +59,7 @@ impl<H: ElementHasher> MulFib2Example<H> {
// compute Fibonacci sequence
let now = Instant::now();
let result = compute_mulfib_term(sequence_length);
debug!(
println!(
"Computed multiplicative Fibonacci sequence up to {}th term in {} ms",
sequence_length,
now.elapsed().as_millis()
Expand All @@ -83,26 +83,27 @@ where
{
fn prove(&self) -> StarkProof {
let sequence_length = self.sequence_length;
debug!(
"Generating proof for computing multiplicative Fibonacci sequence (8 terms per step) up to {}th term\n\
---------------------",
println!(
"Generating proof for computing multiplicative Fibonacci sequence (2 terms per step) up to {}th term",
sequence_length
);

// create a prover
let prover = MulFib2Prover::<H>::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();
debug!(
"Generated execution trace of {} registers and 2^{} steps in {} ms",
trace_width,
trace_length.ilog2(),
now.elapsed().as_millis()
);
let trace = info_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::DEBUG,
"Generated execution trace of {} registers and 2^{} steps",
trace_width,
trace_length.ilog2(),
);
trace
});

// generate the proof
prover.prove(trace).unwrap()
Expand Down
31 changes: 16 additions & 15 deletions examples/src/fibonacci/mulfib8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use super::utils::compute_mulfib_term;
use crate::{Blake3_192, Blake3_256, Example, ExampleOptions, HashFunction, Sha3_256};
use core::marker::PhantomData;
use log::debug;
use std::time::Instant;
use tracing::{event, info_span, Level};
use winterfell::{
crypto::{DefaultRandomCoin, ElementHasher},
math::{fields::f128::BaseElement, FieldElement},
Expand Down Expand Up @@ -60,7 +60,7 @@ impl<H: ElementHasher> MulFib8Example<H> {
// compute Fibonacci sequence
let now = Instant::now();
let result = compute_mulfib_term(sequence_length);
debug!(
println!(
"Computed multiplicative Fibonacci sequence up to {}th term in {} ms",
sequence_length,
now.elapsed().as_millis()
Expand All @@ -84,26 +84,27 @@ where
{
fn prove(&self) -> StarkProof {
let sequence_length = self.sequence_length;
debug!(
"Generating proof for computing multiplicative Fibonacci sequence (2 terms per step) up to {}th term\n\
---------------------",
println!(
"Generating proof for computing multiplicative Fibonacci sequence (8 terms per step) up to {}th term",
sequence_length
);

// create a prover
let prover = MulFib8Prover::<H>::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();
debug!(
"Generated execution trace of {} registers and 2^{} steps in {} ms",
trace_width,
trace_length.ilog2(),
now.elapsed().as_millis()
);
let trace = info_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::DEBUG,
"Generated execution trace of {} registers and 2^{} steps",
trace_width,
trace_length.ilog2(),
);
trace
});

// generate the proof
prover.prove(trace).unwrap()
Expand Down
Loading
Loading