Skip to content

Commit 491b5dc

Browse files
authored
Merge branch 'merge-train/barretenberg' into ad/bbapi/vk-simplified-buffer
2 parents 7474ce7 + ce4cd28 commit 491b5dc

File tree

164 files changed

+6149
-1751
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+6149
-1751
lines changed

.test_patterns.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,19 @@ tests:
4545
error_regex: "field_t::range_constraint"
4646
owners:
4747
- *luke
48-
- regex: "barretenberg/acir_tests/scripts/run_test_browser.sh"
48+
- regex: "barretenberg/acir_tests/scripts/browser_prove.sh"
4949
error_regex: "Failed to fetch"
5050
owners:
5151
- *adam
52-
- regex: "barretenberg/acir_tests/scripts/run_test_browser.sh"
53-
error_regex: "Failed to fetch"
54-
owners:
55-
- *adam
56-
- regex: "barretenberg/acir_tests/scripts/run_test_browser.sh"
52+
- regex: "barretenberg/acir_tests/scripts/browser_prove.sh"
5753
error_regex: "RuntimeError: Out of bounds memory access"
5854
owners:
5955
- *adam
60-
- regex: "barretenberg/acir_tests/scripts/run_test_browser.sh"
56+
- regex: "barretenberg/acir_tests/scripts/browser_prove.sh"
6157
error_regex: "call_indirect to a null table entry"
6258
owners:
6359
- *adam
64-
- regex: "barretenberg/acir_tests/scripts/run_test_browser.sh"
60+
- regex: "barretenberg/acir_tests/scripts/browser_prove.sh"
6561
error_regex: "Input is not large enough"
6662
owners:
6763
- *adam

