-
Notifications
You must be signed in to change notification settings - Fork 599
feat: constrain call #13758
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
Merged
Merged
feat: constrain call #13758
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,85 @@ | ||
| // This is a virtual gadget, which is part of the execution trace. | ||
| namespace execution; | ||
|
|
||
| // This the same sel as in execution | ||
| #[skippable_if] | ||
| sel = 0; | ||
|
|
||
| // Useful to define some opcodes within this pil file | ||
| // Constrained to be boolean by execution instruction spec table | ||
| pol commit sel_call; | ||
| pol commit sel_static_call; | ||
| pol CALL = sel_call + sel_static_call; // Guaranteed to be mutually exclusive | ||
| // CALL & precomputed.first_row are NAND | ||
| CALL * precomputed.first_row = 0; | ||
fcarreiro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Context columns | ||
| pol commit context_id; | ||
| pol commit parent_id; | ||
| pol commit pc; | ||
| pol commit next_pc; | ||
| pol commit msg_sender; | ||
| pol commit contract_address; | ||
|
|
||
| // Constrained boolean by tx trace (for enqueued call) and #[NEXT_IS_STATIC] for nested | ||
| pol commit is_static; | ||
| is_static * (1 - is_static) = 0; | ||
|
|
||
| pol commit parent_calldata_offset_addr; | ||
| pol commit parent_calldata_size_addr; | ||
|
|
||
| pol commit last_child_returndata_offset_addr; | ||
| pol commit last_child_returndata_size_addr; | ||
| pol commit last_child_success; // Careful with this for now... | ||
|
|
||
| // ==== Helper columns ==== | ||
| // TODO: These context modifiers also need to factor in when a new enqueued call occurs | ||
| // REPLACE prefixed precomputed.first_row in relations with actual phase / enqueued call change | ||
| pol NOT_FIRST = (1 - precomputed.first_row); // Temp | ||
|
|
||
| // next_context_id increments with each invocation of an external call or new enqueued call | ||
| pol commit next_context_id; // Can be replaced by clk | ||
| // The initial next_context_id = 2, in row = 1 | ||
| #[INCR_CONTEXT_ID] | ||
| NOT_FIRST * sel' * (next_context_id' - (next_context_id + CALL)) = 0; | ||
|
|
||
| // CALL = 1 <==> context_id' = next_context_id | ||
| // CALL = 0 <==> context_id' = context_id | ||
IlyasRidhuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #[NEXT_CONTEXT_ID] | ||
| NOT_FIRST * sel' * ((next_context_id - context_id) * CALL + context_id + precomputed.first_row - context_id') = 0; | ||
|
|
||
| // CALL = 1 <==> parent_id' = context_id | ||
| // CALL = 0 <==> parent_id' = parent_id | ||
IlyasRidhuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #[NEXT_PARENT_ID] | ||
| NOT_FIRST * sel' * ((context_id - parent_id) * (CALL + precomputed.first_row) + parent_id - parent_id') = 0; | ||
|
|
||
| // CALL = 1 <==> pc' = 0 | ||
| // CALL = 0 <==> pc' = next_pc | ||
| #[NEXT_PC] | ||
| NOT_FIRST * sel' * (pc' - ((1 - CALL) * next_pc)) = 0; | ||
|
|
||
| // CALL = 1 <==> msg_sender' = contract_address | ||
| // CALL = 0 <==> msg_sender' = msg_sender | ||
| #[NEXT_MSG_SENDER] | ||
| NOT_FIRST * sel' * ((contract_address - msg_sender) * CALL + msg_sender - msg_sender') = 0; | ||
|
|
||
| // CALL = 1 <==> contract_address' = reg3 (intermediate register 3 from execution trace) | ||
| // CALL = 0 <==> contract_address' = contract_address | ||
| #[NEXT_CONTRACT_ADDR] | ||
| NOT_FIRST * sel' * ((reg3 - contract_address) * CALL + contract_address - contract_address') = 0; | ||
|
|
||
| // CALL = 1 && static_call = 1 <==> is_static' = 1 | ||
| // CALL = 1 && static_call = 0 <==> is_static' = 0 | ||
| // CALL = 0 && static_call = 0 <==> is_static' = is_static | ||
| #[NEXT_IS_STATIC] | ||
| NOT_FIRST * sel' * (is_static' - (sel_static_call + (1 - CALL) * is_static)) = 0; | ||
|
|
||
| // CALL = 1 <==> parent_calldata_offset_addr' = rop4 (resolved operand 4 from execution trace) | ||
| // CALL = 0 <==> parent_calldata_offset_addr' = parent_calldata_offset_addr | ||
| #[NEXT_CD_OFFSET] | ||
| NOT_FIRST * sel' * ((rop4 - parent_calldata_offset_addr) * CALL + parent_calldata_offset_addr - parent_calldata_offset_addr') = 0; | ||
|
|
||
| // CALL = 1 <==> parent_calldata_size_addr' = rop5 (resolved operand 5 from execution trace) | ||
| // CALL = 0 <==> parent_calldata_size_addr' = parent_calldata_size_addr | ||
| #[NEXT_CD_SIZE] | ||
| NOT_FIRST * sel' * ((rop5 - parent_calldata_size_addr) * CALL + parent_calldata_size_addr - parent_calldata_size_addr') = 0; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,11 @@ | ||
| namespace context_stack; | ||
|
|
||
| pol commit context_id; | ||
| pol commit pc; | ||
| pol commit parent_id; | ||
| pol commit next_pc; | ||
| pol commit msg_sender; | ||
| pol commit contract_address; | ||
|
|
||
| pol commit is_static; | ||
| is_static * (1 - is_static) = 0; | ||
|
|
||
| pol commit parent_calldata_offset_addr; | ||
| pol commit parent_calldata_size_addr; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,10 @@ include "nullifier_check.pil"; | |
| namespace execution; | ||
|
|
||
| pol commit sel; // subtrace selector | ||
|
|
||
| #[skippable_if] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ohh we didn't have this |
||
| sel = 0; | ||
|
|
||
| // Subtrace operation id | ||
| pol commit subtrace_operation_id; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
barretenberg/cpp/src/barretenberg/vm2/generated/relations/context_stack.hpp
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.