Skip to content

Commit 1b08a64

Browse files
committed
feat(avm)!: enable amm check circuit
1 parent 95932af commit 1b08a64

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

barretenberg/cpp/pil/vm2/context.pil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ namespace execution;
126126

127127
// The initial next_context_id = 2, in row = 1
128128
#[INCR_NEXT_CONTEXT_ID]
129-
NOT_LAST_EXEC * (next_context_id' - (next_context_id + sel_enter_call)) = 0;
129+
NOT_LAST_EXEC * (next_context_id' - (next_context_id + sel_enter_call + enqueued_call_start')) = 0;
130130

131131
// nested_exit_call = 1 ==> context_id' = parent_id
132132
// sel_enter_call = 1 ==> context_id' = next_context_id

barretenberg/cpp/pil/vm2/opcodes/internal_call.pil

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ namespace execution;
1717
// When we encounter this case, the internal call information in the next row is constrained to change (incremented, unwound, etc)
1818
pol NEW_NEXT_CALL_ID = (sel_execute_internal_call + sel_execute_internal_return) * (1 - sel_error) + sel_exit_call;
1919

20-
pol PROPAGATE_CALL_ID = 1 - RESET_NEXT_CALL_ID - NEW_NEXT_CALL_ID;
20+
// This is an XOR
21+
pol RESET_OR_NEW_NEXT_CALL_ID = (RESET_NEXT_CALL_ID + NEW_NEXT_CALL_ID) - (RESET_NEXT_CALL_ID * NEW_NEXT_CALL_ID);
22+
pol PROPAGATE_CALL_ID = 1 - RESET_OR_NEW_NEXT_CALL_ID;
2123

2224
// =============================
2325
// === Internal Call Pointer ===
@@ -55,9 +57,8 @@ namespace execution;
5557
#[NEXT_CALL_ID_STARTS_TWO]
5658
RESET_NEXT_CALL_ID * (next_internal_call_id' - 2) = 0;
5759
// If we encounter a sel_execute_internal_call, we increment the next next_internal_call_id, unless we are changing context
58-
pol CONTEXT_CHANGE = (RESET_NEXT_CALL_ID + sel_exit_call) - (RESET_NEXT_CALL_ID * sel_exit_call) ;
5960
#[INCR_NEXT_INT_CALL_ID]
60-
NOT_LAST_EXEC * (1 - CONTEXT_CHANGE) * (next_internal_call_id' - (next_internal_call_id + sel_execute_internal_call)) = 0;
61+
NOT_LAST_EXEC * (1 - RESET_OR_NEW_NEXT_CALL_ID) * (next_internal_call_id' - (next_internal_call_id + sel_execute_internal_call)) = 0;
6162

6263
// =============================
6364
// === Error Handling ====

barretenberg/cpp/src/barretenberg/vm2/generated/relations/context_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ void contextImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
9292
using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>;
9393
auto tmp =
9494
execution_NOT_LAST_EXEC * (in.get(C::execution_next_context_id_shift) -
95-
(in.get(C::execution_next_context_id) + in.get(C::execution_sel_enter_call)));
95+
(in.get(C::execution_next_context_id) + in.get(C::execution_sel_enter_call) +
96+
in.get(C::execution_enqueued_call_start_shift)));
9697
tmp *= scaling_factor;
9798
std::get<7>(evals) += typename Accumulator::View(tmp);
9899
}

barretenberg/cpp/src/barretenberg/vm2/generated/relations/internal_call.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ template <typename FF_> class internal_callImpl {
1414
public:
1515
using FF = FF_;
1616

17-
static constexpr std::array<size_t, 10> SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 6, 3, 3, 6, 3, 6, 5 };
17+
static constexpr std::array<size_t, 10> SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 3, 7, 3, 3, 7, 3, 7, 5 };
1818

1919
template <typename AllEntities> inline static bool skip(const AllEntities& in)
2020
{

barretenberg/cpp/src/barretenberg/vm2/generated/relations/internal_call_impl.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ void internal_callImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
2323
(in.get(C::execution_sel_execute_internal_call) + in.get(C::execution_sel_execute_internal_return)) *
2424
(FF(1) - in.get(C::execution_sel_error)) +
2525
in.get(C::execution_sel_exit_call);
26-
const auto execution_PROPAGATE_CALL_ID = ((FF(1) - execution_RESET_NEXT_CALL_ID) - execution_NEW_NEXT_CALL_ID);
27-
const auto execution_CONTEXT_CHANGE = ((execution_RESET_NEXT_CALL_ID + in.get(C::execution_sel_exit_call)) -
28-
execution_RESET_NEXT_CALL_ID * in.get(C::execution_sel_exit_call));
26+
const auto execution_RESET_OR_NEW_NEXT_CALL_ID = ((execution_RESET_NEXT_CALL_ID + execution_NEW_NEXT_CALL_ID) -
27+
execution_RESET_NEXT_CALL_ID * execution_NEW_NEXT_CALL_ID);
28+
const auto execution_PROPAGATE_CALL_ID = (FF(1) - execution_RESET_OR_NEW_NEXT_CALL_ID);
2929

3030
{ // CALL_ID_STARTS_ONE
3131
using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>;
@@ -82,7 +82,7 @@ void internal_callImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
8282
}
8383
{ // INCR_NEXT_INT_CALL_ID
8484
using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>;
85-
auto tmp = execution_NOT_LAST_EXEC * (FF(1) - execution_CONTEXT_CHANGE) *
85+
auto tmp = execution_NOT_LAST_EXEC * (FF(1) - execution_RESET_OR_NEW_NEXT_CALL_ID) *
8686
(in.get(C::execution_next_internal_call_id_shift) -
8787
(in.get(C::execution_next_internal_call_id) + in.get(C::execution_sel_execute_internal_call)));
8888
tmp *= scaling_factor;

yarn-project/bb-prover/src/avm_proving_tests/avm_check_circuit_amm.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { AvmProvingTester } from './avm_proving_tester.js';
99
const TIMEOUT = 300_000;
1010

1111
// TODO: unskip when check-circuit works for AMM. Confirm that it is fast enough to run in CI.
12-
describe.skip('AVM proven AMM', () => {
12+
describe('AVM proven AMM', () => {
1313
const logger = createLogger('avm-proven-tests-amm');
1414
const metrics = new TestExecutorMetrics();
1515
let tester: AvmProvingTester;

0 commit comments

Comments
 (0)