From ed183bdcf77c9383280524b4339cb1071804470d Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Fri, 24 Feb 2023 17:40:20 +0000 Subject: [PATCH 1/3] chore: restrict CliError visibility to crate --- crates/nargo/src/cli/compile_cmd.rs | 2 +- crates/nargo/src/cli/fs/inputs.rs | 4 ++-- crates/nargo/src/cli/fs/mod.rs | 2 +- crates/nargo/src/cli/gates_cmd.rs | 2 +- crates/nargo/src/cli/prove_cmd.rs | 2 +- crates/nargo/src/errors.rs | 2 +- crates/nargo/src/resolver.rs | 2 +- crates/nargo/src/toml.rs | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/nargo/src/cli/compile_cmd.rs b/crates/nargo/src/cli/compile_cmd.rs index 70b9d22f73b..a5d85129313 100644 --- a/crates/nargo/src/cli/compile_cmd.rs +++ b/crates/nargo/src/cli/compile_cmd.rs @@ -50,7 +50,7 @@ fn compile_and_preprocess_circuit>( Ok(circuit_path) } -pub fn compile_circuit>( +pub(crate) fn compile_circuit>( program_dir: P, show_ssa: bool, allow_warnings: bool, diff --git a/crates/nargo/src/cli/fs/inputs.rs b/crates/nargo/src/cli/fs/inputs.rs index 5df9d9bc7eb..fc1f661eaee 100644 --- a/crates/nargo/src/cli/fs/inputs.rs +++ b/crates/nargo/src/cli/fs/inputs.rs @@ -15,7 +15,7 @@ use super::write_to_file; /// let (input_map, return_value): (InputMap, Option) = /// read_inputs_from_file(path, "Verifier", Format::Toml, &abi)?; /// ``` -pub fn read_inputs_from_file>( +pub(crate) fn read_inputs_from_file>( path: P, file_name: &str, format: Format, @@ -42,7 +42,7 @@ pub fn read_inputs_from_file>( Ok((input_map, return_value)) } -pub fn write_inputs_to_file>( +pub(crate) fn write_inputs_to_file>( input_map: &InputMap, return_value: &Option, path: P, diff --git a/crates/nargo/src/cli/fs/mod.rs b/crates/nargo/src/cli/fs/mod.rs index 91bd7e88b77..a8c7e96388c 100644 --- a/crates/nargo/src/cli/fs/mod.rs +++ b/crates/nargo/src/cli/fs/mod.rs @@ -37,7 +37,7 @@ pub(crate) fn write_to_file(bytes: &[u8], path: &Path) -> String { } } -pub fn load_hex_data>(path: P) -> Result, CliError> { +pub(crate) fn load_hex_data>(path: P) -> Result, CliError> { let hex_data: Vec<_> = std::fs::read(&path).map_err(|_| CliError::PathNotValid(path.as_ref().to_path_buf()))?; diff --git a/crates/nargo/src/cli/gates_cmd.rs b/crates/nargo/src/cli/gates_cmd.rs index bae5dd22953..dd4a951731c 100644 --- a/crates/nargo/src/cli/gates_cmd.rs +++ b/crates/nargo/src/cli/gates_cmd.rs @@ -23,7 +23,7 @@ pub(crate) fn run(args: GatesCommand, config: NargoConfig) -> Result<(), CliErro count_gates_with_path(config.program_dir, args.show_ssa, args.allow_warnings) } -pub fn count_gates_with_path>( +fn count_gates_with_path>( program_dir: P, show_ssa: bool, allow_warnings: bool, diff --git a/crates/nargo/src/cli/prove_cmd.rs b/crates/nargo/src/cli/prove_cmd.rs index e71185fa732..c3969af9b12 100644 --- a/crates/nargo/src/cli/prove_cmd.rs +++ b/crates/nargo/src/cli/prove_cmd.rs @@ -64,7 +64,7 @@ pub(crate) fn run(args: ProveCommand, config: NargoConfig) -> Result<(), CliErro Ok(()) } -pub fn prove_with_path>( +pub(crate) fn prove_with_path>( proof_name: Option, program_dir: P, proof_dir: P, diff --git a/crates/nargo/src/errors.rs b/crates/nargo/src/errors.rs index 09de29e558d..1baced25da0 100644 --- a/crates/nargo/src/errors.rs +++ b/crates/nargo/src/errors.rs @@ -6,7 +6,7 @@ use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use thiserror::Error; #[derive(Debug, Error)] -pub enum CliError { +pub(crate) enum CliError { #[error("{0}")] Generic(String), #[error("Error: destination {} already exists", .0.display())] diff --git a/crates/nargo/src/resolver.rs b/crates/nargo/src/resolver.rs index f1b34aa9bac..3f21f698fd7 100644 --- a/crates/nargo/src/resolver.rs +++ b/crates/nargo/src/resolver.rs @@ -35,7 +35,7 @@ struct CachedDep { /// or it uses the repo on the cache. /// Downloading will be recursive, so if a package contains packages /// We need to download those too -pub struct Resolver<'a> { +pub(crate) struct Resolver<'a> { cached_packages: HashMap, driver: &'a mut Driver, } diff --git a/crates/nargo/src/toml.rs b/crates/nargo/src/toml.rs index 4c9ab210f66..04df9dd0c39 100644 --- a/crates/nargo/src/toml.rs +++ b/crates/nargo/src/toml.rs @@ -51,7 +51,7 @@ pub enum Dependency { /// Parses a Nargo.toml file from it's path /// The path to the toml file must be present. /// Calling this function without this guarantee is an ICE. -pub fn parse>(path_to_toml: P) -> Result { +pub(crate) fn parse>(path_to_toml: P) -> Result { let toml_as_string = std::fs::read_to_string(&path_to_toml).expect("ice: path given for toml file is invalid"); From ab1874444420505c8b5e552e0942ca50fbfef4ce Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Fri, 24 Feb 2023 18:00:48 +0000 Subject: [PATCH 2/3] chore!: remove check_from_path from crate's interface. --- crates/nargo/src/cli/check_cmd.rs | 2 +- crates/nargo/src/cli/mod.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/nargo/src/cli/check_cmd.rs b/crates/nargo/src/cli/check_cmd.rs index fd37a841952..61aa17d7db7 100644 --- a/crates/nargo/src/cli/check_cmd.rs +++ b/crates/nargo/src/cli/check_cmd.rs @@ -26,7 +26,7 @@ pub(crate) fn run(args: CheckCommand, config: NargoConfig) -> Result<(), CliErro Ok(()) } // This is exposed so that we can run the examples and verify that they pass -pub fn check_from_path>(p: P, allow_warnings: bool) -> Result<(), CliError> { +fn check_from_path>(p: P, allow_warnings: bool) -> Result<(), CliError> { let backend = crate::backends::ConcreteBackend; let mut driver = Resolver::resolve_root_config(p.as_ref(), backend.np_language())?; diff --git a/crates/nargo/src/cli/mod.rs b/crates/nargo/src/cli/mod.rs index b0b778ad226..1f4901a692d 100644 --- a/crates/nargo/src/cli/mod.rs +++ b/crates/nargo/src/cli/mod.rs @@ -1,4 +1,3 @@ -pub use check_cmd::check_from_path; use clap::{Args, Parser, Subcommand}; use const_format::formatcp; use noirc_abi::InputMap; From 80e6507859aff1d7aa5281289d9286d5f40cf958 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Fri, 24 Feb 2023 19:12:15 +0000 Subject: [PATCH 3/3] chore: clippy --- crates/nargo/src/errors.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/nargo/src/errors.rs b/crates/nargo/src/errors.rs index 1baced25da0..004d3621874 100644 --- a/crates/nargo/src/errors.rs +++ b/crates/nargo/src/errors.rs @@ -19,10 +19,6 @@ pub(crate) enum CliError { " Error: cannot find {0}.toml file.\n Expected location: {1:?} \n Please generate this file at the expected location." )] MissingTomlFile(String, PathBuf), - #[error("Error: cannot find proving key located at {}\nEither run `nargo compile` to generate the missing proving key or check that the correct file name has been provided", .0.display())] - MissingProvingKey(PathBuf), - #[error("Error: cannot find verification key located at {}\nEither run `nargo compile` to generate the missing verification key or check that the correct file name has been provided", .0.display())] - MissingVerificationkey(PathBuf), #[error("Error: the circuit you are trying to prove differs from the build artifact at {}\nYou must call `nargo compile` to generate the correct proving and verification keys for this circuit", .0.display())] MismatchedAcir(PathBuf), #[error("Failed to verify proof {}", .0.display())]