Skip to content

Commit

Permalink
Merge branch 'master' into tf/break-up-traits
Browse files Browse the repository at this point in the history
* master:
  fix(experimental elaborator): Avoid calling `add_generics` twice on trait methods (#5108)
  fix(experimental elaborator): Fix duplicate `resolve_type` on self type and don't leak a trait impl's generics (#5102)
  feat: replace stdlib poseidon implementation with optimized version (#5122)
  fix(experimental elaborator): Only call `add_generics` once (#5091)
  fix(experimental elaborator): Fix panic in the elaborator (#5082)
  chore: move `is_native_field` up into `noirc_frontend` (#5119)
  • Loading branch information
TomAFrench committed May 28, 2024
2 parents c463f2c + 7d8c0a3 commit 8acf029
Show file tree
Hide file tree
Showing 25 changed files with 25,504 additions and 556 deletions.
4 changes: 3 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion acvm-repo/acir_field/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ repository.workspace = true
hex.workspace = true
num-bigint.workspace = true
serde.workspace = true
num-traits.workspace = true

ark-bn254 = { version = "^0.4.0", default-features = false, features = ["curve"] }
ark-bls12-381 = { version = "^0.4.0", optional = true, default-features = false, features = ["curve"] }
Expand Down
32 changes: 0 additions & 32 deletions acvm-repo/acir_field/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
#![warn(clippy::semicolon_if_nothing_returned)]
#![cfg_attr(not(test), warn(unused_crate_dependencies, unused_extern_crates))]

use num_bigint::BigUint;
use num_traits::Num;

mod field_element;
mod generic_ark;

Expand All @@ -17,40 +14,11 @@ pub use field_element::FieldElement as GenericFieldElement;
cfg_if::cfg_if! {
if #[cfg(feature = "bls12_381")] {
pub type FieldElement = field_element::FieldElement<ark_bls12_381::Fr>;
pub const CHOSEN_FIELD : FieldOptions = FieldOptions::BLS12_381;
} else {
pub type FieldElement = field_element::FieldElement<ark_bn254::Fr>;
pub const CHOSEN_FIELD : FieldOptions = FieldOptions::BN254;
}
}

#[derive(Debug, PartialEq, Eq)]
pub enum FieldOptions {
BN254,
BLS12_381,
}

impl FieldOptions {
pub fn to_string(&self) -> &str {
match self {
FieldOptions::BN254 => "bn254",
FieldOptions::BLS12_381 => "bls12_381",
}
}

pub fn is_native_field(str: &str) -> bool {
let big_num = if let Some(hex) = str.strip_prefix("0x") {
BigUint::from_str_radix(hex, 16)
} else {
BigUint::from_str_radix(str, 10)
};
if let Ok(big_num) = big_num {
big_num == FieldElement::modulus()
} else {
CHOSEN_FIELD.to_string() == str
}
}
}
// This is needed because features are additive through the dependency graph; if a dependency turns on the bn254, then it
// will be turned on in all crates that depend on it
#[macro_export]
Expand Down
6 changes: 6 additions & 0 deletions compiler/noirc_frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ smol_str.workspace = true
im.workspace = true
serde_json.workspace = true
serde.workspace = true
num-bigint.workspace = true
num-traits.workspace = true
rustc-hash = "1.1.0"
small-ord-set = "0.1.3"
regex = "1.9.1"
cfg-if = "1.0.0"
tracing.workspace = true
petgraph = "0.6"
lalrpop-util = { version = "0.20.2", features = ["lexer"] }


[dev-dependencies]
base64.workspace = true
strum = "0.24"
Expand All @@ -39,3 +43,5 @@ lalrpop = "0.20.2"

[features]
experimental_parser = []
bn254 = []
bls12_381 = []
12 changes: 6 additions & 6 deletions compiler/noirc_frontend/src/elaborator/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use crate::{
hir_def::{
expr::{
HirArrayLiteral, HirBinaryOp, HirBlockExpression, HirCallExpression, HirCastExpression,
HirConstructorExpression, HirIdent, HirIfExpression, HirIndexExpression,
HirInfixExpression, HirLambda, HirMemberAccess, HirMethodCallExpression,
HirMethodReference, HirPrefixExpression,
HirConstructorExpression, HirIfExpression, HirIndexExpression, HirInfixExpression,
HirLambda, HirMemberAccess, HirMethodCallExpression, HirMethodReference,
HirPrefixExpression,
},
traits::TraitConstraint,
},
Expand Down Expand Up @@ -84,10 +84,10 @@ impl<'context> Elaborator<'context> {
expr_type: inner_expr_type.clone(),
expr_span: span,
});
}

if i + 1 == statements.len() {
block_type = stmt_type;
}
if i + 1 == statements.len() {
block_type = stmt_type;
}
}

Expand Down
Loading

0 comments on commit 8acf029

Please sign in to comment.