-
Notifications
You must be signed in to change notification settings - Fork 240
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
feat(avm/brillig)!: revert/rethrow oracle #9408
Merged
Merged
Changes from all commits
Commits
Show all changes
4 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 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 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 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 |
---|---|---|
|
@@ -2736,10 +2736,59 @@ std::vector<FF> AvmTraceBuilder::op_return(uint8_t indirect, uint32_t ret_offset | |
return returndata; | ||
} | ||
|
||
std::vector<FF> AvmTraceBuilder::op_revert(uint8_t indirect, uint32_t ret_offset, uint32_t ret_size) | ||
std::vector<FF> AvmTraceBuilder::op_revert(uint8_t indirect, uint32_t ret_offset, uint32_t ret_size_offset) | ||
{ | ||
// TODO: This opcode is still masquerading as RETURN. | ||
auto clk = static_cast<uint32_t>(main_trace.size()) + 1; | ||
|
||
// This boolean will not be a trivial constant once we re-enable constraining address resolution | ||
bool tag_match = true; | ||
|
||
auto [resolved_ret_offset, resolved_ret_size_offset] = | ||
Addressing<2>::fromWire(indirect, call_ptr).resolve({ ret_offset, ret_size_offset }, mem_trace_builder); | ||
const auto ret_size = static_cast<uint32_t>(unconstrained_read_from_memory(resolved_ret_size_offset)); | ||
|
||
gas_trace_builder.constrain_gas(clk, OpCode::RETURN, ret_size); | ||
|
||
// TODO: fix and set sel_op_revert | ||
return op_return(indirect, ret_offset, ret_size); | ||
if (ret_size == 0) { | ||
main_trace.push_back(Row{ | ||
.main_clk = clk, | ||
.main_call_ptr = call_ptr, | ||
.main_ib = ret_size, | ||
.main_internal_return_ptr = FF(internal_return_ptr), | ||
.main_pc = pc, | ||
.main_sel_op_external_return = 1, | ||
}); | ||
|
||
pc = UINT32_MAX; // This ensures that no subsequent opcode will be executed. | ||
return {}; | ||
} | ||
|
||
// The only memory operation performed from the main trace is a possible indirect load for resolving the | ||
// direct destination offset stored in main_mem_addr_c. | ||
// All the other memory operations are triggered by the slice gadget. | ||
if (tag_match) { | ||
returndata = mem_trace_builder.read_return_opcode(clk, call_ptr, resolved_ret_offset, ret_size); | ||
slice_trace_builder.create_return_slice(returndata, clk, call_ptr, resolved_ret_offset, ret_size); | ||
} | ||
|
||
main_trace.push_back(Row{ | ||
.main_clk = clk, | ||
.main_call_ptr = call_ptr, | ||
.main_ib = ret_size, | ||
.main_internal_return_ptr = FF(internal_return_ptr), | ||
.main_mem_addr_c = resolved_ret_offset, | ||
.main_pc = pc, | ||
.main_r_in_tag = static_cast<uint32_t>(AvmMemoryTag::FF), | ||
.main_sel_op_external_return = 1, | ||
.main_sel_slice_gadget = static_cast<uint32_t>(tag_match), | ||
.main_tag_err = static_cast<uint32_t>(!tag_match), | ||
.main_w_in_tag = static_cast<uint32_t>(AvmMemoryTag::FF), | ||
}); | ||
Comment on lines
+2776
to
+2788
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. Doesn't raise the main error flag? |
||
|
||
pc = UINT32_MAX; // This ensures that no subsequent opcode will be executed. | ||
return returndata; | ||
} | ||
|
||
/************************************************************************************************** | ||
|
This file contains 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 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 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 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 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 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no selector for revert?