Skip to content

Commit

Permalink
Merge branch 'master' into kw/bb-binaries
Browse files Browse the repository at this point in the history
* master:
  chore!: Remove keys from preprocessed artifacts (#2283)
  chore(noir): Release 0.10.5 (#2482)
  feat: Basic implementation of traits (#2368)
  fix: Implement constant folding during the mem2reg pass (#2464)
  • Loading branch information
TomAFrench committed Aug 30, 2023
2 parents bd6bd29 + 4554287 commit 4d322f7
Show file tree
Hide file tree
Showing 61 changed files with 1,244 additions and 150 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.10.4"
".": "0.10.5"
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [0.10.5](https://github.com/noir-lang/noir/compare/v0.10.4...v0.10.5) (2023-08-30)


### Features

* Basic implementation of traits ([#2368](https://github.com/noir-lang/noir/issues/2368)) ([df9f09e](https://github.com/noir-lang/noir/commit/df9f09eda62b7d09ed8ade8cad907453ea91d3e2))


### Bug Fixes

* Implement constant folding during the mem2reg pass ([#2464](https://github.com/noir-lang/noir/issues/2464)) ([5361ebd](https://github.com/noir-lang/noir/commit/5361ebd8a66648678702258bd07c9d221c748c8c))
* **ssa:** Handle right shift with constants ([#2481](https://github.com/noir-lang/noir/issues/2481)) ([13a8c87](https://github.com/noir-lang/noir/commit/13a8c878422f03c33c924ff9cb56d5fd08195357))

## [0.10.4](https://github.com/noir-lang/noir/compare/v0.10.3...v0.10.4) (2023-08-29)


Expand Down
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ resolver = "2"

[workspace.package]
# x-release-please-start-version
version = "0.10.4"
version = "0.10.5"
# x-release-please-end
authors = ["The Noir Team <[email protected]>"]
edition = "2021"
Expand Down
38 changes: 35 additions & 3 deletions crates/nargo_cli/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use acvm::{acir::circuit::Circuit, compiler::AcirTransformationMap, Backend};
use iter_extended::{try_vecmap, vecmap};
use iter_extended::try_vecmap;
use nargo::artifacts::contract::PreprocessedContractFunction;
use nargo::artifacts::debug::DebugArtifact;
use nargo::artifacts::program::PreprocessedProgram;
Expand Down Expand Up @@ -102,8 +102,34 @@ pub(crate) fn run<B: Backend>(
},
debug_infos,
)
});
for (contract, debug_infos) in preprocessed_contracts {
.map_err(CliError::CommonReferenceStringError)?;

Ok::<_, CliError<B>>((
PreprocessedContractFunction {
name: func.name,
function_type: func.function_type,
is_internal: func.is_internal,
abi: func.abi,

bytecode: func.bytecode,
},
func.debug,
))
})?;

let (preprocessed_contract_functions, debug_infos): (Vec<_>, Vec<_>) =
preprocess_result.into_iter().unzip();

Ok((
PreprocessedContract {
name: contract.name,
backend: String::from(BACKEND_IDENTIFIER),
functions: preprocessed_contract_functions,
},
debug_infos,
))
});
for (contract, debug_infos) in preprocessed_contracts? {
save_contract_to_file(
&contract,
&format!("{}-{}", package.name, contract.name),
Expand All @@ -128,6 +154,12 @@ pub(crate) fn run<B: Backend>(
bytecode: program.circuit,
};

let preprocessed_program = PreprocessedProgram {
backend: String::from(BACKEND_IDENTIFIER),
abi: program.abi,
bytecode: program.circuit,
};

save_program_to_file(&preprocessed_program, &package.name, &circuit_dir);

if args.output_debug {
Expand Down
14 changes: 14 additions & 0 deletions crates/nargo_cli/src/cli/prove_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use noirc_driver::CompileOptions;
use noirc_frontend::graph::CrateName;

use super::compile_cmd::compile_package;
use super::fs::common_reference_string::update_common_reference_string;
use super::fs::{
common_reference_string::read_cached_common_reference_string,
inputs::{read_inputs_from_file, write_inputs_to_file},
program::read_program_from_file,
proof::save_proof_to_dir,
Expand Down Expand Up @@ -105,6 +107,18 @@ pub(crate) fn prove_package<B: Backend>(
(preprocessed_program, Some((program.debug, context)))
};

let common_reference_string = read_cached_common_reference_string();
let common_reference_string = update_common_reference_string(
backend,
&common_reference_string,
&preprocessed_program.bytecode,
)
.map_err(CliError::CommonReferenceStringError)?;

let (proving_key, verification_key) = backend
.preprocess(&common_reference_string, &preprocessed_program.bytecode)
.map_err(CliError::ProofSystemCompilerError)?;

let PreprocessedProgram { abi, bytecode, .. } = preprocessed_program;

// Parse the initial witness values from Prover.toml
Expand Down
3 changes: 3 additions & 0 deletions crates/nargo_cli/src/cli/verify_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use super::fs::common_reference_string::{
read_cached_common_reference_string, update_common_reference_string,
};
use super::NargoConfig;
use super::{
compile_cmd::compile_package,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "dup_trait_declaration"
type = "bin"
authors = [""]
compiler_version = "0.9.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 1
y = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use dep::std;

trait Default {
fn default(x: Field, y: Field) -> Self;
}

struct Foo {
bar: Field,
array: [Field; 2],
}

impl Default for Foo {
fn default(x: Field,y: Field) -> Self {
Self { bar: x, array: [x,y] }
}
}

// Duplicate trait declarations should not compile
trait Default {
fn default(x: Field) -> Self;
}

fn main(x: Field, y: Field) {
let first = Foo::default(x,y);
assert(first.bar == x);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "dup_trait_implementation"
type = "bin"
authors = [""]
compiler_version = "0.9.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 1
y = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use dep::std;

trait Default {
fn default(x: Field, y: Field) -> Self;
}

struct Foo {
bar: Field,
array: [Field; 2],
}

// Duplicate trait implementations should not compile
impl Default for Foo {
fn default(x: Field,y: Field) -> Self {
Self { bar: x, array: [x,y] }
}
}

// Duplicate trait implementations should not compile
impl Default for Foo {
fn default(x: Field, y: Field) -> Self {
Self { bar: y, array: [y,x] }
}
}


fn main(x: Field, y: Field) {
let first = Foo::default(x,y);
assert(first.bar == x);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "impl_struct_not_trait"
type = "bin"
authors = [""]
compiler_version = "0.9.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 1
y = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use dep::std;

struct Foo {
bar: Field,
array: [Field; 2],
}

struct Default {
x: Field,
z: Field,
}

// Default is struct not a trait
impl Default for Foo {
fn default(x: Field, y: Field) -> Self {
Self { bar: x, array: [x,y] }
}
}

fn main(x: Field, y: Field) {
let first = Foo::default(x,y);
assert(first.bar == x);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "traits"
type = "bin"
authors = [""]
compiler_version = "0.1"

[dependencies]
Loading

0 comments on commit 4d322f7

Please sign in to comment.