@@ -153,11 +153,9 @@ pub(crate) comptime fn create_utility_stub(f: FunctionDefinition) -> Quoted {
153153 }
154154}
155155
156- // Self-call stub generation functions for CallSelf, CallSelfStatic, EnqueueSelf and EnqueueSelfStatic structs
157-
158- // Note: Unlike for the call registry, the self-call registry stubs directly perform the call instead of returning a
159- // call interface struct.
160- // TODO(F-131): This ^ is confusing and should be reflected in the naming.
156+ // Self-call stub generation functions for CallSelf, CallSelfStatic, EnqueueSelf, and EnqueueSelfStatic structs.
157+ // Unlike the stubs above, the self-call stubs directly perform the call instead of returning a struct that can
158+ // be later used to perform the call.
161159
162160/// Creates a stub for calling a private function (or static private function if `is_static` is true) from private
163161/// context (for CallSelf<&mut PrivateContext> and CallSelfStatic<&mut PrivateContext>).
@@ -183,18 +181,15 @@ pub comptime fn create_private_self_call_stub(f: FunctionDefinition, is_static:
183181 }
184182}
185183
186- // TODO(F-131): Drop the use of the Call in the following 4 functions - it doesn't make sense to not not
187- // perform the call directly using the context. I tried doing this already but it became a lot of pain due to the use of
188- // slices and them being illegal to return from unconstrained functions. Makes sense to tackle this when cleaning up the
189- // call interface code.
190- // Note: Once we get rid of the structs we will be able to merge some of the static and non-static stub functions.
191-
192184/// Creates a stub for calling a public function from public context (for CallSelf<PublicContext>)
193185pub comptime fn create_public_self_call_stub (f : FunctionDefinition ) -> Quoted {
194186 let (fn_name , fn_parameters_list , serialized_args_array_construction , serialized_args_array_name , _ , fn_name_str , _ , fn_selector ) =
195187 create_stub_base (f );
196188 let fn_return_type = f .return_type ();
197189
190+ // TODO: It makes sense to drop the use of PublicStaticCall struct here and just perform the call directly but
191+ // before doing that we need to drop the use of slices from return values because we cannot return slices from
192+ // an unconstrained function. This is not a priority right now.
198193 quote {
199194 pub fn $fn_name (self , $fn_parameters_list ) -> $fn_return_type {
200195 $serialized_args_array_construction
@@ -217,6 +212,9 @@ pub comptime fn create_public_self_call_static_stub(f: FunctionDefinition) -> Qu
217212 create_stub_base (f );
218213 let fn_return_type = f .return_type ();
219214
215+ // TODO: It makes sense to drop the use of PublicStaticCall struct here and just perform the call directly but
216+ // before doing that we need to drop the use of slices from return values because we cannot return slices from
217+ // an unconstrained function. This is not a priority right now.
220218 quote {
221219 pub fn $fn_name (self , $fn_parameters_list ) -> $fn_return_type {
222220 $serialized_args_array_construction
@@ -235,40 +233,44 @@ pub comptime fn create_public_self_call_static_stub(f: FunctionDefinition) -> Qu
235233
236234/// Creates a static stub for enqueuing a public view function from private context (for EnqueueSelfStatic<&mut PrivateContext>)
237235pub comptime fn create_public_self_enqueue_static_stub (f : FunctionDefinition ) -> Quoted {
238- let (fn_name , fn_parameters_list , serialized_args_array_construction , serialized_args_array_name , serialized_args_array_len , fn_name_str , fn_name_len , fn_selector ) =
236+ let (fn_name , fn_parameters_list , serialized_args_array_construction , serialized_args_array_name , _serialized_args_array_len , _fn_name_str , _fn_name_len , fn_selector ) =
239237 create_stub_base (f );
240238
241239 quote {
242240 pub fn $fn_name (self , $fn_parameters_list ) {
243241 $serialized_args_array_construction
244242 let selector = $FROM_FIELD ($fn_selector );
245- let interface : aztec::context::calls::PublicStaticCall <$fn_name_len , $serialized_args_array_len , ()> = aztec::context::calls::PublicStaticCall ::new (
243+ let calldata = [aztec::protocol_types::traits::ToField ::to_field (selector )].concat ($serialized_args_array_name );
244+ let calldata_hash = aztec::hash:: hash_calldata_array (calldata );
245+ aztec::oracle::execution_cache:: store (calldata , calldata_hash );
246+ self .context .call_public_function_with_calldata_hash (
246247 self .address ,
247- selector ,
248- $ fn_name_str ,
249- $ serialized_args_array_name ,
248+ calldata_hash ,
249+ /*is_static_call=*/ true ,
250+ /*hide_msg_sender=*/ false ,
250251 );
251- interface .enqueue_view (self .context );
252252 }
253253 }
254254}
255255
256256/// Creates a stub for enqueuing a public function from private context (for EnqueueSelf<&mut PrivateContext>)
257257pub comptime fn create_public_self_enqueue_stub (f : FunctionDefinition ) -> Quoted {
258- let (fn_name , fn_parameters_list , serialized_args_array_construction , serialized_args_array_name , serialized_args_array_len , fn_name_str , fn_name_len , fn_selector ) =
258+ let (fn_name , fn_parameters_list , serialized_args_array_construction , serialized_args_array_name , _serialized_args_array_len , _fn_name_str , _fn_name_len , fn_selector ) =
259259 create_stub_base (f );
260260
261261 quote {
262262 pub fn $fn_name (self , $fn_parameters_list ) {
263263 $serialized_args_array_construction
264264 let selector = $FROM_FIELD ($fn_selector );
265- let interface : aztec::context::calls::PublicCall <$fn_name_len , $serialized_args_array_len , ()> = aztec::context::calls::PublicCall ::new (
265+ let calldata = [aztec::protocol_types::traits::ToField ::to_field (selector )].concat ($serialized_args_array_name );
266+ let calldata_hash = aztec::hash:: hash_calldata_array (calldata );
267+ aztec::oracle::execution_cache:: store (calldata , calldata_hash );
268+ self .context .call_public_function_with_calldata_hash (
266269 self .address ,
267- selector ,
268- $ fn_name_str ,
269- $ serialized_args_array_name ,
270+ calldata_hash ,
271+ /*is_static_call=*/ false ,
272+ /*hide_msg_sender=*/ false ,
270273 );
271- interface .enqueue (self .context );
272274 }
273275 }
274276}
0 commit comments