Browse Source

Add logging

main
Piotr Mikołajczyk 6 months ago
parent
commit
58beac6257
No known key found for this signature in database GPG Key ID: 7ADA31326DE28EC7
4 changed files with 114 additions and 9 deletions
  1. +78
    -5
      Cargo.lock
  2. +4
    -1
      Cargo.toml
  3. +24
    -0
      src/logging.rs
  4. +8
    -3
      src/main.rs

+ 78
- 5
Cargo.lock

@ -2516,7 +2516,7 @@ dependencies = [
"petgraph",
"pico-args",
"regex",
"regex-syntax",
"regex-syntax 0.8.4",
"string_cache",
"term",
"tiny-keccak",
@ -2530,7 +2530,7 @@ version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553"
dependencies = [
"regex-automata",
"regex-automata 0.4.7",
]
[[package]]
@ -2647,6 +2647,15 @@ dependencies = [
"libc",
]
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata 0.1.10",
]
[[package]]
name = "memchr"
version = "2.7.4"
@ -2966,6 +2975,16 @@ dependencies = [
"toml 0.8.19",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "num"
version = "0.4.0"
@ -3180,6 +3199,12 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "owo-colors"
version = "3.5.0"
@ -3333,6 +3358,8 @@ dependencies = [
"itertools 0.13.0",
"num-traits",
"rand 0.8.5",
"tracing",
"tracing-subscriber 0.3.18",
]
[[package]]
@ -3655,8 +3682,17 @@ checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
"regex-automata 0.4.7",
"regex-syntax 0.8.4",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax 0.6.29",
]
[[package]]
@ -3667,9 +3703,15 @@ checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"regex-syntax 0.8.4",
]
[[package]]
name = "regex-syntax"
version = "0.6.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
version = "0.8.4"
@ -4771,6 +4813,27 @@ dependencies = [
"tracing-subscriber 0.3.18",
]
[[package]]
name = "tracing-log"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
dependencies = [
"log",
"once_cell",
"tracing-core",
]
[[package]]
name = "tracing-serde"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1"
dependencies = [
"serde",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.2.25"
@ -4786,9 +4849,19 @@ version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
"regex",
"serde",
"serde_json",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
"tracing-serde",
]
[[package]]

+ 4
- 1
Cargo.toml

@ -11,9 +11,12 @@ ark-grumpkin = { version = "0.4.0", features = ["r1cs"] }
ark-groth16 = { version = "0.4.0", features = ["parallel"] }
ark-serialize = { version = "0.4.0" }
itertools = { version = "0.13.0" }
num-traits = { version = "0.2.15" }
rand = { version = "0.8.5" }
tracing = { version = "0.1.26" }
tracing-subscriber = { version = "0.3.18", features = ["fmt", "json", "env-filter"] }
sonobe = { git = "https://github.com/privacy-scaling-explorations/sonobe", rev = "f1d82418ba047cf90805f2d0505370246df24d68", package = "folding-schemes" }
num-traits = { version = "0.2.15" }
[patch.crates-io]
ark-r1cs-std = { git = "https://github.com/winderica/r1cs-std", branch = "cherry-pick" }

+ 24
- 0
src/logging.rs

@ -0,0 +1,24 @@
use std::io;
use tracing::level_filters::LevelFilter;
use tracing_subscriber::{EnvFilter, fmt::format::FmtSpan};
fn get_filter() -> EnvFilter {
EnvFilter::builder()
.with_default_directive(LevelFilter::WARN.into())
.from_env_lossy()
.add_directive("playground=info".parse().unwrap())
}
pub fn init_logging() {
tracing_subscriber::fmt()
.with_writer(io::stdout)
.with_target(false)
.without_time()
.with_env_filter(get_filter())
.with_span_events(FmtSpan::ENTER | FmtSpan::CLOSE)
.with_level(false)
.json()
.try_init()
.expect("Failed to initialize logging");
}

+ 8
- 3
src/main.rs

@ -1,12 +1,15 @@
use std::time::Instant;
use scenario_config::ScenarioConfig;
use tracing::info;
use crate::folding::{
prepare_folding, verify_folding, FoldingSchemeExt, HyperNovaFolding, NovaFolding,
use crate::{
folding::{prepare_folding, verify_folding, FoldingSchemeExt, HyperNovaFolding, NovaFolding},
logging::init_logging,
};
mod circuit;
mod logging;
mod folding;
mod input;
@ -15,7 +18,7 @@ mod scenario_config;
fn measure<T, Action: FnOnce() -> T>(action_name: &str, action: Action) -> T {
let start = Instant::now();
let result = action();
println!("{action_name}: {:?}", start.elapsed());
info!("{action_name}: {:?}", start.elapsed());
result
}
@ -57,6 +60,8 @@ fn scenario(config: ScenarioConfig, rng: &mut impl rand::R
}
fn main() {
init_logging();
let mut rng = rand::rngs::OsRng;
let config = ScenarioConfig::new();

Loading…
Cancel
Save