-
Notifications
You must be signed in to change notification settings - Fork 598
feat!: constrain discarding of side-effects for tx-level operations in AVM #16258
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
Changes from all commits
Commits
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /** | ||
| * Discarding on error for tx-level operations. | ||
| * | ||
| * Design Document: https://docs.google.com/document/d/1xz5sZSxTu841K8uvnT8U-nO2X5ZjY8o0TjOYKfT9b6o | ||
| * | ||
| * This subtrace is focused on managing the changes to the discard column. | ||
| * It is a virtual gadget, which is part of the execution trace. | ||
| * | ||
| * 1. Propagate discard by default. | ||
| * 2. Discard and reverted must be 0 for all rows of startup, non-revertibles, setup, fee-payment/tree-padding/cleanup. | ||
| * 3. If reverted is 1, discard must be 1. | ||
| * 4. Lift/relax propagation only in either of the following two scenarios: | ||
| * * A revert is encountered. | ||
| * * End of setup is encountered. | ||
| */ | ||
| namespace tx; // virtual to tx.pil | ||
| // No relations will be checked if this identity is satisfied. | ||
| #[skippable_if] | ||
| sel = 0; // from tx.pil. | ||
|
|
||
| pol commit discard; | ||
| discard * (1 - discard) = 0; | ||
|
|
||
| // If discard == 1, is_revertible must be 1 | ||
| // Can ONLY discard during revertible phases (revertible insertions, app-logic, teardown) | ||
| #[CAN_ONLY_DISCARD_IN_REVERTIBLE_PHASES] | ||
| discard * (1 - is_revertible) = 0; | ||
|
|
||
| // If failure == 1, discard must be 1 | ||
| #[FAILURE_MUST_DISCARD] | ||
| reverted * (1 - discard) = 0; | ||
|
|
||
| // By default, discard's value is propagated to the next row. | ||
| // Lift/relax propagation of discard to the next row if: | ||
| // 1. A failure (reverted == 1) occurs in the current row. | ||
| // 2. This row is the last row of SETUP. | ||
| // | ||
| // We can know that this row is the "last row of setup" iff: | ||
| // a. The current row is NOT revertible: `is_revertible == 0` | ||
| // b. AND the next row _is_ revertible: `is_revertible' == 1` | ||
|
|
||
| pol LAST_ROW_OF_SETUP = (1 - is_revertible) * (is_revertible'); | ||
| pol PROPAGATE_DISCARD = (1 - LAST_ROW_OF_SETUP) * (1 - reverted); | ||
|
|
||
| // If propagate_discard == 1, discard' = discard. | ||
| #[DISCARD_PROPAGATION] | ||
| sel * PROPAGATE_DISCARD * (discard' - discard) = 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
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.
sad