Skip to content

fix(avm)!: pre-audit review of context.pil#19549

Merged
jeanmon merged 32 commits into
merge-train/avmfrom
jean/avm-44-execution-contextpil
Jan 14, 2026
Merged

fix(avm)!: pre-audit review of context.pil#19549
jeanmon merged 32 commits into
merge-train/avmfrom
jean/avm-44-execution-contextpil

Conversation

@jeanmon

@jeanmon jeanmon commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

Linear issue: AVM-44

@jeanmon jeanmon marked this pull request as ready for review January 13, 2026 14:21
@jeanmon jeanmon requested review from dbanks12 and removed request for IlyasRidhuan, Maddiaa0 and fcarreiro January 13, 2026 14:21
@AztecBot

AztecBot commented Jan 13, 2026

Copy link
Copy Markdown
Collaborator

Flakey Tests

🤖 says: This CI run detected 5 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (8;;http://ci.aztec-labs.com/cfd821ffe607aa65�cfd821ffe607aa658;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_epochs/epochs_invalidate_block.parallel.test.ts "committee member invalidates a block if proposer does not come through" (94s) (code: 1) group:e2e-p2p-epoch-flakes (\033jeanmon\033: Remove an old TODO)
\033FLAKED\033 (8;;http://ci.aztec-labs.com/26ca0f527967dca1�26ca0f527967dca18;;�): yarn-project/end-to-end/scripts/run_test.sh web3signer src/composed/web3signer/e2e_multi_validator_node_key_store.test.ts (37s) (code: 1) (\033jeanmon\033: Remove an old TODO)
\033FLAKED\033 (8;;http://ci.aztec-labs.com/2389817d9fac43eb�2389817d9fac43eb8;;�): yarn-project/scripts/run_test.sh stdlib/src/p2p/topics.test.ts (2s) (code: 1) group:e2e-p2p-epoch-flakes (\033jeanmon\033: Remove an old TODO)
\033FLAKED\033 (8;;http://ci.aztec-labs.com/922ef617f8ecd480�922ef617f8ecd4808;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_p2p/gossip_network.test.ts (433s) (code: 1) group:e2e-p2p-epoch-flakes (\033jeanmon\033: Remove an old TODO)
\033FLAKED\033 (8;;http://ci.aztec-labs.com/0eec33bbca504682�0eec33bbca5046828;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_epochs/epochs_invalidate_block.parallel.test.ts "proposer invalidates multiple blocks" (603s) (code: 124) group:e2e-p2p-epoch-flakes (\033jeanmon\033: Remove an old TODO)

@dbanks12 dbanks12 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice work!

Comment on lines +131 to +138
// Selectors related to exiting a nested context
pol commit nested_return; // @boolean (by definition)
nested_return = has_parent_ctx * sel_execute_return;
pol commit nested_failure; // @boolean (by definition)
nested_failure = has_parent_ctx * sel_failure;
// Since `sel_exit_call = sel_failure + sel_execute_return`, we can define the following alias
// to characterize exiting from a nested context.
pol NESTED_EXIT_CALL = nested_failure + nested_return; // = has_parent_ctx * sel_exit_call;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it true that sel_execute_return can only be 1 if there has been no failure? The opcode cannot fail during its execution?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, this comes from #[INFALLIBLE_OPCODES_SUCCESS] and this explanation is present before the definition of sel_exit_call.
We use this property a lot. Basically, when an opcode selector is turned on in execution, it means that the only error which might occur is an opcode error. #[INFALLIBLE_OPCODES_SUCCESS] prevents to turn on this error for those we know will not fail such as RETURN.

Comment thread barretenberg/cpp/pil/vm2/context.pil Outdated
// Initialization: enqueued_call_start = 1 ==> parent_calldata_addr = 0;
// Propagation:
// NESTED_EXIT_CALL = 1 ==> constraints come from lookups (#[CTX_STACK_ROLLBACK] and #[CTX_STACK_RETURN])
// sel_enter_call = 1 ==> parent_calldata_addr' = rop[4] (resolved operand 5 from execution trace)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just confirming that rop[4] does indeed correspond to resolved operand 5, or is this a typo?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments were already present and are all "incrementing the index by one" because humans like to start by index one. I think it is misleading and will remove such indices in the comment and just keep "from execution trace".

Comment thread barretenberg/cpp/pil/vm2/context.pil Outdated
// RETRIEVED BYTECODES TREE
// =============================

// Here, we constrain the transition `retrieved_bytecodes_tree_root` to `prev_retrieved_bytecodes_tree_size`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This confuses me. Why would retrieved_*root transition to prev_*root? And i think you have a typo here because you say *root to *size

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh we're not really transitioning? We're saying "on the next row, make sure that prev_*root points to this row's root? I'd reword to make clearer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rephrased this.

Comment thread barretenberg/cpp/pil/vm2/context.pil Outdated
Comment on lines +541 to +544
// The state of the retrieved bytecodes tree should be continuous unless we have finished an enqueued call.
// `prev_retrieved_bytecodes_tree_root` and `prev_retrieved_bytecodes_tree_size` are initialized
// on `enqueued_call_start == 1` as part of the permutation (#[DISPATCH_EXEC_START] in tx.pil).
// The final values at the end of an enqueued call are sent back to the tx trace in the lookup #[DISPATCH_EXEC_END].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean for the bytecodes tree to be continuous? I'd clarify that it can evolve during an enqueued call as bytecodes are retrieved. And then we don't actually constrain that it propagates in context.pil at enqueued-call boundaries because it is sent-back and initialized like you say. Maybe just clarify the meaning of continuous.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added clarifications on what we mean by continuous.

Comment thread barretenberg/cpp/pil/vm2/context.pil Outdated
Comment on lines 38 to 39
pol commit transaction_fee;
// Constrained boolean by tx trace for enqueued call, #[IS_STATIC_NEXT_ROW] during normal execution,
// IS_STATIC_IF_STATIC_CALL+IS_STATIC_IF_CALL_FROM_STATIC_CONTEXT for nested calls,
// and CTX_STACK_CALL for returns or failures.
pol commit is_static;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove comment? Is it made clear elsewhere?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you add @boolean with a note later, although it doesn't specify exactly how is_static is constrained to be bool

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some explanations.

@jeanmon jeanmon force-pushed the jean/avm-44-execution-contextpil branch 3 times, most recently from 576d813 to ad16c1c Compare January 14, 2026 14:38
@jeanmon jeanmon force-pushed the jean/avm-44-execution-contextpil branch from ad16c1c to 81a7651 Compare January 14, 2026 15:13
@jeanmon jeanmon merged commit 18d05a3 into merge-train/avm Jan 14, 2026
8 checks passed
@jeanmon jeanmon deleted the jean/avm-44-execution-contextpil branch January 14, 2026 15:46
@AztecBot AztecBot mentioned this pull request Jan 14, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Jan 14, 2026
BEGIN_COMMIT_OVERRIDE
fix(avm): Fix relative addressing in fuzzer (#19550)
feat(avm): avm fuzzer bytecode mutation (#19378)
chore(avm): there is automatic conversion from uint128_t to FF
chore(avm): ECC pre-audit - normalise infinity points (#19462)
feat(bb-pilcom): single-component graph check (#19578)
feat(avm): contract class mutation (#19498)
chore: support uint128_t in uint256_t construction (#19581)
fix!: remove unused column in update_check.pil (#19557)
fix(avm)!: pre-audit review of context.pil (#19549)
fix(avm): Relax fuzzer memory manager asserts (#19591)
fix!: sha256.pil missing input propagation constraints (#19590)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants