Skip to content

Commit

Permalink
Cargo build working
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerTaule committed Jan 7, 2025
1 parent 6878d03 commit 78f4c48
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 73 deletions.
19 changes: 0 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ members = [
"util",
"pil2-components/lib/std/rs",
# "pil2-components/test/std/direct_update/rs",
"pil2-components/test/std/diff_buses/rs",
# "pil2-components/test/std/diff_buses/rs",
# "pil2-components/test/std/range_check/rs",
# "pil2-components/test/std/lookup/rs",
# "pil2-components/test/std/connection/rs",
Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ impl ProveCmd {

let debug_info = if let Some(debug_value) = &self.debug {
if debug_value.is_empty() || debug_value == "false" {
DebugInfo::new()
DebugInfo::default()
} else {
json_to_debug_instances_map(debug_value.clone())
}
} else {
DebugInfo::new()
DebugInfo::default()
};

match self.field {
Expand Down
12 changes: 3 additions & 9 deletions cli/src/commands/verify_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ impl VerifyConstraintsCmd {

let debug_info = if let Some(debug_value) = &self.debug {
if debug_value.is_empty() || debug_value == "false" {
DebugInfo::new()
DebugInfo::default()
} else {
json_to_debug_instances_map(debug_value.clone())
}
} else {
DebugInfo::new()
DebugInfo::default()
};

match self.field {
Expand All @@ -67,13 +67,7 @@ impl VerifyConstraintsCmd {
self.public_inputs.clone(),
self.proving_key.clone(),
PathBuf::new(),
ProofOptions::new(
true,
self.verbose.into(),
false,
false,
debug_info
),
ProofOptions::new(true, self.verbose.into(), false, false, debug_info),
)?,
};

Expand Down
14 changes: 2 additions & 12 deletions common/src/proof_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::PathBuf;

use p3_field::Field;

use crate::{ModeName, distribution_ctx::DistributionCtx, AirInstancesRepository, GlobalInfo, StdMode, VerboseMode};
use crate::{distribution_ctx::DistributionCtx, AirInstancesRepository, GlobalInfo, StdMode, VerboseMode};

pub struct Values<F> {
pub values: RwLock<Vec<F>>,
Expand Down Expand Up @@ -34,23 +34,13 @@ pub struct ProofOptions {
pub debug_info: DebugInfo,
}

#[derive(Clone)]
#[derive(Default, Clone)]
pub struct DebugInfo {
pub debug_instances: AirGroupMap,
pub debug_global_instances: Vec<usize>,
pub std_mode: StdMode,
}

impl DebugInfo {
pub fn new() -> Self {
Self {
std_mode: StdMode::new(ModeName::Standard, Vec::new(), 0, false),
debug_instances: HashMap::new(),
debug_global_instances: Vec::new(),
}
}
}

impl ProofOptions {
pub fn new(
verify_constraints: bool,
Expand Down
2 changes: 1 addition & 1 deletion pil2-components/lib/std/rs/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub trait AirComponent<F> {
fn new(pctx: Arc<ProofCtx<F>>, sctx: Arc<SetupCtx>, airgroup_id: Option<usize>, air_id: Option<usize>)
-> Arc<Self>;

fn debug(
fn debug_mode(
&self,
_pctx: &ProofCtx<F>,
_sctx: &SetupCtx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl<F: PrimeField> StdRangeCheck<F> {
let range_item = range_item.unwrap();
let range = range_item.range;

if self.pctx.options.std_mode.name == ModeName::Debug && !range.contains(value) {
if self.pctx.options.debug_info.std_mode.name == ModeName::Debug && !range.contains(value) {
log::error!("Value {} is not in the range [min,max] = {}", value, range);
panic!();
}
Expand Down
14 changes: 7 additions & 7 deletions pil2-components/lib/std/rs/src/std_prod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ impl<F: PrimeField> AirComponent<F> for StdProd<F> {
Some(Mutex::new(stage_wc))
}
},
debug_data: if pctx.options.std_mode.name == ModeName::Debug {
debug_data: if pctx.options.debug_info.std_mode.name == ModeName::Debug {
Some(Mutex::new(HashMap::new()))
} else {
None
},
})
}

fn debug(
fn debug_mode(
&self,
pctx: &ProofCtx<F>,
sctx: &SetupCtx,
Expand Down Expand Up @@ -276,8 +276,8 @@ impl<F: PrimeField> WitnessComponent<F> for StdProd<F> {
let debug_data_hints = get_hint_ids_by_name(p_expressions_bin, "gprod_debug_data");

// Debugging, if enabled
if pctx.options.std_mode.name == ModeName::Debug {
self.debug(&pctx, &sctx, air_instance, num_rows, debug_data_hints.clone());
if pctx.options.debug_info.std_mode.name == ModeName::Debug {
self.debug_mode(&pctx, &sctx, air_instance, num_rows, debug_data_hints.clone());
}

// We know that at most one product hint exists
Expand Down Expand Up @@ -324,11 +324,11 @@ impl<F: PrimeField> WitnessComponent<F> for StdProd<F> {

fn end_proof(&self) {
// Print debug info if in debug mode
if self.pctx.options.std_mode.name == ModeName::Debug {
if self.pctx.options.debug_info.std_mode.name == ModeName::Debug {
let pctx = &self.pctx;
let name = Self::MY_NAME;
let max_values_to_print = pctx.options.std_mode.n_vals;
let print_to_file = pctx.options.std_mode.print_to_file;
let max_values_to_print = pctx.options.debug_info.std_mode.n_vals;
let print_to_file = pctx.options.debug_info.std_mode.print_to_file;
let debug_data = self.debug_data.as_ref().expect("Debug data missing");
print_debug_info(pctx, name, max_values_to_print, print_to_file, debug_data);
}
Expand Down
16 changes: 9 additions & 7 deletions pil2-components/lib/std/rs/src/std_sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ impl<F: PrimeField> AirComponent<F> for StdSum<F> {
Some(Mutex::new(stage_wc))
}
},
debug_data: if pctx.options.std_mode.name == ModeName::Debug {
debug_data: if pctx.options.debug_info.std_mode.name == ModeName::Debug {
Some(Mutex::new(HashMap::new()))
} else {
None
},
})
}

fn debug(
fn debug_mode(
&self,
pctx: &ProofCtx<F>,
sctx: &SetupCtx,
Expand Down Expand Up @@ -144,6 +144,7 @@ impl<F: PrimeField> AirComponent<F> for StdSum<F> {
// If opids are specified, then only update the bus if the opid is in the list
if !pctx
.options
.debug_info
.std_mode
.opids
.contains(&opid.as_canonical_biguint().to_u64().expect("Cannot convert to u64"))
Expand Down Expand Up @@ -179,6 +180,7 @@ impl<F: PrimeField> AirComponent<F> for StdSum<F> {
// If opids are specified, then only update the bus if the opid is in the list
if !pctx
.options
.debug_info
.std_mode
.opids
.contains(&opid.as_canonical_biguint().to_u64().expect("Cannot convert to u64"))
Expand Down Expand Up @@ -307,8 +309,8 @@ impl<F: PrimeField> WitnessComponent<F> for StdSum<F> {
let debug_data_hints = get_hint_ids_by_name(p_expressions_bin, "gsum_debug_data");

// Debugging, if enabled
if pctx.options.std_mode.name == ModeName::Debug {
self.debug(&pctx, &sctx, air_instance, num_rows, debug_data_hints.clone());
if pctx.options.debug_info.std_mode.name == ModeName::Debug {
self.debug_mode(&pctx, &sctx, air_instance, num_rows, debug_data_hints.clone());
}

// Populate the im columns
Expand Down Expand Up @@ -370,11 +372,11 @@ impl<F: PrimeField> WitnessComponent<F> for StdSum<F> {

fn end_proof(&self) {
// Print debug info if in debug mode
if self.pctx.options.std_mode.name == ModeName::Debug {
if self.pctx.options.debug_info.std_mode.name == ModeName::Debug {
let pctx = &self.pctx;
let name = Self::MY_NAME;
let max_values_to_print = pctx.options.std_mode.n_vals;
let print_to_file = pctx.options.std_mode.print_to_file;
let max_values_to_print = pctx.options.debug_info.std_mode.n_vals;
let print_to_file = pctx.options.debug_info.std_mode.print_to_file;
let debug_data = self.debug_data.as_ref().expect("Debug data missing");
print_debug_info(pctx, name, max_values_to_print, print_to_file, debug_data);
}
Expand Down
2 changes: 1 addition & 1 deletion pil2-components/test/simple/rs/src/simple_left.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use witness::WitnessComponent;
use proofman_common::{add_air_instance, FromTrace, AirInstance, ProofCtx};

use p3_field::PrimeField;
use p3_field::PrimeField64;
use rand::{distributions::Standard, prelude::Distribution, seq::SliceRandom, Rng};

use crate::SimpleLeftTrace;
Expand Down
4 changes: 1 addition & 3 deletions pil2-components/test/std/diff_buses/rs/src/both_buses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use crate::BothBusesTrace;

pub struct BothBuses;

impl BothBuses
{
impl BothBuses {
const MY_NAME: &'static str = "BothBus ";

pub fn new() -> Arc<Self> {
Expand All @@ -29,7 +28,6 @@ where
let mut trace = BothBusesTrace::new();
let num_rows = trace.num_rows();


log::debug!("{}: ··· Starting witness computation stage {}", Self::MY_NAME, 1);

for i in 0..num_rows {
Expand Down
3 changes: 1 addition & 2 deletions pil2-components/test/std/diff_buses/rs/src/diff_buses_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use p3_field::PrimeField;
use p3_goldilocks::Goldilocks;
use rand::{distributions::Standard, prelude::Distribution};


use crate::{ProdBus, BothBuses, SumBus};

witness_library!(WitnessLib, Goldilocks);
Expand All @@ -26,4 +25,4 @@ where
wcm.register_component(sum_bus.clone());
wcm.register_component(both_buses.clone());
}
}
}
4 changes: 1 addition & 3 deletions pil2-components/test/std/diff_buses/rs/src/prod_bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use crate::ProdBusTrace;

pub struct ProdBus;

impl ProdBus
{
impl ProdBus {
const MY_NAME: &'static str = "ProdBus ";

pub fn new() -> Arc<Self> {
Expand All @@ -29,7 +28,6 @@ where
let mut trace = ProdBusTrace::new();
let num_rows = trace.num_rows();


log::debug!("{}: ··· Starting witness computation stage {}", Self::MY_NAME, 1);

for i in 0..num_rows {
Expand Down
8 changes: 3 additions & 5 deletions pil2-components/test/std/diff_buses/rs/src/sum_bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@ use crate::SumBusTrace;

pub struct SumBus;

impl SumBus
{
impl SumBus {
const MY_NAME: &'static str = "SumBus ";

pub fn new() -> Arc<Self> {
Arc::new(Self)
}
}

impl<F: PrimeField> WitnessComponent<F> for SumBus
{
impl<F: PrimeField> WitnessComponent<F> for SumBus {
fn execute(&self, pctx: Arc<ProofCtx<F>>) {
let mut trace = SumBusTrace::new();
let num_rows = trace.num_rows();

log::debug!("{}: ··· Starting witness computation stage {}", Self::MY_NAME, 1);

for i in 0..num_rows {
Expand Down

0 comments on commit 78f4c48

Please sign in to comment.