barretenberg/cpp/CMakePresets.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@
250250
"cacheVariables": {
251251
"ENABLE_ASAN": "ON",
252252
"DISABLE_AZTEC_VM": "ON",
253-
"DISABLE_ASM": "ON"
253+
"DISABLE_ASM": "ON",
254+
"ENABLE_STACKTRACES": "OFF"
254255
}
255256
},
256257
{
@@ -261,7 +262,8 @@
261262
"binaryDir": "build-asan",
262263
"cacheVariables": {
263264
"ENABLE_ASAN": "ON",
264-
"DISABLE_ASM": "ON"
265+
"DISABLE_ASM": "ON",
266+
"ENABLE_STACKTRACES": "OFF"
265267
}
266268
},
267269
{

barretenberg/cpp/pil/vm2/execution/addressing.pil

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,9 @@ pol NUM_RELATIVE_E = 1 - sel_do_base_check;
128128
#[NUM_RELATIVE_INV_CHECK]
129129
NUM_RELATIVE_X * (NUM_RELATIVE_E * (1 - NUM_RELATIVE_Y) + NUM_RELATIVE_Y) - 1 + NUM_RELATIVE_E = 0;
130130

131-
// FIXME: this should eventually be a permutation.
132131
#[BASE_ADDRESS_FROM_MEMORY]
133132
sel_do_base_check { precomputed.clk, context_id, /*address=*/precomputed.zero, /*value=*/base_address_val, /*tag=*/base_address_tag, /*rw=*/precomputed.zero/*(read)*/ }
134-
in
135-
memory.sel { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
133+
is memory.sel_addressing_base { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
136134

137135
// This error will be true iff the base address is not valid AND we did actually check it.
138136
pol commit sel_base_address_failure;
@@ -259,30 +257,28 @@ sel_should_apply_indirection[6] = SEL_OP_IS_INDIRECT_EFFECTIVE_6_ * (1 - sel_rel
259257
pol commit rop_tag[7];
260258

261259
// If indirection is applied, we need to lookup the value from memory.
262-
// If sel_should_apply_indirection is 1, then we know the address is valid therefore we can make the lookups.
263-
// TODO: complete these lookups once we get memory done. In particular, clk and space id.
264-
// FIXME: these should eventually be permutations.
260+
// If sel_should_apply_indirection is 1, then we know the address is valid therefore we can make the permutations.
265261
#[INDIRECT_FROM_MEMORY_0]
266262
sel_should_apply_indirection[0] { precomputed.clk, context_id, /*address=*/op_after_relative[0], /*value=*/rop[0], /*tag=*/rop_tag[0], /*rw=*/precomputed.zero/*(read)*/ }
267-
in memory.sel { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
263+
is memory.sel_addressing_indirect[0] { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
268264
#[INDIRECT_FROM_MEMORY_1]
269265
sel_should_apply_indirection[1] { precomputed.clk, context_id, /*address=*/op_after_relative[1], /*value=*/rop[1], /*tag=*/rop_tag[1], /*rw=*/precomputed.zero/*(read)*/ }
270-
in memory.sel { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
266+
is memory.sel_addressing_indirect[1] { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
271267
#[INDIRECT_FROM_MEMORY_2]
272268
sel_should_apply_indirection[2] { precomputed.clk, context_id, /*address=*/op_after_relative[2], /*value=*/rop[2], /*tag=*/rop_tag[2], /*rw=*/precomputed.zero/*(read)*/ }
273-
in memory.sel { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
269+
is memory.sel_addressing_indirect[2] { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
274270
#[INDIRECT_FROM_MEMORY_3]
275271
sel_should_apply_indirection[3] { precomputed.clk, context_id, /*address=*/op_after_relative[3], /*value=*/rop[3], /*tag=*/rop_tag[3], /*rw=*/precomputed.zero/*(read)*/ }
276-
in memory.sel { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
272+
is memory.sel_addressing_indirect[3] { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
277273
#[INDIRECT_FROM_MEMORY_4]
278274
sel_should_apply_indirection[4] { precomputed.clk, context_id, /*address=*/op_after_relative[4], /*value=*/rop[4], /*tag=*/rop_tag[4], /*rw=*/precomputed.zero/*(read)*/ }
279-
in memory.sel { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
275+
is memory.sel_addressing_indirect[4] { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
280276
#[INDIRECT_FROM_MEMORY_5]
281277
sel_should_apply_indirection[5] { precomputed.clk, context_id, /*address=*/op_after_relative[5], /*value=*/rop[5], /*tag=*/rop_tag[5], /*rw=*/precomputed.zero/*(read)*/ }
282-
in memory.sel { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
278+
is memory.sel_addressing_indirect[5] { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
283279
#[INDIRECT_FROM_MEMORY_6]
284280
sel_should_apply_indirection[6] { precomputed.clk, context_id, /*address=*/op_after_relative[6], /*value=*/rop[6], /*tag=*/rop_tag[6], /*rw=*/precomputed.zero/*(read)*/ }
285-
in memory.sel { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
281+
is memory.sel_addressing_indirect[6] { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
286282

287283
// Otherwise, if indirection is not applied , we propagate the operands from the previous step.
288284
#[INDIRECT_PROPAGATION_0]

barretenberg/cpp/pil/vm2/keccak_memory.pil

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,9 @@ val43 = (1 - last) * val42';
237237
#[VAL44]
238238
val44 = (1 - last) * val43';
239239

240-
// Memory permutation
241-
// TODO: Proper memory permutation (not a lookup), and introduce a specific
242-
// selector for keccak in memory sub-trace.
243240
#[SLICE_TO_MEM]
244-
sel {clk, addr, val00, tag, rw, space_id}
245-
in // TODO: replace with `is` (permutation)
246-
memory.sel { memory.clk, memory.address, memory.value, memory.tag, memory.rw, memory.space_id };
241+
sel { clk, space_id, addr, val00, tag, rw }
242+
is memory.sel_keccak { memory.clk, memory.space_id, memory.address, memory.value, memory.tag, memory.rw };
247243

248244
// Used to constrain the number of rounds in keccakf1600.pil through the slice_write lookup.
249245
pol commit num_rounds;

barretenberg/cpp/pil/vm2/memory.pil

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,49 @@ pol commit tag;
1010
pol commit rw;
1111
pol commit space_id;
1212

13+
// Permutation selectors (addressing.pil).
14+
pol commit sel_addressing_base;
15+
pol commit sel_addressing_indirect[7];
16+
sel_addressing_base * (1 - sel_addressing_base) = 0;
17+
sel_addressing_indirect[0] * (1 - sel_addressing_indirect[0]) = 0;
18+
sel_addressing_indirect[1] * (1 - sel_addressing_indirect[1]) = 0;
19+
sel_addressing_indirect[2] * (1 - sel_addressing_indirect[2]) = 0;
20+
sel_addressing_indirect[3] * (1 - sel_addressing_indirect[3]) = 0;
21+
sel_addressing_indirect[4] * (1 - sel_addressing_indirect[4]) = 0;
22+
sel_addressing_indirect[5] * (1 - sel_addressing_indirect[5]) = 0;
23+
sel_addressing_indirect[6] * (1 - sel_addressing_indirect[6]) = 0;
24+
25+
// Permutation selectors (keccak_memory.pil).
26+
pol commit sel_keccak;
27+
sel_keccak * (1 - sel_keccak) = 0;
28+
29+
// Permutation selectors (sha256_mem.pil).
30+
pol commit sel_sha256_read;
31+
pol commit sel_sha256_op[8];
32+
sel_sha256_read * (1 - sel_sha256_read) = 0;
33+
sel_sha256_op[0] * (1 - sel_sha256_op[0]) = 0;
34+
sel_sha256_op[1] * (1 - sel_sha256_op[1]) = 0;
35+
sel_sha256_op[2] * (1 - sel_sha256_op[2]) = 0;
36+
sel_sha256_op[3] * (1 - sel_sha256_op[3]) = 0;
37+
sel_sha256_op[4] * (1 - sel_sha256_op[4]) = 0;
38+
sel_sha256_op[5] * (1 - sel_sha256_op[5]) = 0;
39+
sel_sha256_op[6] * (1 - sel_sha256_op[6]) = 0;
40+
sel_sha256_op[7] * (1 - sel_sha256_op[7]) = 0;
41+
42+
// Permutation consistency.
43+
/*
44+
sel = // Addressing.
45+
sel_addressing_base
46+
+ sel_addressing_indirect[0] + sel_addressing_indirect[1] + sel_addressing_indirect[2] + sel_addressing_indirect[3]
47+
+ sel_addressing_indirect[4] + sel_addressing_indirect[5] + sel_addressing_indirect[6]
48+
// Keccak.
49+
+ sel_keccak
50+
// Sha256.
51+
+ sel_sha256_read
52+
+ sel_sha256_op[0] + sel_sha256_op[1] + sel_sha256_op[2] + sel_sha256_op[3]
53+
+ sel_sha256_op[4] + sel_sha256_op[5] + sel_sha256_op[6] + sel_sha256_op[7];
54+
*/
55+
1356
#[skippable_if]
1457
sel = 0;
1558

0 commit comments

Comments
 (0)