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 aztec-packages #6001

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 .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 @@ -337,7 +337,7 @@
self.set_program_counter(*location)
}
Opcode::Const { destination, value, bit_size } => {
// Consts are not checked in runtime to fit in the bit size, since they can safely be checked statically.

Check warning on line 340 in acvm-repo/brillig_vm/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Consts)
self.memory.write(*destination, MemoryValue::new_from_field(*value, *bit_size));
self.increment_program_counter()
}
Expand Down Expand Up @@ -449,17 +449,16 @@
}
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 @@
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 @@ -837,7 +836,7 @@
}

#[test]
fn jmpifnot_opcode() {

Check warning on line 839 in acvm-repo/brillig_vm/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (jmpifnot)
let calldata: Vec<FieldElement> = vec![1u128.into(), 2u128.into()];

let opcodes = vec![
Expand Down Expand Up @@ -997,7 +996,7 @@
}

#[test]
fn cmov_opcode() {

Check warning on line 999 in acvm-repo/brillig_vm/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (cmov)
let calldata: Vec<FieldElement> =
vec![(0u128).into(), (1u128).into(), (2u128).into(), (3u128).into()];

Expand Down Expand Up @@ -1251,7 +1250,7 @@
}

#[test]
fn iconst_opcode() {

Check warning on line 1253 in acvm-repo/brillig_vm/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (iconst)
let opcodes = &[
Opcode::Const {
destination: MemoryAddress(0),
Expand Down Expand Up @@ -2005,33 +2004,31 @@
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 @@
// 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
Loading