From 607685122b6837e9d193269badffd401b584999b Mon Sep 17 00:00:00 2001 From: howardwu Date: Sun, 28 Jun 2020 18:24:36 -0700 Subject: [PATCH 1/4] Update logger, add debug flag, improve CLI messages, add num_constraints --- compiler/src/compiler.rs | 2 +- examples/pedersen_hash/src/main.leo | 4 +- examples/test/.gitignore | 1 + examples/test/Leo.toml | 3 ++ examples/test/inputs/test.in | 4 ++ examples/test/src/main.leo | 5 +++ leo/cli.rs | 15 ++++++- leo/commands/build.rs | 6 ++- leo/commands/setup.rs | 15 +++++-- leo/files/checksum.rs | 2 - leo/files/proving_key.rs | 2 - leo/files/verification_key.rs | 2 - leo/logger.rs | 20 +--------- leo/main.rs | 61 ++++++++++++----------------- 14 files changed, 75 insertions(+), 67 deletions(-) create mode 100644 examples/test/.gitignore create mode 100644 examples/test/Leo.toml create mode 100644 examples/test/inputs/test.in create mode 100644 examples/test/src/main.leo diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index 4b5ea8be63..312ab9c3cf 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -127,7 +127,7 @@ impl> ConstraintSynthesizer for Compil })?; // Write results to file or something - log::info!("{}", result); + // log::info!("{}", result); Ok(()) } diff --git a/examples/pedersen_hash/src/main.leo b/examples/pedersen_hash/src/main.leo index ce7b714716..5b417f604f 100644 --- a/examples/pedersen_hash/src/main.leo +++ b/examples/pedersen_hash/src/main.leo @@ -15,8 +15,8 @@ circuit PedersenHash { // The 'pedersen_hash' main function. function main() -> u32 { - let parameters = [0u32; 512]; - let pedersen = PedersenHash::new(parameters); + const parameters = [0u32; 512]; + const pedersen = PedersenHash::new(parameters); let input: bool[512] = [true; 512]; return pedersen.hash(input) } diff --git a/examples/test/.gitignore b/examples/test/.gitignore new file mode 100644 index 0000000000..17aa483ab4 --- /dev/null +++ b/examples/test/.gitignore @@ -0,0 +1 @@ +outputs/ diff --git a/examples/test/Leo.toml b/examples/test/Leo.toml new file mode 100644 index 0000000000..f18a42ff37 --- /dev/null +++ b/examples/test/Leo.toml @@ -0,0 +1,3 @@ +[package] +name = "test" +version = "0.1.0" diff --git a/examples/test/inputs/test.in b/examples/test/inputs/test.in new file mode 100644 index 0000000000..9f7c94c12f --- /dev/null +++ b/examples/test/inputs/test.in @@ -0,0 +1,4 @@ +// The program inputs for test/src/main.leo +[main] +a: u32 = 1; +b: u32 = 2; diff --git a/examples/test/src/main.leo b/examples/test/src/main.leo new file mode 100644 index 0000000000..f5d7f2b03c --- /dev/null +++ b/examples/test/src/main.leo @@ -0,0 +1,5 @@ +// The 'test' main function. +function main(a: u32, b: u32) -> u32 { + let c: u32 = a + b; + return c +} diff --git a/leo/cli.rs b/leo/cli.rs index 2e321ec02a..ac49bfbf75 100644 --- a/leo/cli.rs +++ b/leo/cli.rs @@ -1,4 +1,4 @@ -use crate::{cli_types::*, errors::CLIError}; +use crate::{cli_types::*, errors::CLIError, logger}; use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; @@ -66,6 +66,19 @@ pub trait CLI { .subcommands(subcommands) } + #[cfg_attr(tarpaulin, skip)] + fn process(arguments: &ArgMatches) -> Result<(), CLIError> { + // Set logging environment + match arguments.is_present("debug") { + true => logger::init_logger("leo", 2), + false => logger::init_logger("leo", 1), + } + + let options = Self::parse(arguments)?; + let _output = Self::output(options)?; + Ok(()) + } + #[cfg_attr(tarpaulin, skip)] fn parse(arguments: &ArgMatches) -> Result; diff --git a/leo/commands/build.rs b/leo/commands/build.rs index 6011e13f57..2e78600a85 100644 --- a/leo/commands/build.rs +++ b/leo/commands/build.rs @@ -9,6 +9,7 @@ use leo_compiler::{compiler::Compiler, group::edwards_bls12::EdwardsGroupType}; use snarkos_algorithms::snark::KeypairAssembly; use snarkos_curves::{bls12_377::Bls12_377, edwards_bls12::Fq}; +use snarkos_models::gadgets::r1cs::ConstraintSystem; use clap::ArgMatches; use std::{convert::TryFrom, env::current_dir}; @@ -76,6 +77,7 @@ impl CLI for BuildCommand { let temporary_program = program.clone(); let output = temporary_program.compile_constraints(&mut cs)?; log::debug!("Compiled constraints - {:#?}", output); + log::debug!("Number of constraints - {:#?}", cs.num_constraints()); } // If a checksum file exists, check if it differs from the new checksum @@ -92,9 +94,11 @@ impl CLI for BuildCommand { if checksum_differs { // Write the new checksum to the outputs directory checksum_file.write_to(&path, program_checksum)?; + + log::info!("Checksum saved ({:?})", path); } - log::info!("Compiled program in {:?}", main_file_path); + log::info!("Compiled program ({:?})", main_file_path); Ok((program, checksum_differs)) } diff --git a/leo/commands/setup.rs b/leo/commands/setup.rs index 8cd115bc3e..072d18c870 100644 --- a/leo/commands/setup.rs +++ b/leo/commands/setup.rs @@ -52,6 +52,8 @@ impl CLI for SetupCommand { // If keys do not exist or the checksum differs, run the program setup if !keys_exist || checksum_differs { + log::info!("Setup starting..."); + // Start the timer let start = Instant::now(); @@ -61,18 +63,25 @@ impl CLI for SetupCommand { let prepared_verifying_key = prepare_verifying_key::(¶meters.vk); // End the timer - log::info!("Setup completed in {:?} milliseconds", start.elapsed().as_millis()); + let end = start.elapsed().as_millis(); // TODO (howardwu): Convert parameters to a 'proving key' struct for serialization. // Write the proving key file to the outputs directory let mut proving_key = vec![]; parameters.write(&mut proving_key)?; ProvingKeyFile::new(&package_name).write_to(&path, &proving_key)?; + log::info!("Saving proving key ({:?})", path); - // Write the proving key file to the outputs directory + // Write the verification key file to the outputs directory let mut verification_key = vec![]; prepared_verifying_key.write(&mut verification_key)?; VerificationKeyFile::new(&package_name).write_to(&path, &verification_key)?; + log::info!("Saving verification key ({:?})", path); + + // Output the setup time + log::info!("Setup completed in {:?} milliseconds", end); + } else { + log::info!("Setup complete"); } // Read the proving key file from the outputs directory @@ -98,7 +107,7 @@ impl CLI for SetupCommand { } } - log::info!("Completed program setup"); + log::info!("Program setup complete"); Ok((program, parameters, prepared_verifying_key)) } diff --git a/leo/files/checksum.rs b/leo/files/checksum.rs index b71c227808..d06ab14abc 100644 --- a/leo/files/checksum.rs +++ b/leo/files/checksum.rs @@ -42,8 +42,6 @@ impl ChecksumFile { let mut file = File::create(&path)?; file.write_all(checksum.as_bytes())?; - log::info!("Checksum stored to {:?}", path); - Ok(()) } diff --git a/leo/files/proving_key.rs b/leo/files/proving_key.rs index 49b42ba037..082eedd51f 100644 --- a/leo/files/proving_key.rs +++ b/leo/files/proving_key.rs @@ -42,8 +42,6 @@ impl ProvingKeyFile { let mut file = File::create(&path)?; file.write_all(proving_key)?; - log::info!("Proving key stored to {:?}", path); - Ok(()) } diff --git a/leo/files/verification_key.rs b/leo/files/verification_key.rs index 07071c8b18..a74328c82b 100644 --- a/leo/files/verification_key.rs +++ b/leo/files/verification_key.rs @@ -42,8 +42,6 @@ impl VerificationKeyFile { let mut file = File::create(&path)?; file.write_all(verification_key)?; - log::info!("Verification key stored to {:?}", path); - Ok(()) } diff --git a/leo/logger.rs b/leo/logger.rs index e4c12234f7..98c48c34d7 100644 --- a/leo/logger.rs +++ b/leo/logger.rs @@ -3,33 +3,18 @@ use std::io::Write; const LEVEL_NAME_LENGTH: usize = 10; -#[allow(dead_code)] -fn level_string(level: log::Level) -> colored::ColoredString { - match level { - log::Level::Error => "ERROR".bold().red(), - log::Level::Warn => "WARN".bold().yellow(), - log::Level::Info => "INFO".bold().blue(), - log::Level::Debug => "DEBUG".bold().magenta(), - log::Level::Trace => "TRACE".bold(), - } -} - #[allow(dead_code)] fn colored_string(level: log::Level, message: &str) -> colored::ColoredString { match level { log::Level::Error => message.bold().red(), log::Level::Warn => message.bold().yellow(), - log::Level::Info => message.bold().blue(), + log::Level::Info => message.bold().cyan(), log::Level::Debug => message.bold().magenta(), log::Level::Trace => message.bold(), } } /// Initialize logger with custom format and verbosity. -/// -/// # Arguments -/// -/// * `verbosity` - Verbosity level. 0 for `Warn`, 1 for `Info`, 2 for `Debug`, more for `Trace` pub fn init_logger(app_name: &'static str, verbosity: usize) { env_logger::builder() .filter_level(match verbosity { @@ -46,8 +31,7 @@ pub fn init_logger(app_name: &'static str, verbosity: usize) { writeln!( buf, - "{:>5}{:>5} {}", - level_string(record.level()), + "{:>5} {}", colored_string(record.level(), app_name), record.args().to_string().replace("\n", &padding) ) diff --git a/leo/main.rs b/leo/main.rs index 6b542b3f41..b6c14f883a 100644 --- a/leo/main.rs +++ b/leo/main.rs @@ -1,11 +1,9 @@ -use leo::{cli::*, commands::*, errors::CLIError, logger}; +use leo::{cli::*, commands::*, errors::CLIError}; -use clap::{App, AppSettings}; +use clap::{App, AppSettings, Arg}; #[cfg_attr(tarpaulin, skip)] fn main() -> Result<(), CLIError> { - logger::init_logger("leo", 1); - let arguments = App::new("leo") .version("v0.1.0") .about("Leo compiler and package manager") @@ -16,46 +14,39 @@ fn main() -> Result<(), CLIError> { AppSettings::DisableVersion, AppSettings::SubcommandRequiredElseHelp, ]) + .args(&[Arg::with_name("debug") + .short("d") + .long("debug") + .help("Enables debugging mode") + .global(true)]) .subcommands(vec![ NewCommand::new().display_order(0), InitCommand::new().display_order(1), BuildCommand::new().display_order(2), - LoadCommand::new().display_order(3), - UnloadCommand::new().display_order(4), - SetupCommand::new().display_order(5), - ProveCommand::new().display_order(6), - RunCommand::new().display_order(7), - PublishCommand::new().display_order(8), - DeployCommand::new().display_order(9), - TestCommand::new().display_order(10), + TestCommand::new().display_order(3), + LoadCommand::new().display_order(4), + UnloadCommand::new().display_order(5), + SetupCommand::new().display_order(6), + ProveCommand::new().display_order(7), + RunCommand::new().display_order(8), + PublishCommand::new().display_order(9), + DeployCommand::new().display_order(10), ]) .set_term_width(0) .get_matches(); match arguments.subcommand() { - ("new", Some(arguments)) => NewCommand::output(NewCommand::parse(arguments)?), - ("init", Some(arguments)) => InitCommand::output(InitCommand::parse(arguments)?), - ("build", Some(arguments)) => { - BuildCommand::output(BuildCommand::parse(arguments)?)?; - Ok(()) - } - ("load", Some(arguments)) => LoadCommand::output(LoadCommand::parse(arguments)?), - ("unload", Some(arguments)) => UnloadCommand::output(UnloadCommand::parse(arguments)?), - ("setup", Some(arguments)) => { - SetupCommand::output(SetupCommand::parse(arguments)?)?; - Ok(()) - } - ("prove", Some(arguments)) => { - ProveCommand::output(ProveCommand::parse(arguments)?)?; - Ok(()) - } - ("run", Some(arguments)) => RunCommand::output(RunCommand::parse(arguments)?), - ("publish", Some(arguments)) => PublishCommand::output(PublishCommand::parse(arguments)?), - ("deploy", Some(arguments)) => DeployCommand::output(DeployCommand::parse(arguments)?), - ("test", Some(arguments)) => { - TestCommand::output(TestCommand::parse(arguments)?)?; - Ok(()) - } + ("new", Some(arguments)) => NewCommand::process(arguments), + ("init", Some(arguments)) => InitCommand::process(arguments), + ("build", Some(arguments)) => BuildCommand::process(arguments), + ("test", Some(arguments)) => TestCommand::process(arguments), + ("load", Some(arguments)) => LoadCommand::process(arguments), + ("unload", Some(arguments)) => UnloadCommand::process(arguments), + ("setup", Some(arguments)) => SetupCommand::process(arguments), + ("prove", Some(arguments)) => ProveCommand::process(arguments), + ("run", Some(arguments)) => RunCommand::process(arguments), + ("publish", Some(arguments)) => PublishCommand::process(arguments), + ("deploy", Some(arguments)) => DeployCommand::process(arguments), _ => unreachable!(), } } From c1243a2e74c609755e1e0e1e2e3454af35b1395b Mon Sep 17 00:00:00 2001 From: howardwu Date: Sun, 28 Jun 2020 18:53:09 -0700 Subject: [PATCH 2/4] Adds the command --- compiler/src/compiler.rs | 2 +- leo/commands/clean.rs | 53 ++++++++++++++++++++++++++++ leo/commands/mod.rs | 3 ++ leo/errors/files/checksum.rs | 3 ++ leo/errors/files/proof.rs | 3 ++ leo/errors/files/proving_key.rs | 3 ++ leo/errors/files/verification_key.rs | 3 ++ leo/files/checksum.rs | 12 +++++++ leo/files/proof.rs | 12 +++++++ leo/files/proving_key.rs | 12 +++++++ leo/files/verification_key.rs | 12 +++++++ leo/main.rs | 2 ++ 12 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 leo/commands/clean.rs diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index 312ab9c3cf..4b5ea8be63 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -127,7 +127,7 @@ impl> ConstraintSynthesizer for Compil })?; // Write results to file or something - // log::info!("{}", result); + log::info!("{}", result); Ok(()) } diff --git a/leo/commands/clean.rs b/leo/commands/clean.rs new file mode 100644 index 0000000000..cd0f620a6c --- /dev/null +++ b/leo/commands/clean.rs @@ -0,0 +1,53 @@ +use crate::{ + cli::*, + cli_types::*, + commands::BuildCommand, + errors::CLIError, + files::{ChecksumFile, Manifest, ProofFile, ProvingKeyFile, VerificationKeyFile}, +}; + +use clap::ArgMatches; +use std::{convert::TryFrom, env::current_dir}; + +#[derive(Debug)] +pub struct CleanCommand; + +impl CLI for CleanCommand { + type Options = (); + type Output = (); + + const ABOUT: AboutType = "Clean the outputs directory"; + const ARGUMENTS: &'static [ArgumentType] = &[]; + const FLAGS: &'static [FlagType] = &[]; + const NAME: NameType = "clean"; + const OPTIONS: &'static [OptionType] = &[]; + const SUBCOMMANDS: &'static [SubCommandType] = &[]; + + #[cfg_attr(tarpaulin, skip)] + fn parse(_arguments: &ArgMatches) -> Result { + Ok(()) + } + + #[cfg_attr(tarpaulin, skip)] + fn output(options: Self::Options) -> Result { + let (_program, _checksum_differs) = BuildCommand::output(options)?; + + // Get the package name + let path = current_dir()?; + let package_name = Manifest::try_from(&path)?.get_package_name(); + + // Remove the checksum from the outputs directory + ChecksumFile::new(&package_name).remove(&path)?; + + // Remove the proving key from the outputs directory + ProvingKeyFile::new(&package_name).remove(&path)?; + + // Remove the verification key from the outputs directory + VerificationKeyFile::new(&package_name).remove(&path)?; + + // Remove the proof from the outputs directory + ProofFile::new(&package_name).remove(&path)?; + + Ok(()) + } +} diff --git a/leo/commands/mod.rs b/leo/commands/mod.rs index 14bc6c664d..152ebb158a 100644 --- a/leo/commands/mod.rs +++ b/leo/commands/mod.rs @@ -1,6 +1,9 @@ pub mod build; pub use self::build::*; +pub mod clean; +pub use self::clean::*; + pub mod deploy; pub use self::deploy::*; diff --git a/leo/errors/files/checksum.rs b/leo/errors/files/checksum.rs index 4fed871e41..65fe78c9e6 100644 --- a/leo/errors/files/checksum.rs +++ b/leo/errors/files/checksum.rs @@ -11,6 +11,9 @@ pub enum ChecksumFileError { #[error("Cannot read from the provided file path - {:?}", _0)] FileReadError(PathBuf), + #[error("Cannot remove the provided file - {:?}", _0)] + FileRemovalError(PathBuf), + #[error("writing: {}", _0)] Writing(io::Error), } diff --git a/leo/errors/files/proof.rs b/leo/errors/files/proof.rs index fe7785cc5a..e0e8b1b022 100644 --- a/leo/errors/files/proof.rs +++ b/leo/errors/files/proof.rs @@ -11,6 +11,9 @@ pub enum ProofFileError { #[error("Cannot read from the provided file path - {:?}", _0)] FileReadError(PathBuf), + #[error("Cannot remove the provided file - {:?}", _0)] + FileRemovalError(PathBuf), + #[error("writing: {}", _0)] Writing(io::Error), } diff --git a/leo/errors/files/proving_key.rs b/leo/errors/files/proving_key.rs index e24bfc6fa8..ef9481551a 100644 --- a/leo/errors/files/proving_key.rs +++ b/leo/errors/files/proving_key.rs @@ -11,6 +11,9 @@ pub enum ProvingKeyFileError { #[error("Cannot read from the provided file path - {:?}", _0)] FileReadError(PathBuf), + #[error("Cannot remove the provided file - {:?}", _0)] + FileRemovalError(PathBuf), + #[error("writing: {}", _0)] Writing(io::Error), } diff --git a/leo/errors/files/verification_key.rs b/leo/errors/files/verification_key.rs index 1003af52ab..ffa3d34a61 100644 --- a/leo/errors/files/verification_key.rs +++ b/leo/errors/files/verification_key.rs @@ -11,6 +11,9 @@ pub enum VerificationKeyFileError { #[error("Cannot read from the provided file path - {:?}", _0)] FileReadError(PathBuf), + #[error("Cannot remove the provided file - {:?}", _0)] + FileRemovalError(PathBuf), + #[error("Verification key file was corrupted")] IncorrectVerificationKey, diff --git a/leo/files/checksum.rs b/leo/files/checksum.rs index d06ab14abc..a8d9053021 100644 --- a/leo/files/checksum.rs +++ b/leo/files/checksum.rs @@ -45,6 +45,18 @@ impl ChecksumFile { Ok(()) } + /// Removes the checksum at the given path if it exists. Returns `true` on success, + /// `false` if the file doesn't exist, and `Error` if the file system fails during operation. + pub fn remove(&self, path: &PathBuf) -> Result { + let path = self.setup_file_path(path); + if !path.exists() { + return Ok(false); + } + + fs::remove_file(&path).map_err(|_| ChecksumFileError::FileRemovalError(path.clone()))?; + Ok(true) + } + fn setup_file_path(&self, path: &PathBuf) -> PathBuf { let mut path = path.to_owned(); if path.is_dir() { diff --git a/leo/files/proof.rs b/leo/files/proof.rs index 0e6fa5578e..75e4f22680 100644 --- a/leo/files/proof.rs +++ b/leo/files/proof.rs @@ -48,6 +48,18 @@ impl ProofFile { Ok(()) } + /// Removes the proof at the given path if it exists. Returns `true` on success, + /// `false` if the file doesn't exist, and `Error` if the file system fails during operation. + pub fn remove(&self, path: &PathBuf) -> Result { + let path = self.setup_file_path(path); + if !path.exists() { + return Ok(false); + } + + fs::remove_file(&path).map_err(|_| ProofFileError::FileRemovalError(path.clone()))?; + Ok(true) + } + fn setup_file_path(&self, path: &PathBuf) -> PathBuf { let mut path = path.to_owned(); if path.is_dir() { diff --git a/leo/files/proving_key.rs b/leo/files/proving_key.rs index 082eedd51f..4c62a5cea9 100644 --- a/leo/files/proving_key.rs +++ b/leo/files/proving_key.rs @@ -45,6 +45,18 @@ impl ProvingKeyFile { Ok(()) } + /// Removes the proving key at the given path if it exists. Returns `true` on success, + /// `false` if the file doesn't exist, and `Error` if the file system fails during operation. + pub fn remove(&self, path: &PathBuf) -> Result { + let path = self.setup_file_path(path); + if !path.exists() { + return Ok(false); + } + + fs::remove_file(&path).map_err(|_| ProvingKeyFileError::FileRemovalError(path.clone()))?; + Ok(true) + } + fn setup_file_path(&self, path: &PathBuf) -> PathBuf { let mut path = path.to_owned(); if path.is_dir() { diff --git a/leo/files/verification_key.rs b/leo/files/verification_key.rs index a74328c82b..6087e2d999 100644 --- a/leo/files/verification_key.rs +++ b/leo/files/verification_key.rs @@ -45,6 +45,18 @@ impl VerificationKeyFile { Ok(()) } + /// Removes the verification key at the given path if it exists. Returns `true` on success, + /// `false` if the file doesn't exist, and `Error` if the file system fails during operation. + pub fn remove(&self, path: &PathBuf) -> Result { + let path = self.setup_file_path(path); + if !path.exists() { + return Ok(false); + } + + fs::remove_file(&path).map_err(|_| VerificationKeyFileError::FileRemovalError(path.clone()))?; + Ok(true) + } + fn setup_file_path(&self, path: &PathBuf) -> PathBuf { let mut path = path.to_owned(); if path.is_dir() { diff --git a/leo/main.rs b/leo/main.rs index b6c14f883a..f11932b0b4 100644 --- a/leo/main.rs +++ b/leo/main.rs @@ -31,6 +31,7 @@ fn main() -> Result<(), CLIError> { RunCommand::new().display_order(8), PublishCommand::new().display_order(9), DeployCommand::new().display_order(10), + CleanCommand::new().display_order(11), ]) .set_term_width(0) .get_matches(); @@ -47,6 +48,7 @@ fn main() -> Result<(), CLIError> { ("run", Some(arguments)) => RunCommand::process(arguments), ("publish", Some(arguments)) => PublishCommand::process(arguments), ("deploy", Some(arguments)) => DeployCommand::process(arguments), + ("clean", Some(arguments)) => CleanCommand::process(arguments), _ => unreachable!(), } } From a262622f605c43e2841bc8bf11753ca9fe2fae8c Mon Sep 17 00:00:00 2001 From: howardwu Date: Sun, 28 Jun 2020 18:53:40 -0700 Subject: [PATCH 3/4] Remove the test folder --- examples/test/.gitignore | 1 - examples/test/Leo.toml | 3 --- examples/test/inputs/test.in | 4 ---- examples/test/src/main.leo | 5 ----- 4 files changed, 13 deletions(-) delete mode 100644 examples/test/.gitignore delete mode 100644 examples/test/Leo.toml delete mode 100644 examples/test/inputs/test.in delete mode 100644 examples/test/src/main.leo diff --git a/examples/test/.gitignore b/examples/test/.gitignore deleted file mode 100644 index 17aa483ab4..0000000000 --- a/examples/test/.gitignore +++ /dev/null @@ -1 +0,0 @@ -outputs/ diff --git a/examples/test/Leo.toml b/examples/test/Leo.toml deleted file mode 100644 index f18a42ff37..0000000000 --- a/examples/test/Leo.toml +++ /dev/null @@ -1,3 +0,0 @@ -[package] -name = "test" -version = "0.1.0" diff --git a/examples/test/inputs/test.in b/examples/test/inputs/test.in deleted file mode 100644 index 9f7c94c12f..0000000000 --- a/examples/test/inputs/test.in +++ /dev/null @@ -1,4 +0,0 @@ -// The program inputs for test/src/main.leo -[main] -a: u32 = 1; -b: u32 = 2; diff --git a/examples/test/src/main.leo b/examples/test/src/main.leo deleted file mode 100644 index f5d7f2b03c..0000000000 --- a/examples/test/src/main.leo +++ /dev/null @@ -1,5 +0,0 @@ -// The 'test' main function. -function main(a: u32, b: u32) -> u32 { - let c: u32 = a + b; - return c -} From c622b157f59417f9b26effa7697cd07a948f770a Mon Sep 17 00:00:00 2001 From: howardwu Date: Sun, 28 Jun 2020 19:36:45 -0700 Subject: [PATCH 4/4] Cleanup --- compiler/src/constraints/mod.rs | 1 - leo/commands/build.rs | 4 +++- leo/commands/clean.rs | 5 +---- leo/commands/load.rs | 2 +- leo/commands/prove.rs | 2 ++ leo/commands/unload.rs | 2 +- leo/files/proof.rs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/src/constraints/mod.rs b/compiler/src/constraints/mod.rs index 2045087aff..42a3ce22f4 100644 --- a/compiler/src/constraints/mod.rs +++ b/compiler/src/constraints/mod.rs @@ -53,7 +53,6 @@ pub fn generate_constraints, CS: Constrai match main.clone() { ConstrainedValue::Function(_circuit_identifier, function) => { let result = resolved_program.enforce_main_function(cs, program_name, function, parameters)?; - log::debug!("{}", result); Ok(result) } _ => Err(CompilerError::NoMainFunction), diff --git a/leo/commands/build.rs b/leo/commands/build.rs index 2e78600a85..4bd745c4d7 100644 --- a/leo/commands/build.rs +++ b/leo/commands/build.rs @@ -52,6 +52,8 @@ impl CLI for BuildCommand { return Err(BuildError::MainFileDoesNotExist(package_path.as_os_str().to_owned()).into()); } + log::info!("Compiling..."); + // Create the outputs directory OutputsDirectory::create(&package_path)?; @@ -95,7 +97,7 @@ impl CLI for BuildCommand { // Write the new checksum to the outputs directory checksum_file.write_to(&path, program_checksum)?; - log::info!("Checksum saved ({:?})", path); + log::debug!("Checksum saved ({:?})", path); } log::info!("Compiled program ({:?})", main_file_path); diff --git a/leo/commands/clean.rs b/leo/commands/clean.rs index cd0f620a6c..3c41690019 100644 --- a/leo/commands/clean.rs +++ b/leo/commands/clean.rs @@ -1,7 +1,6 @@ use crate::{ cli::*, cli_types::*, - commands::BuildCommand, errors::CLIError, files::{ChecksumFile, Manifest, ProofFile, ProvingKeyFile, VerificationKeyFile}, }; @@ -29,9 +28,7 @@ impl CLI for CleanCommand { } #[cfg_attr(tarpaulin, skip)] - fn output(options: Self::Options) -> Result { - let (_program, _checksum_differs) = BuildCommand::output(options)?; - + fn output(_options: Self::Options) -> Result { // Get the package name let path = current_dir()?; let package_name = Manifest::try_from(&path)?.get_package_name(); diff --git a/leo/commands/load.rs b/leo/commands/load.rs index 8cef939d0b..8129b98179 100644 --- a/leo/commands/load.rs +++ b/leo/commands/load.rs @@ -30,7 +30,7 @@ impl CLI for LoadCommand { let path = current_dir()?; let _package_name = Manifest::try_from(&path)?.get_package_name(); - log::info!("Unimplemented - `leo deploy`"); + log::info!("Unimplemented - `leo load`"); Ok(()) } diff --git a/leo/commands/prove.rs b/leo/commands/prove.rs index 14d66e450b..9fd9993e22 100644 --- a/leo/commands/prove.rs +++ b/leo/commands/prove.rs @@ -40,6 +40,8 @@ impl CLI for ProveCommand { let path = current_dir()?; let package_name = Manifest::try_from(&path)?.get_package_name(); + log::info!("Proving..."); + // Fetch program inputs here let inputs_string = InputsFile::new(&package_name).read_from(&path)?; program.parse_inputs(&inputs_string)?; diff --git a/leo/commands/unload.rs b/leo/commands/unload.rs index 52fe84b2b0..614506fe55 100644 --- a/leo/commands/unload.rs +++ b/leo/commands/unload.rs @@ -30,7 +30,7 @@ impl CLI for UnloadCommand { let path = current_dir()?; let _package_name = Manifest::try_from(&path)?.get_package_name(); - log::info!("Unimplemented - `leo deploy`"); + log::info!("Unimplemented - `leo unload`"); Ok(()) } diff --git a/leo/files/proof.rs b/leo/files/proof.rs index 75e4f22680..2353699ef8 100644 --- a/leo/files/proof.rs +++ b/leo/files/proof.rs @@ -43,7 +43,7 @@ impl ProofFile { let mut file = File::create(&path)?; file.write_all(proof)?; - log::info!("Proof stored to {:?}", path); + log::info!("Proof stored ({:?})", path); Ok(()) }