feat: process designated teardown function call#6244
Conversation
|
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @just-mitch and the rest of your teammates on |
226f621 to
60bbd5d
Compare
Docs PreviewHey there! 👋 You can check your preview at https://663d2d3f143d0349f0976b3c--aztec-docs-dev.netlify.app |
e2f0bdb to
2f517be
Compare
2f517be to
d47e180
Compare
| @@ -88,14 +88,15 @@ impl PublicKernelTeardownCircuitPrivateInputs { | |||
| self.validate_inputs(); | |||
There was a problem hiding this comment.
Now that we have different stacks for different phases, we can re-enable this check in validate_inputs:
assert(needs_setup == false)
yarn-project/Earthfile
Outdated
| ARG debug="" | ||
| FROM +end-to-end | ||
| RUN DEBUG=aztec:* yarn test $test | ||
| RUN DEBUG=$DEBUG yarn test $test |
| export function collectPublicTeardownFunctionCall(execResult: ExecutionResult): PublicCallRequest { | ||
| const teardownCalls = [ | ||
| execResult.publicTeardownFunctionCall, | ||
| ...[...execResult.nestedExecutions].flatMap(collectPublicTeardownFunctionCall), |
There was a problem hiding this comment.
...execResult.nestedExecutions.flatMap().
This is probably copied from the function above, which is also overdone 😂
There was a problem hiding this comment.
I cleaned them up a little!
|
|
||
| const teardownCallStackLength = arrayNonEmptyLength(data.publicTeardownCallStack, f => f.isEmpty()); | ||
|
|
||
| const teardownCallStack = teardownCallStackLength === 0 ? [] : [tx.publicTeardownFunctionCall]; |
There was a problem hiding this comment.
Can it be const teardownCallStack = !tx.publicTeardownFunctionCall.isEmpty() ? [tx.publicTeardownFunctionCall] : []?
Using the length to create the stack makes it look like something is wrong: the length might be larger than 1 (although it won't be) but the array will only contain at most 1 item.
d47e180 to
575caab
Compare
...ocol-circuits/crates/private-kernel-lib/src/private_kernel_circuit_public_inputs_composer.nr
Show resolved
Hide resolved
noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr
Outdated
Show resolved
Hide resolved
...ts/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs.nr
Outdated
Show resolved
Hide resolved
...ts/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs.nr
Outdated
Show resolved
Hide resolved
fc7a463 to
968ecf7
Compare
0aabf76 to
19aea2e
Compare

Deviations from the spec:
I needed to create a new stack for processing the teardown calls, instead of storing a single call. I.e.
class PublicKernelCircuitPublicInputs { // ... other fields --- +CallRequest public_teardown_call_request +++ +CallRequest[MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX] public_teardown_call_stack }This is because a teardown function can call a nested function, and, similar to the current design for public/private calls,
we need a way to keep track of our execution stack.
Further, in order to pass in the CallRequest to the private kernel circuits, I needed to add a new parameter to the PrivateCallData.
Overview
We designate a function to be run for teardown as:
As I note in a comment, I created #6277 for getting back to something like:
This sets
publicTeardownFunctionCall: PublicCallRequestin the encapsulatingClientExecutionContext, which defaults toPublicCallRequest.empty().When private simulation is finished, we collect an array of all the public teardown functions that were set during the simulation.
We assert that the length of that array is 0 or 1.
When proving, we convert the
publicTeardownFunctionCallto aCallRequestif it is not empty, otherwise we useCallRequest.empty().This is specified in the
PrivateCallDatawhich is passed to the private kernel circuit.In the private kernel circuits, we assert that if the
public_teardown_function_hashis not zero on thePrivateCircuitPublicInputs, then it matches the hash of thepublicTeardownFunctionCallin thePrivateCallData.Further, we assert that if the teardown call request in the
PrivateCallDatais not empty, then the teardown call request from the previous kernel is empty.In the private kernel tail, we assert that the public teardown call request is empty.
In private kernel tail to public, we initialize the teardown call stack to have the single element corresponding to the call request if it is not empty, and initialize it to an empty array otherwise.
Since teardown now has its own stack, we update the logic for how to know when we are in the different phases to simply look at each of their stacks:
Note:
This does not change the fact that teardown is still non-revertible. That is covered by #5924