-
Notifications
You must be signed in to change notification settings - Fork 284
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
Support public function calls from private functions #447
Comments
@iAmMichaelConnor I think that the semantics of
However, we cannot get the results of nested public executions as outputs of the private circuit, since these are enqueued to be run later in the sequencer. Instead, interface PublicExecution {
/** Address of the contract being executed. */
contractAddress: AztecAddress;
/** Function of the contract being called. */
functionData: FunctionData;
/** Arguments for the call. */
args: Fr[];
/** Context of the call. */
callContext: CallContext;
} (note we can possible trim down many of these fields and recalculate them on the sequencer, but that's another story) These request preimages would be sent to the sequencer, which should run them through the VM public circuit and get the actual Does this make sense? If so, should we rename |
My mental model was that the Although, re-reading, your suggestion also has a single
I'm still not sure on some details of your proposal. Suppose a private function A enqueues public function requests B, C, D. Then suppose B makes pulic function calls to E, F, G (just so that there are both kinds of calls on the stack). The Public Kernel Circuit will need to copy the
We don't have this problem for calls to E, F, G, because the return values can be populated by their calling function B. I suppose my approach has 'bugs', though. If we unified the Maybe a boolean I rambled. Good topic for our call later. I do like your suggestion of only sending the data that's actually needed, because it makes the code much easier to follow. I just have some 'question marks' over how it'll work. |
Summarizing today's discussion with @iAmMichaelConnor: out of the private circuit, we'll get public_call_stack_items where most of the struct is empty. Only contract_address, function_signature, args, and call_context should be set, which should be equivalent to the This will reduce the number of conditionals in the circuit, and get an initial version working faster since we won't need to alter the structs. We'll need to dig into the public kernel circuit to see what changes would be needed to handle this case, if any. Note that removing the "outputs" of an execution (return_values, etc) from all call stack items is not viable, since a call may use the return values from a call stack item, so these are needed for the general case of a public function calling another public function (or private calling private). The only scenario in which they can be safely ignored is this one, since return values from async enqueued public calls cannot be used. |
So this is effectively going down the road of storing the hashes of the 'requests' where the struct is bridging between private and public executions? But in a way that doesn't mean we introduce a load of new data structures solely for that purpose. |
Yup. We are using the same data structures as we have today, only we change their semantic when it is an enqueued public function call request. |
Private functions should be able to "enqueue" a call to a private function. These are different to calls from private to private or public to public, since they won't be synchronous nor return any value, but rather just populate the public call stack to be emptied by the sequencer.
To implement this, we'd need a new oracle function that takes care of enqueuing the function call. Note that it'll have to be different from the one for #430 since this one won't return anything. This will just populate the
public_call_stack
of thePrivateCircuitPublicInputs
. The private kernel circuit should just forward the contents of the public call stack from its inputs to its outputs, so they can be later picked up on the sequencer.We'll also need to augment the Tx object sent to the P2P module to include the public call stack preimages. Right now, the private kernel circuit output only includes the hashes of the call stack items, but in order to process the public calls, we'll need the preimages. These preimages are only known to the private simulator, so they'll need to be pushed from the client to the sequencer.
Once the
PublicProcessor
picks up a tx with apublic_call_stack
, it should run those calls through the public function simulator, and then through the public kernel circuit.The text was updated successfully, but these errors were encountered: