Skip to content

Commit

Permalink
Revert "Merge 'jf/ssa' to master (#217)" (#222)
Browse files Browse the repository at this point in the history
This reverts commit 8da90d5.
  • Loading branch information
jfecher authored May 19, 2022
1 parent 6ad1449 commit 7d40c57
Show file tree
Hide file tree
Showing 21 changed files with 1,955 additions and 1,798 deletions.
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
edition = "2018"
use_small_heuristics = "Max"
use_small_heuristics="Max"
6 changes: 1 addition & 5 deletions crates/nargo/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ pub fn start_cli() {
App::new("prove")
.about("Create proof for this program")
.arg(Arg::with_name("proof_name").help("The name of the proof").required(true))
.arg(
Arg::with_name("show-ssa")
.long("show-ssa")
.help("Emit debug information for the intermediate SSA IR"),
),
.arg(Arg::with_name("interactive").help("pause execution").required(false)),
)
.get_matches();

Expand Down
21 changes: 13 additions & 8 deletions crates/nargo/src/cli/prove_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@ use crate::{errors::CliError, resolver::Resolver};
use super::{create_dir, write_to_file, PROOFS_DIR, PROOF_EXT, PROVER_INPUT_FILE};

pub(crate) fn run(args: ArgMatches) -> Result<(), CliError> {
let args = args.subcommand_matches("prove").unwrap();
let proof_name = args.value_of("proof_name").unwrap();
let show_ssa = args.is_present("show-ssa");
prove(proof_name, show_ssa)
let proof_name = args.subcommand_matches("prove").unwrap().value_of("proof_name").unwrap();
let interactive = args.subcommand_matches("prove").unwrap().value_of("interactive");
let mut is_interactive = false;
if let Some(int) = interactive {
if int == "i" {
is_interactive = true;
}
}
prove(proof_name, is_interactive)
}

/// In Barretenberg, the proof system adds a zero witness in the first index,
/// So when we add witness values, their index start from 1.
const WITNESS_OFFSET: u32 = 1;

fn prove(proof_name: &str, show_ssa: bool) -> Result<(), CliError> {
fn prove(proof_name: &str, interactive: bool) -> Result<(), CliError> {
let curr_dir = std::env::current_dir().unwrap();
let mut proof_path = PathBuf::new();
proof_path.push(PROOFS_DIR);
let result = prove_with_path(proof_name, curr_dir, proof_path, show_ssa);
let result = prove_with_path(proof_name, curr_dir, proof_path, interactive);
match result {
Ok(_) => Ok(()),
Err(e) => Err(e),
Expand Down Expand Up @@ -84,11 +89,11 @@ pub fn prove_with_path<P: AsRef<Path>>(
proof_name: &str,
program_dir: P,
proof_dir: P,
show_ssa: bool,
interactive: bool,
) -> Result<PathBuf, CliError> {
let driver = Resolver::resolve_root_config(program_dir.as_ref())?;
let backend = crate::backends::ConcreteBackend;
let compiled_program = driver.into_compiled_program(backend.np_language(), show_ssa);
let compiled_program = driver.into_compiled_program(backend.np_language(), interactive);

// Parse the initial witness values
let witness_map = noirc_abi::input_parser::Format::Toml.parse(program_dir, PROVER_INPUT_FILE);
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo/tests/test_data/5_over/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

fn main(mut x : u32, y : u32) {
x = x * x;
constrain y == x;
constrain (y) == x;
}
4 changes: 0 additions & 4 deletions crates/noir_field/src/generic_ark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ impl<F: PrimeField> FieldElement<F> {
FieldElement(inv)
}

pub fn try_inverse(mut self) -> Option<Self> {
self.0.inverse_in_place().map(|f| FieldElement(*f))
}

// XXX: This method is used while this field element
// implementation is not generic.
pub fn into_repr(self) -> F {
Expand Down
4 changes: 2 additions & 2 deletions crates/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl Driver {
pub fn into_compiled_program(
mut self,
np_language: acvm::Language,
show_ssa: bool,
interactive: bool,
) -> CompiledProgram {
self.build();
// First find the local crate
Expand All @@ -166,7 +166,7 @@ impl Driver {
let evaluator = Evaluator::new(main_function, &self.context);

// Compile Program
let circuit = match evaluator.compile(np_language, show_ssa) {
let circuit = match evaluator.compile(np_language, interactive) {
Ok(circuit) => circuit,
Err(err) => {
// The FileId here will be the file id of the file with the main file
Expand Down
1 change: 1 addition & 0 deletions crates/noirc_evaluator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ lazy_static = "1.4.0"
thiserror = "1.0.21"
num-bigint = "0.4"
num-traits = "0.2.8"
if_debug = "0.1.0"
13 changes: 8 additions & 5 deletions crates/noirc_evaluator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ impl<'a> Evaluator<'a> {
pub fn compile(
mut self,
np_language: Language,
enable_logging: bool,
interactive: bool,
) -> Result<Circuit, RuntimeError> {
// create a new environment for the main context
let mut env = Environment::new(FuncContext::Main);

// First evaluate the main function
if enable_logging {
self.evaluate_main_alt(&mut env, enable_logging)?;
if interactive {
self.evaluate_main_alt(&mut env, interactive)?;
} else {
self.evaluate_main(&mut env)?;
}
Expand Down Expand Up @@ -173,6 +173,9 @@ impl<'a> Evaluator<'a> {
HirBinaryOpKind::Shr | HirBinaryOpKind::Shl => Err(RuntimeErrorKind::Unimplemented(
"Bit shift operations are not currently implemented.".to_owned(),
)),
HirBinaryOpKind::MemberAccess => {
todo!("Member access for structs is unimplemented in the noir backend")
}
}
.map_err(|kind| kind.add_span(op.span))
}
Expand Down Expand Up @@ -205,7 +208,7 @@ impl<'a> Evaluator<'a> {
pub fn evaluate_main_alt(
&mut self,
env: &mut Environment,
enable_logging: bool,
interactive: bool,
) -> Result<(), RuntimeError> {
let mut igen = IRGenerator::new(self.context);
self.parse_abi_alt(env, &mut igen)?;
Expand All @@ -215,7 +218,7 @@ impl<'a> Evaluator<'a> {
ssa::code_gen::evaluate_main(&mut igen, env, main_func_body)?;

//Generates ACIR representation:
igen.context.ir_to_acir(self, enable_logging)?;
igen.context.ir_to_acir(self, interactive)?;
Ok(())
}

Expand Down
Loading

0 comments on commit 7d40c57

Please sign in to comment.