-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: non revertible effects and tx phases (#4629)
There are 3 primary changes in this PR. 1. Within the private kernel tail, split the side effects that have been accumulated during private execution into `end`, and `end_non_revertible` based on their side effect counters compared with `min_revertible_side_effect_counter`. 2. Examine those structs on the sequencer and run circuits for setup, app logic, and teardown accordingly. 3. Recombine `end` and `end_non_revertible` at the beginning of the rollup base. To accomplish this, new structs are introduced. `CombinedAccumulatedData` is unchanged, and holds side effects that are both revertible and non-revertible. For this reason, it is part of `PrivateKernelInnerCircuitPublicInputs`, and `RollupKernelCircuitPublicInputs`. `PrivateKernelTailCircuitPublicInputs` has been updated to hold ``` end_non_revertible: PrivateAccumulatedNonRevertibleData, end: PrivateAccumulatedRevertibleData, ``` and `PublicKernelCircuitPublicInputs` has been updated to hold ``` end_non_revertible: PublicAccumulatedNonRevertibleData, end: PublicAccumulatedRevertibleData, ``` The difference between `PrivateAccumulated` and `PublicAccumulated` is that the `Private` flavors cannot hold `public_data_update_requests` or `public_data_reads`. Additionally, for the types of side effects that can be non-revertible (which at present are commitments, nullifiers, public data updates, public data reads), there are new constants defined, e.g. `MAX_NON_REVERTIBLE_COMMITMENTS_PER_TX` and `MAX_REVERTIBLE_COMMITMENTS_PER_TX`. These two sizes must sum to `MAX_NEW_COMMITMENTS_PER_TX`, and similarly for the other types. Thus, the bulk of the added work done by circuits is performed in `combined_accumulated_data.nr`. We expect there are significant optimizations that can be made to our initial implementation of splitting and recombining. Note, the decision was made to recombine in the base rollup to reduce conditional logic and reuse existing machinery that wants to look at a single `CombinedAccumulatedData`. Further, it made architectural sense in that the rollup should not need to know/care that certain e.g. nullifiers submitted were `nonRevertible`: it received the nullifiers, thus they must not have reverted. The recombine could have been performed by the public kernel, but we didn't want to add an obligatory circuit for the sequencer if, e.g. they were submitted a fully private transaction (since they would always be obliged to recombine the TX nullifier which is now part of the non-revertible side effects). To handle the non revertible side effects, we repurposed the public kernel circuits to correspond with the "phases" of a transaction: 1. setup 2. app logic 3. teardown In order to ensure that the phases are correctly followed, we introduce 3 more members to `PrivateKernelTailCircuitPublicInputs` and `PublicKernelCircuitPublicInputs`: ``` needs_setup: bool, // true if there is more than 1 enqueued non-revertible public call needs_app_logic: bool, // true if there is more than 0 enqueued revertible public calls needs_teardown: bool, // true if there is more than 0 enqueued non-revertible public calls ``` The semantic is that for enqueued non-revertible public calls, the call that is enqueued last is for teardown (e.g. pay the fee), and all other are for setup (e.g. engage with some fee payment contract). See `AbstractPhaseManager.extractEnqueuedPublicCallsByPhase`. Note further that we haven't added new e2e tests here, as the interface for using this is sitting in [this PR](#4543) Co-authored-by: Alex Gherghisan <[email protected]>
- Loading branch information
1 parent
9e09772
commit c04d72f
Showing
84 changed files
with
4,358 additions
and
3,981 deletions.
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
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.