Skip to content

Commit

Permalink
fix: rm optional bool flags (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-camuto authored Feb 21, 2024
1 parent 74feb82 commit bf69b16
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
10 changes: 6 additions & 4 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ pub const DEFAULT_VK_ABI: &str = "vk.abi";
pub const DEFAULT_SCALE_REBASE_MULTIPLIERS: &str = "1,2,10";
/// Default use reduced srs for verification
pub const DEFAULT_USE_REDUCED_SRS_FOR_VERIFICATION: &str = "false";
/// Default only check for range check rebase
pub const DEFAULT_ONLY_RANGE_CHECK_REBASE: &str = "false";

#[cfg(feature = "python-bindings")]
/// Converts TranscriptType into a PyObject (Required for TranscriptType to be compatible with Python)
Expand Down Expand Up @@ -371,9 +373,9 @@ pub enum Commands {
/// max logrows to use for calibration, 26 is the max public SRS size
#[arg(long)]
max_logrows: Option<u32>,
// whether to fix the div_rebasing value truthiness during calibration. this changes how we rebase
#[arg(long)]
div_rebasing: Option<bool>,
// whether to only range check rebases (instead of trying both range check and lookup)
#[arg(long, default_value = DEFAULT_ONLY_RANGE_CHECK_REBASE)]
only_range_check_rebase: bool,
},

/// Generates a dummy SRS
Expand Down Expand Up @@ -732,7 +734,7 @@ pub enum Commands {
srs_path: Option<PathBuf>,
/// Reduce SRS logrows to the number of instances rather than the number of logrows used for proofs (only works if the srs were generated in the same ceremony)
#[arg(long, default_value = DEFAULT_USE_REDUCED_SRS_FOR_VERIFICATION)]
reduced_srs: Option<bool>,
reduced_srs: bool,
},
/// Verifies an aggregate proof, returning accept or reject
VerifyAggr {
Expand Down
20 changes: 8 additions & 12 deletions src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub async fn run(command: Commands) -> Result<String, Box<dyn Error>> {
scales,
scale_rebase_multiplier,
max_logrows,
div_rebasing,
only_range_check_rebase,
} => calibrate(
model,
data,
Expand All @@ -187,7 +187,7 @@ pub async fn run(command: Commands) -> Result<String, Box<dyn Error>> {
lookup_safety_margin,
scales,
scale_rebase_multiplier,
div_rebasing,
only_range_check_rebase,
max_logrows,
)
.map(|e| serde_json::to_string(&e).unwrap()),
Expand Down Expand Up @@ -789,7 +789,7 @@ pub(crate) fn calibrate(
lookup_safety_margin: i128,
scales: Option<Vec<crate::Scale>>,
scale_rebase_multiplier: Vec<u32>,
div_rebasing: Option<bool>,
only_range_check_rebase: bool,
max_logrows: Option<u32>,
) -> Result<GraphSettings, Box<dyn Error>> {
use std::collections::HashMap;
Expand Down Expand Up @@ -830,8 +830,8 @@ pub(crate) fn calibrate(
(10..14).collect::<Vec<crate::Scale>>()
};

let div_rebasing = if let Some(div_rebasing) = div_rebasing {
vec![div_rebasing]
let div_rebasing = if only_range_check_rebase {
vec![false]
} else {
vec![true, false]
};
Expand Down Expand Up @@ -2044,16 +2044,12 @@ pub(crate) fn verify(
settings_path: PathBuf,
vk_path: PathBuf,
srs_path: Option<PathBuf>,
reduced_srs: Option<bool>,
reduced_srs: bool,
) -> Result<bool, Box<dyn Error>> {
let circuit_settings = GraphSettings::load(&settings_path)?;

let params = if let Some(reduced_srs) = reduced_srs {
if reduced_srs {
load_params_cmd(srs_path, circuit_settings.log2_total_instances())?
} else {
load_params_cmd(srs_path, circuit_settings.run_args.logrows)?
}
let params = if reduced_srs {
load_params_cmd(srs_path, circuit_settings.log2_total_instances())?
} else {
load_params_cmd(srs_path, circuit_settings.run_args.logrows)?
};
Expand Down
10 changes: 5 additions & 5 deletions src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ fn gen_settings(
scales = None,
scale_rebase_multiplier = DEFAULT_SCALE_REBASE_MULTIPLIERS.split(",").map(|x| x.parse().unwrap()).collect(),
max_logrows = None,
div_rebasing = None,
only_range_check_rebase = DEFAULT_ONLY_RANGE_CHECK_REBASE.parse().unwrap(),
))]
fn calibrate_settings(
data: PathBuf,
Expand All @@ -534,7 +534,7 @@ fn calibrate_settings(
scales: Option<Vec<crate::Scale>>,
scale_rebase_multiplier: Vec<u32>,
max_logrows: Option<u32>,
div_rebasing: Option<bool>,
only_range_check_rebase: bool,
) -> Result<bool, PyErr> {
crate::execute::calibrate(
model,
Expand All @@ -544,7 +544,7 @@ fn calibrate_settings(
lookup_safety_margin,
scales,
scale_rebase_multiplier,
div_rebasing,
only_range_check_rebase,
max_logrows,
)
.map_err(|e| {
Expand Down Expand Up @@ -687,14 +687,14 @@ fn prove(
settings_path=PathBuf::from(DEFAULT_SETTINGS),
vk_path=PathBuf::from(DEFAULT_VK),
srs_path=None,
non_reduced_srs=Some(DEFAULT_USE_REDUCED_SRS_FOR_VERIFICATION.parse::<bool>().unwrap()),
non_reduced_srs=DEFAULT_USE_REDUCED_SRS_FOR_VERIFICATION.parse::<bool>().unwrap(),
))]
fn verify(
proof_path: PathBuf,
settings_path: PathBuf,
vk_path: PathBuf,
srs_path: Option<PathBuf>,
non_reduced_srs: Option<bool>,
non_reduced_srs: bool,
) -> Result<bool, PyErr> {
crate::execute::verify(
proof_path,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,7 @@ mod native_tests {
&format!("{}/{}/proof.pf", test_dir, example_name),
"--vk-path",
&format!("{}/{}/key.vk", test_dir, example_name),
"--reduced-srs=true",
"--reduced-srs",
])
.status()
.expect("failed to execute process");
Expand Down

0 comments on commit bf69b16

Please sign in to comment.