Skip to content

Commit e7e6e48

Browse files
committed
feat(avm)!: enable amm check circuit
1 parent 8cd0d2e commit e7e6e48

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

barretenberg/cpp/pil/vm2/context.pil

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

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

133133
// nested_exit_call = 1 ==> context_id' = parent_id
134134
// 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
@@ -19,7 +19,9 @@ namespace execution;
1919
// When we encounter this case, the internal call information in the next row is constrained to change (incremented, unwound, etc)
2020
pol NEW_NEXT_CALL_ID = (sel_execute_internal_call + sel_execute_internal_return) * (1 - sel_error) + sel_exit_call;
2121

22-
pol PROPAGATE_CALL_ID = 1 - RESET_NEXT_CALL_ID - NEW_NEXT_CALL_ID;
22+
// This is an XOR
23+
pol RESET_OR_NEW_NEXT_CALL_ID = (RESET_NEXT_CALL_ID + NEW_NEXT_CALL_ID) - (RESET_NEXT_CALL_ID * NEW_NEXT_CALL_ID);
24+
pol PROPAGATE_CALL_ID = 1 - RESET_OR_NEW_NEXT_CALL_ID;
2325

2426
// =============================
2527
// === Internal Call Pointer ===
@@ -57,9 +59,8 @@ namespace execution;
5759
#[NEXT_CALL_ID_STARTS_TWO]
5860
RESET_NEXT_CALL_ID * (next_internal_call_id' - 2) = 0;
5961
// If we encounter a sel_execute_internal_call, we increment the next next_internal_call_id, unless we are changing context
60-
pol CONTEXT_CHANGE = (RESET_NEXT_CALL_ID + sel_exit_call) - (RESET_NEXT_CALL_ID * sel_exit_call) ;
6162
#[INCR_NEXT_INT_CALL_ID]
62-
NOT_LAST_EXEC * (1 - CONTEXT_CHANGE) * (next_internal_call_id' - (next_internal_call_id + sel_execute_internal_call)) = 0;
63+
NOT_LAST_EXEC * (1 - RESET_OR_NEW_NEXT_CALL_ID) * (next_internal_call_id' - (next_internal_call_id + sel_execute_internal_call)) = 0;
6364

6465
// =============================
6566
// === 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
@@ -91,7 +91,8 @@ void contextImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
9191
using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>;
9292
auto tmp =
9393
execution_NOT_LAST_EXEC * (in.get(C::execution_next_context_id_shift) -
94-
(in.get(C::execution_next_context_id) + in.get(C::execution_sel_enter_call)));
94+
(in.get(C::execution_next_context_id) + in.get(C::execution_sel_enter_call) +
95+
in.get(C::execution_enqueued_call_start_shift)));
9596
tmp *= scaling_factor;
9697
std::get<7>(evals) += typename Accumulator::View(tmp);
9798
}

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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { AvmProvingTester } from './avm_proving_tester.js';
1010

1111
const TIMEOUT = 300_000;
1212

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

0 commit comments

Comments
 (0)