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

chore: setup tracing by default in sdk #567

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions lib/recursion/src/halo2/tests/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use crate::{

#[test]
fn test_fibonacci() {
setup_tracing();
run_recursive_test(fibonacci_test_proof_input::<BabyBearPoseidon2OuterConfig>(
16,
))
Expand All @@ -26,7 +25,6 @@ fn test_fibonacci() {
#[test]
fn test_interactions() {
// Please make sure kzg trusted params are downloaded before running the test.
setup_tracing();
run_recursive_test(interaction_test_proof_input::<BabyBearPoseidon2OuterConfig>())
}

Expand Down
14 changes: 1 addition & 13 deletions lib/recursion/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ax_sdk::{
config::{
baby_bear_poseidon2::{BabyBearPoseidon2Config, BabyBearPoseidon2Engine},
fri_params::standard_fri_params_with_100_bits_conjectured_security,
setup_tracing, FriParameters,
FriParameters,
},
dummy_airs::{
fib_air::chip::FibonacciChip,
Expand All @@ -34,8 +34,6 @@ pub fn fibonacci_test_proof_input<SC: StarkGenericConfig>(n: usize) -> ProofInpu
where
Val<SC>: PrimeField32,
{
setup_tracing();

let fib_chip = FibonacciChip::new(0, 1, n);
ProofInputForTest {
per_air: vec![fib_chip.generate_air_proof_input()],
Expand Down Expand Up @@ -137,8 +135,6 @@ where

#[test]
fn test_fibonacci_small() {
setup_tracing();

run_recursive_test(
fibonacci_test_proof_input::<BabyBearPoseidon2Config>(1 << 5),
standard_fri_params_with_100_bits_conjectured_security(3),
Expand All @@ -147,8 +143,6 @@ fn test_fibonacci_small() {

#[test]
fn test_fibonacci() {
setup_tracing();

// test lde = 27
run_recursive_test(
fibonacci_test_proof_input::<BabyBearPoseidon2Config>(1 << 24),
Expand All @@ -162,8 +156,6 @@ fn test_fibonacci() {

#[test]
fn test_interactions() {
setup_tracing();

run_recursive_test(
interaction_test_proof_input::<BabyBearPoseidon2Config>(),
standard_fri_params_with_100_bits_conjectured_security(3),
Expand All @@ -172,8 +164,6 @@ fn test_interactions() {

#[test]
fn test_unordered() {
setup_tracing();

run_recursive_test(
unordered_test_proof_input::<BabyBearPoseidon2Config>(),
standard_fri_params_with_100_bits_conjectured_security(3),
Expand All @@ -183,8 +173,6 @@ fn test_unordered() {
#[test]
fn test_optional_air() {
use afs_stark_backend::{engine::StarkEngine, prover::types::ProofInput, Chip};
setup_tracing();

let fri_params = standard_fri_params_with_100_bits_conjectured_security(3);
let engine = BabyBearPoseidon2Engine::new(fri_params);
let fib_chip = FibonacciChip::new(0, 1, 8);
Expand Down
5 changes: 1 addition & 4 deletions lib/recursion/tests/recursion.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use afs_compiler::{asm::AsmBuilder, ir::Felt};
use afs_recursion::testing_utils::inner::run_recursive_test;
use ax_sdk::{
config::{fri_params::standard_fri_params_with_100_bits_conjectured_security, setup_tracing},
config::fri_params::standard_fri_params_with_100_bits_conjectured_security,
engine::ProofInputForTest,
};
use p3_baby_bear::BabyBear;
Expand Down Expand Up @@ -71,8 +71,6 @@ where

#[test]
fn test_fibonacci_program_verify() {
setup_tracing();

let fib_program_stark = fibonacci_program_test_proof_input(0, 1, 32);
run_recursive_test(
fib_program_stark,
Expand All @@ -84,7 +82,6 @@ fn test_fibonacci_program_verify() {
#[test]
fn test_fibonacci_program_halo2_verify() {
use afs_recursion::halo2::testing_utils::run_static_verifier_test;
setup_tracing();

let fib_program_stark = fibonacci_program_test_proof_input(0, 1, 32);
run_static_verifier_test(
Expand Down
4 changes: 3 additions & 1 deletion sdk/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use afs_stark_backend::{
};
use p3_matrix::dense::DenseMatrix;
use p3_uni_stark::{Domain, StarkGenericConfig, Val};
use tracing::Level;

use crate::config::{instrument::StarkHashStatistics, FriParameters};
use crate::config::{instrument::StarkHashStatistics, setup_tracing_with_log_level, FriParameters};

pub trait StarkEngineWithHashInstrumentation<SC: StarkGenericConfig>: StarkEngine<SC> {
fn clear_instruments(&mut self);
Expand Down Expand Up @@ -65,6 +66,7 @@ where
where
AirProofInput<SC>: Send + Sync,
{
setup_tracing_with_log_level(Level::WARN);
let data = <Self as StarkEngine<_>>::run_test_impl(self, air_proof_inputs)?;
Ok(VerificationDataWithFriParams {
data,
Expand Down
3 changes: 1 addition & 2 deletions stark-backend/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use afs_stark_backend::{utils::disable_debug_builder, Chip};
/// Test utils
use ax_sdk::{
any_rap_arc_vec, config,
config::{baby_bear_poseidon2::BabyBearPoseidon2Engine, setup_tracing, FriParameters},
config::{baby_bear_poseidon2::BabyBearPoseidon2Engine, FriParameters},
dummy_airs::{
fib_air::chip::FibonacciChip,
interaction::dummy_interaction_air::{DummyInteractionChip, DummyInteractionData},
Expand Down Expand Up @@ -135,7 +135,6 @@ fn test_double_fib_starks() {
#[test]
fn test_optional_air() {
use afs_stark_backend::{engine::StarkEngine, prover::types::ProofInput};
setup_tracing();

let engine = BabyBearPoseidon2Engine::new(FriParameters::standard_fast());
let fib_chip = FibonacciChip::new(0, 1, 8);
Expand Down
6 changes: 1 addition & 5 deletions toolchain/compiler/tests/keccak256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use afs_compiler::{
ir::{Array, Var},
};
use ax_sdk::{
config::{
baby_bear_poseidon2::BabyBearPoseidon2Engine, setup_tracing_with_log_level, FriParameters,
},
config::{baby_bear_poseidon2::BabyBearPoseidon2Engine, FriParameters},
engine::StarkFriEngine,
};
use hex::FromHex;
Expand All @@ -19,7 +17,6 @@ use stark_vm::{
intrinsics::hashes::keccak::hasher::{utils::keccak256, KECCAK_DIGEST_BYTES},
system::{program::util::execute_and_prove_program, vm::config::VmConfig},
};
use tracing::Level;

type F = BabyBear;
type EF = BinomialExtensionField<BabyBear, 4>;
Expand Down Expand Up @@ -69,7 +66,6 @@ fn run_e2e_keccak_test(inputs: Vec<Vec<u8>>, expected_outputs: Vec<[u8; 32]>) {
// KAT includes inputs at the bit level; we only include the ones that are bytes
#[test]
fn test_compiler_keccak_kat_vectors() {
setup_tracing_with_log_level(Level::DEBUG);
// input, output, Len in bits
let test_vectors = vec![
("", "C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470"), // ShortMsgKAT_256 Len = 0
Expand Down
5 changes: 0 additions & 5 deletions vm/src/intrinsics/ecc/test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use afs_primitives::ecc::SampleEcPoints;
use ax_sdk::config::setup_tracing;
use p3_baby_bear::BabyBear;
use p3_field::AbstractField;

Expand All @@ -12,8 +11,6 @@ use crate::{

#[test]
fn test_ec_add() {
setup_tracing();

let mut tester: VmChipTestBuilder<BabyBear> = VmChipTestBuilder::default();

let mut ec_chip = EcAddUnequalChip::new(
Expand Down Expand Up @@ -88,8 +85,6 @@ fn test_ec_add() {

#[test]
fn test_ec_double() {
setup_tracing();

let mut tester: VmChipTestBuilder<BabyBear> = VmChipTestBuilder::default();

let mut ec_chip = EcDoubleChip::new(
Expand Down
4 changes: 1 addition & 3 deletions vm/src/intrinsics/modular_v2/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use afs_primitives::bigint::utils::{secp256k1_coord_prime, secp256k1_scalar_prime};
use ax_sdk::{config::setup_tracing, utils::create_seeded_rng};
use ax_sdk::utils::create_seeded_rng;
use num_bigint_dig::BigUint;
use p3_baby_bear::BabyBear;
use p3_field::AbstractField;
Expand All @@ -23,7 +23,6 @@ type F = BabyBear;

#[test]
fn test_modular_add() {
setup_tracing();
let coord_modulus = secp256k1_coord_prime();
let scalar_modulus = secp256k1_scalar_prime();
let mut tester: VmChipTestBuilder<F> = VmChipTestBuilder::default();
Expand Down Expand Up @@ -132,7 +131,6 @@ fn test_modular_add() {

#[test]
fn test_modular_muldiv() {
setup_tracing();
let coord_modulus = secp256k1_coord_prime();
let scalar_modulus = secp256k1_scalar_prime();
let mut tester: VmChipTestBuilder<F> = VmChipTestBuilder::default();
Expand Down
5 changes: 1 addition & 4 deletions vm/src/kernels/field_arithmetic/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use afs_stark_backend::{
prover::USE_DEBUG_BUILDER, utils::disable_debug_builder, verifier::VerificationError, Chip,
};
use ax_sdk::{
config::{baby_bear_poseidon2::BabyBearPoseidon2Engine, setup_tracing},
engine::StarkFriEngine,
config::baby_bear_poseidon2::BabyBearPoseidon2Engine, engine::StarkFriEngine,
utils::create_seeded_rng,
};
use axvm_instructions::UsizeOpcode;
Expand All @@ -30,8 +29,6 @@ use crate::{

#[test]
fn new_field_arithmetic_air_test() {
setup_tracing();

let num_ops = 3; // non-power-of-2 to also test padding
let elem_range = || 1..=100;
let z_address_space_range = || 1usize..=2;
Expand Down
4 changes: 1 addition & 3 deletions vm/src/old/modular_addsub/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use afs_primitives::bigint::utils::{secp256k1_coord_prime, secp256k1_scalar_prime};
use ax_sdk::{config::setup_tracing, utils::create_seeded_rng};
use ax_sdk::utils::create_seeded_rng;
use num_bigint_dig::BigUint;
use p3_baby_bear::BabyBear;
use p3_field::AbstractField;
Expand All @@ -21,8 +21,6 @@ type F = BabyBear;

#[test]
fn test_modular_addsub() {
setup_tracing();

let mut tester: VmChipTestBuilder<F> = VmChipTestBuilder::default();
let mut coord_chip: ModularAddSubChip<F, NUM_LIMBS, LIMB_SIZE> = ModularAddSubChip::new(
tester.execution_bus(),
Expand Down
4 changes: 1 addition & 3 deletions vm/src/old/modular_multdiv/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use afs_primitives::bigint::utils::{secp256k1_coord_prime, secp256k1_scalar_prime};
use ax_sdk::{config::setup_tracing, utils::create_seeded_rng};
use ax_sdk::utils::create_seeded_rng;
use num_bigint_dig::BigUint;
use p3_baby_bear::BabyBear;
use p3_field::AbstractField;
Expand All @@ -21,8 +21,6 @@ type F = BabyBear;

#[test]
fn test_modular_multdiv() {
setup_tracing();

let mut tester: VmChipTestBuilder<F> = VmChipTestBuilder::default();
let mut coord_chip: ModularMultDivChip<F, CARRY_LIMBS, NUM_LIMBS, LIMB_SIZE> =
ModularMultDivChip::new(
Expand Down
13 changes: 1 addition & 12 deletions vm/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use ax_sdk::{
config::{
baby_bear_poseidon2::{default_perm, engine_from_perm, random_perm},
fri_params::standard_fri_params_with_100_bits_conjectured_security,
setup_tracing_with_log_level, FriParameters,
FriParameters,
},
engine::StarkEngine,
utils::create_seeded_rng,
Expand All @@ -27,7 +27,6 @@ use stark_vm::{
},
},
};
use tracing::Level;

const LIMB_BITS: usize = 29;

Expand Down Expand Up @@ -112,8 +111,6 @@ fn air_test_with_compress_poseidon2(

#[test]
fn test_vm_1() {
setup_tracing_with_log_level(Level::TRACE);

let n = 6;
/*
Instruction 0 assigns word[0]_1 to n.
Expand Down Expand Up @@ -143,8 +140,6 @@ fn test_vm_1() {

#[test]
fn test_vm_1_persistent() {
setup_tracing_with_log_level(Level::TRACE);

let n = 6;
let instructions = vec![
Instruction::from_isize(STOREW.with_default_offset(), n, 0, 0, 0, 1),
Expand Down Expand Up @@ -282,8 +277,6 @@ fn test_vm_fibonacci_old_cycle_tracker() {

#[test]
fn test_vm_field_extension_arithmetic() {
setup_tracing_with_log_level(Level::DEBUG);

let instructions = vec![
Instruction::from_isize(STOREW.with_default_offset(), 1, 0, 0, 0, 1),
Instruction::from_isize(STOREW.with_default_offset(), 2, 1, 0, 0, 1),
Expand Down Expand Up @@ -314,8 +307,6 @@ fn test_vm_field_extension_arithmetic() {

#[test]
fn test_vm_field_extension_arithmetic_persistent() {
setup_tracing_with_log_level(Level::DEBUG);

let instructions = vec![
Instruction::from_isize(STOREW.with_default_offset(), 1, 0, 0, 0, 1),
Instruction::from_isize(STOREW.with_default_offset(), 2, 1, 0, 0, 1),
Expand Down Expand Up @@ -559,7 +550,6 @@ fn instructions_for_keccak256_test(input: &[u8]) -> Vec<Instruction<BabyBear>> {

#[test]
fn test_vm_keccak() {
setup_tracing_with_log_level(Level::TRACE);
let inputs = [
vec![],
(0u8..1).collect::<Vec<_>>(),
Expand Down Expand Up @@ -592,7 +582,6 @@ fn test_vm_keccak() {
// This test dones one keccak in 24 rows, and then there are 8 dummy padding rows which don't make up a full round
#[test]
fn test_vm_keccak_non_full_round() {
setup_tracing_with_log_level(Level::TRACE);
let inputs = [[[0u8; 32], [1u8; 32]].concat()];
let mut instructions = inputs
.iter()
Expand Down