From bf69b16fc1ee01d219e44dd1bc7bf7919f6337c3 Mon Sep 17 00:00:00 2001 From: dante <45801863+alexander-camuto@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:45:42 +0000 Subject: [PATCH] fix: rm optional bool flags (#722) --- src/commands.rs | 10 ++++++---- src/execute.rs | 20 ++++++++------------ src/python.rs | 10 +++++----- tests/integration_tests.rs | 2 +- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 6c2415ed6..298ffade4 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -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) @@ -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, - // whether to fix the div_rebasing value truthiness during calibration. this changes how we rebase - #[arg(long)] - div_rebasing: Option, + // 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 @@ -732,7 +734,7 @@ pub enum Commands { srs_path: Option, /// 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, + reduced_srs: bool, }, /// Verifies an aggregate proof, returning accept or reject VerifyAggr { diff --git a/src/execute.rs b/src/execute.rs index 4fdc8989f..b3dbcf3fb 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -178,7 +178,7 @@ pub async fn run(command: Commands) -> Result> { scales, scale_rebase_multiplier, max_logrows, - div_rebasing, + only_range_check_rebase, } => calibrate( model, data, @@ -187,7 +187,7 @@ pub async fn run(command: Commands) -> Result> { lookup_safety_margin, scales, scale_rebase_multiplier, - div_rebasing, + only_range_check_rebase, max_logrows, ) .map(|e| serde_json::to_string(&e).unwrap()), @@ -789,7 +789,7 @@ pub(crate) fn calibrate( lookup_safety_margin: i128, scales: Option>, scale_rebase_multiplier: Vec, - div_rebasing: Option, + only_range_check_rebase: bool, max_logrows: Option, ) -> Result> { use std::collections::HashMap; @@ -830,8 +830,8 @@ pub(crate) fn calibrate( (10..14).collect::>() }; - 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] }; @@ -2044,16 +2044,12 @@ pub(crate) fn verify( settings_path: PathBuf, vk_path: PathBuf, srs_path: Option, - reduced_srs: Option, + reduced_srs: bool, ) -> Result> { 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)? }; diff --git a/src/python.rs b/src/python.rs index 4b92a6433..b517b3fae 100644 --- a/src/python.rs +++ b/src/python.rs @@ -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, @@ -534,7 +534,7 @@ fn calibrate_settings( scales: Option>, scale_rebase_multiplier: Vec, max_logrows: Option, - div_rebasing: Option, + only_range_check_rebase: bool, ) -> Result { crate::execute::calibrate( model, @@ -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| { @@ -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::().unwrap()), + non_reduced_srs=DEFAULT_USE_REDUCED_SRS_FOR_VERIFICATION.parse::().unwrap(), ))] fn verify( proof_path: PathBuf, settings_path: PathBuf, vk_path: PathBuf, srs_path: Option, - non_reduced_srs: Option, + non_reduced_srs: bool, ) -> Result { crate::execute::verify( proof_path, diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 403b989c7..3ac43301b 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -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");