Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Sync from noir #9034

Merged
merged 25 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3d17e4a
[1 changes] feat(perf): Follow array sets backwards in array set from…
AztecBot Oct 5, 2024
0178e71
chore: apply sync fixes
AztecBot Oct 5, 2024
ebd7820
[1 changes] feat(perf): Follow array sets backwards in array set from…
AztecBot Oct 6, 2024
44a4d46
chore: apply sync fixes
AztecBot Oct 6, 2024
66fcb08
feat(perf): Follow array sets backwards in array set from get optimiz…
AztecBot Oct 6, 2024
7fcceac
[1 changes] feat(perf): Follow array sets backwards in array set from…
AztecBot Oct 7, 2024
414f3d3
chore: apply sync fixes
AztecBot Oct 7, 2024
dfc1444
feat(perf): Follow array sets backwards in array set from get optimiz…
AztecBot Oct 7, 2024
33140b3
[1 changes] feat: add more `Type` and `UnresolvedType` methods (https…
AztecBot Oct 7, 2024
d67386c
chore: apply sync fixes
AztecBot Oct 7, 2024
a256d70
feat: add more `Type` and `UnresolvedType` methods (https://github.co…
AztecBot Oct 7, 2024
484b386
Merge branch 'master' into sync-noir
sirasistant Oct 7, 2024
c17bc36
[1 changes] fix: handle nested arrays in calldata (https://github.com…
AztecBot Oct 7, 2024
1cb2abd
chore: apply sync fixes
AztecBot Oct 7, 2024
4ce6453
fix: handle nested arrays in calldata (https://github.com/noir-lang/n…
AztecBot Oct 7, 2024
fe9b4a4
fix: restore verify honk
sirasistant Oct 7, 2024
104725a
[1 changes] feat: handwritten parser (https://github.com/noir-lang/no…
AztecBot Oct 7, 2024
b47ebaf
chore: apply sync fixes
AztecBot Oct 7, 2024
a8b414c
feat: handwritten parser (https://github.com/noir-lang/noir/pull/6180)
AztecBot Oct 7, 2024
898b6a1
[1 changes] feat: handwritten parser (https://github.com/noir-lang/no…
AztecBot Oct 8, 2024
d16681f
chore: apply sync fixes
AztecBot Oct 8, 2024
cc51963
feat: handwritten parser (https://github.com/noir-lang/noir/pull/6180)
AztecBot Oct 8, 2024
576c7c7
fix: restore deleted tests
sirasistant Oct 8, 2024
b2ca704
update cargo lock
sirasistant Oct 8, 2024
94a8dc4
Merge branch 'master' into sync-noir
sirasistant Oct 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .noir-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c3cb38a7c4de6fc321b367eda3fca6d06e76b77a
c4273a0c8f8b751a3dbe097e070e4e7b2c8ec438
31 changes: 1 addition & 30 deletions avm-transpiler/Cargo.lock

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

38 changes: 5 additions & 33 deletions noir/noir-repo/Cargo.lock

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

14 changes: 8 additions & 6 deletions noir/noir-repo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ bb_abstraction_leaks = { path = "tooling/bb_abstraction_leaks" }
acvm_cli = { path = "tooling/acvm_cli" }

# Arkworks
ark-bn254 = { version = "^0.4.0", default-features = false, features = ["curve"] }
ark-bls12-381 = { version = "^0.4.0", default-features = false, features = ["curve"] }
ark-bn254 = { version = "^0.4.0", default-features = false, features = [
"curve",
] }
ark-bls12-381 = { version = "^0.4.0", default-features = false, features = [
"curve",
] }
grumpkin = { version = "0.1.0", package = "noir_grumpkin", features = ["std"] }
ark-ec = { version = "^0.4.0", default-features = false }
ark-ff = { version = "^0.4.0", default-features = false }
Expand Down Expand Up @@ -117,10 +121,6 @@ clap = { version = "4.3.19", features = ["derive", "env"] }
codespan = { version = "0.11.1", features = ["serialization"] }
codespan-lsp = "0.11.1"
codespan-reporting = "0.11.1"
chumsky = { git = "https://github.com/jfecher/chumsky", rev = "ad9d312", default-features = false, features = [
"ahash",
"std",
] }

# Benchmarking
criterion = "0.5.0"
Expand Down Expand Up @@ -153,6 +153,8 @@ rand = "0.8.5"
proptest = "1.2.0"
proptest-derive = "0.4.0"
rayon = "1.8.0"
sha2 = { version = "0.10.6", features = ["compress"] }
sha3 = "0.10.6"

im = { version = "15.1", features = ["serde"] }
tracing = "0.1.40"
Expand Down
4 changes: 2 additions & 2 deletions noir/noir-repo/acvm-repo/blackbox_solver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ num-bigint = "0.4"

blake2 = "0.10.6"
blake3 = "1.5.0"
sha2 = { version="0.10.6", features = ["compress",] }
sha3 = "0.10.6"
sha2.workspace = true
sha3.workspace = true
keccak = "0.1.4"
k256 = { version = "0.11.0", features = [
"ecdsa",
Expand Down
1 change: 0 additions & 1 deletion noir/noir-repo/compiler/noirc_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ acvm.workspace = true
codespan-reporting.workspace = true
codespan.workspace = true
fm.workspace = true
chumsky.workspace = true
noirc_printable_type.workspace = true
serde.workspace = true
serde_with = "3.2.0"
Expand Down
22 changes: 1 addition & 21 deletions noir/noir-repo/compiler/noirc_errors/src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{

pub type Position = u32;

#[derive(PartialOrd, Eq, Ord, Debug, Clone)]
#[derive(PartialOrd, Eq, Ord, Debug, Clone, Default)]
pub struct Spanned<T> {
pub contents: T,
span: Span,
Expand Down Expand Up @@ -121,26 +121,6 @@ impl From<Range<u32>> for Span {
}
}

impl chumsky::Span for Span {
type Context = ();

type Offset = u32;

fn new(_context: Self::Context, range: Range<Self::Offset>) -> Self {
Span(ByteSpan::from(range))
}

fn context(&self) -> Self::Context {}

fn start(&self) -> Self::Offset {
self.start()
}

fn end(&self) -> Self::Offset {
self.end()
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
pub struct Location {
pub span: Span,
Expand Down
47 changes: 31 additions & 16 deletions noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,29 @@ impl<'a> Context<'a> {
}
}

/// Returns the acir value at the provided databus offset
fn get_from_call_data(
&mut self,
offset: &mut AcirVar,
call_data_block: BlockId,
typ: &Type,
) -> Result<AcirValue, RuntimeError> {
match typ {
Type::Numeric(_) => self.array_get_value(&Type::field(), call_data_block, offset),
Type::Array(arc, len) => {
let mut result = Vector::new();
for _i in 0..*len {
for sub_type in arc.iter() {
let element = self.get_from_call_data(offset, call_data_block, sub_type)?;
result.push_back(element);
}
}
Ok(AcirValue::Array(result))
}
_ => unimplemented!("Unsupported type in databus"),
}
}

/// Generates a read opcode for the array
/// `index_side_effect == false` means that we ensured `var_index` will have a type matching the value in the array
fn array_get(
Expand All @@ -1316,27 +1339,19 @@ impl<'a> Context<'a> {
let block_id = self.ensure_array_is_initialized(array, dfg)?;
let results = dfg.instruction_results(instruction);
let res_typ = dfg.type_of_value(results[0]);

// Get operations to call-data parameters are replaced by a get to the call-data-bus array
if let Some(call_data) =
self.data_bus.call_data.iter().find(|cd| cd.index_map.contains_key(&array))
{
let type_size = res_typ.flattened_size();
let type_size = self.acir_context.add_constant(FieldElement::from(type_size as i128));
let offset = self.acir_context.mul_var(var_index, type_size)?;
let call_data =
self.data_bus.call_data.iter().find(|cd| cd.index_map.contains_key(&array)).cloned();
if let Some(call_data) = call_data {
let call_data_block = self.ensure_array_is_initialized(call_data.array_id, dfg)?;
let bus_index = self
.acir_context
.add_constant(FieldElement::from(call_data.index_map[&array] as i128));
let new_index = self.acir_context.add_var(offset, bus_index)?;
return self.array_get(
instruction,
call_data.array_id,
new_index,
dfg,
index_side_effect,
);
let mut current_index = self.acir_context.add_var(bus_index, var_index)?;
let result = self.get_from_call_data(&mut current_index, call_data_block, &res_typ)?;
self.define_result(dfg, instruction, result.clone());
return Ok(result);
}

// Compiler sanity check
assert!(
!res_typ.contains_slice_element(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,24 @@ impl FunctionBuilder {
databus.index += 1;
}
Type::Array(typ, len) => {
assert!(typ.len() == 1, "unsupported composite type");
databus.map.insert(value, databus.index);
for i in 0..len {
// load each element of the array
let index = self
.current_function
.dfg
.make_constant(FieldElement::from(i as i128), Type::length_type());
let element = self.insert_array_get(value, index, typ[0].clone());
self.add_to_data_bus(element, databus);

let mut index = 0;
for _i in 0..len {
for subitem_typ in typ.iter() {
// load each element of the array, and add it to the databus
let index_var = self
.current_function
.dfg
.make_constant(FieldElement::from(index as i128), Type::length_type());
let element = self.insert_array_get(value, index_var, subitem_typ.clone());
index += match subitem_typ {
Type::Array(_, _) | Type::Slice(_) => subitem_typ.element_size(),
Type::Numeric(_) => 1,
_ => unreachable!("Unsupported type for databus"),
};
self.add_to_data_bus(element, databus);
}
}
}
Type::Reference(_) => {
Expand Down
Loading
Loading