Skip to content

Commit

Permalink
feat: Sync from aztec-packages (#6001)
Browse files Browse the repository at this point in the history
Automated pull of Noir development from
[aztec-packages](https://github.com/AztecProtocol/aztec-packages).
BEGIN_COMMIT_OVERRIDE
feat: Sync from noir
(AztecProtocol/aztec-packages#8482)
feat: Change the layout of arrays and vectors to be a single pointer
(AztecProtocol/aztec-packages#8448)
END_COMMIT_OVERRIDE
  • Loading branch information
AztecBot authored Sep 11, 2024
1 parent 29550d1 commit d4832ec
Show file tree
Hide file tree
Showing 20 changed files with 1,019 additions and 991 deletions.
2 changes: 1 addition & 1 deletion .aztec-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
365193617179fbbfb6a19c8f194a0a214beac87f
79995c84e0f88c1ee72876fd21c50c33830597fc
43 changes: 20 additions & 23 deletions acvm-repo/brillig_vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,17 +449,16 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> VM<'a, F, B> {
}
HeapValueType::Array { value_types, size } => {
let array_address = self.memory.read_ref(value_address);
let array_start = self.memory.read_ref(array_address);
self.read_slice_of_values_from_memory(array_start, *size, value_types)
let items_start = MemoryAddress(array_address.to_usize() + 1);
self.read_slice_of_values_from_memory(items_start, *size, value_types)
}
HeapValueType::Vector { value_types } => {
let vector_address = self.memory.read_ref(value_address);
let vector_start = self.memory.read_ref(vector_address);
let size_address: MemoryAddress =
(vector_address.to_usize() + 1).into();
let size_address = MemoryAddress(vector_address.to_usize() + 1);
let items_start = MemoryAddress(vector_address.to_usize() + 2);
let vector_size = self.memory.read(size_address).to_usize();
self.read_slice_of_values_from_memory(
vector_start,
items_start,
vector_size,
value_types,
)
Expand Down Expand Up @@ -646,8 +645,8 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> VM<'a, F, B> {
current_pointer = MemoryAddress(current_pointer.to_usize() + 1);
}
HeapValueType::Array { .. } => {
let destination = self.memory.read_ref(current_pointer);
let destination = self.memory.read_ref(destination);
let destination =
MemoryAddress(self.memory.read_ref(current_pointer).0 + 1);
self.write_slice_of_values_to_memory(
destination,
values,
Expand Down Expand Up @@ -2005,33 +2004,31 @@ mod tests {
vec![MemoryValue::new_field(FieldElement::from(9u128))];

// construct memory by declaring all inner arrays/vectors first
// Declare v2
let v2_ptr: usize = 0usize;
let mut memory = v2.clone();
let v2_start = memory.len();
memory.extend(vec![MemoryValue::from(v2_ptr), v2.len().into(), MemoryValue::from(1_u32)]);
let mut memory = vec![MemoryValue::from(1_u32), v2.len().into()];
memory.extend(v2.clone());
let a4_ptr = memory.len();
memory.extend(vec![MemoryValue::from(1_u32)]);
memory.extend(a4.clone());
let a4_start = memory.len();
memory.extend(vec![MemoryValue::from(a4_ptr), MemoryValue::from(1_u32)]);
let v6_ptr = memory.len();
memory.extend(vec![MemoryValue::from(1_u32), v6.len().into()]);
memory.extend(v6.clone());
let v6_start = memory.len();
memory.extend(vec![MemoryValue::from(v6_ptr), v6.len().into(), MemoryValue::from(1_u32)]);
let a9_ptr = memory.len();
memory.extend(vec![MemoryValue::from(1_u32)]);
memory.extend(a9.clone());
let a9_start = memory.len();
memory.extend(vec![MemoryValue::from(a9_ptr), MemoryValue::from(1_u32)]);
// finally we add the contents of the outer array
let outer_ptr = memory.len();
memory.extend(vec![MemoryValue::from(1_u32)]);
let outer_start = memory.len();
let outer_array = vec![
MemoryValue::new_field(FieldElement::from(1u128)),
MemoryValue::from(v2.len() as u32),
MemoryValue::from(v2_start),
MemoryValue::from(a4_start),
MemoryValue::from(v2_ptr),
MemoryValue::from(a4_ptr),
MemoryValue::new_field(FieldElement::from(5u128)),
MemoryValue::from(v6.len() as u32),
MemoryValue::from(v6_start),
MemoryValue::from(a9_start),
MemoryValue::from(v6_ptr),
MemoryValue::from(a9_ptr),
];
memory.extend(outer_array.clone());

Expand Down Expand Up @@ -2075,7 +2072,7 @@ mod tests {
// input = 0
Opcode::Const {
destination: r_input,
value: (outer_ptr).into(),
value: (outer_start).into(),
bit_size: BitSize::Integer(IntegerBitSize::U32),
},
// some_function(input)
Expand Down
Loading

0 comments on commit d4832ec

Please sign in to comment.