diff --git a/authwit/src/entrypoint/app.nr b/authwit/src/entrypoint/app.nr index 49a22da..71936bc 100644 --- a/authwit/src/entrypoint/app.nr +++ b/authwit/src/entrypoint/app.nr @@ -58,9 +58,19 @@ impl AppPayload { for call in self.function_calls { if !call.target_address.is_zero() { if call.is_public { - context.call_public_function_with_packed_args(call.target_address, call.function_selector, call.args_hash); + context.call_public_function_with_packed_args( + call.target_address, + call.function_selector, + call.args_hash, + false + ); } else { - let _result = context.call_private_function_with_packed_args(call.target_address, call.function_selector, call.args_hash); + let _result = context.call_private_function_with_packed_args( + call.target_address, + call.function_selector, + call.args_hash, + false + ); } } } diff --git a/authwit/src/entrypoint/fee.nr b/authwit/src/entrypoint/fee.nr index 3183302..20b0724 100644 --- a/authwit/src/entrypoint/fee.nr +++ b/authwit/src/entrypoint/fee.nr @@ -54,9 +54,19 @@ impl FeePayload { for call in self.function_calls { if !call.target_address.is_zero() { if call.is_public { - context.call_public_function_with_packed_args(call.target_address, call.function_selector, call.args_hash); + context.call_public_function_with_packed_args( + call.target_address, + call.function_selector, + call.args_hash, + false + ); } else { - let _result = context.call_private_function_with_packed_args(call.target_address, call.function_selector, call.args_hash); + let _result = context.call_private_function_with_packed_args( + call.target_address, + call.function_selector, + call.args_hash, + false + ); } } } diff --git a/aztec/src/context/private_context.nr b/aztec/src/context/private_context.nr index 0e3d7fa..d7f63f0 100644 --- a/aztec/src/context/private_context.nr +++ b/aztec/src/context/private_context.nr @@ -249,7 +249,18 @@ impl PrivateContext { ) -> [Field; RETURN_VALUES_LENGTH] { let args_hash = hash_args(args); assert(args_hash == arguments::pack_arguments(args)); - self.call_private_function_with_packed_args(contract_address, function_selector, args_hash) + self.call_private_function_with_packed_args(contract_address, function_selector, args_hash, false) + } + + pub fn call_private_function_static( + &mut self, + contract_address: AztecAddress, + function_selector: FunctionSelector, + args: [Field; ARGS_COUNT] + ) -> [Field; RETURN_VALUES_LENGTH] { + let args_hash = hash_args(args); + assert(args_hash == arguments::pack_arguments(args)); + self.call_private_function_with_packed_args(contract_address, function_selector, args_hash, true) } pub fn call_private_function_no_args( @@ -257,20 +268,30 @@ impl PrivateContext { contract_address: AztecAddress, function_selector: FunctionSelector ) -> [Field; RETURN_VALUES_LENGTH] { - self.call_private_function_with_packed_args(contract_address, function_selector, 0) + self.call_private_function_with_packed_args(contract_address, function_selector, 0, false) + } + + pub fn call_private_function_no_args_static( + &mut self, + contract_address: AztecAddress, + function_selector: FunctionSelector + ) -> [Field; RETURN_VALUES_LENGTH] { + self.call_private_function_with_packed_args(contract_address, function_selector, 0, true) } - pub fn call_private_function_with_packed_args( + fn call_private_function_with_packed_args( &mut self, contract_address: AztecAddress, function_selector: FunctionSelector, - args_hash: Field + args_hash: Field, + is_static_call: bool ) -> [Field; RETURN_VALUES_LENGTH] { let item = call_private_function_internal( contract_address, function_selector, args_hash, - self.side_effect_counter + self.side_effect_counter, + is_static_call ); assert_eq(item.public_inputs.call_context.start_side_effect_counter, self.side_effect_counter); @@ -286,7 +307,7 @@ impl PrivateContext { // the msg_sender in the nested call to be equal to our address, and the execution context address // for the nested call to be equal to the address we actually called. assert(item.public_inputs.call_context.is_delegate_call == false); - assert(item.public_inputs.call_context.is_static_call == false); + assert(item.public_inputs.call_context.is_static_call == is_static_call); assert(item.public_inputs.call_context.is_contract_deployment == false); assert( item.public_inputs.call_context.msg_sender.eq(self.inputs.call_context.storage_contract_address) @@ -306,7 +327,18 @@ impl PrivateContext { ) { let args_hash = hash_args(args); assert(args_hash == arguments::pack_arguments(args)); - self.call_public_function_with_packed_args(contract_address, function_selector, args_hash) + self.call_public_function_with_packed_args(contract_address, function_selector, args_hash, false) + } + + pub fn call_public_function_static( + &mut self, + contract_address: AztecAddress, + function_selector: FunctionSelector, + args: [Field; ARGS_COUNT] + ) { + let args_hash = hash_args(args); + assert(args_hash == arguments::pack_arguments(args)); + self.call_public_function_with_packed_args(contract_address, function_selector, args_hash, true) } pub fn call_public_function_no_args( @@ -314,20 +346,30 @@ impl PrivateContext { contract_address: AztecAddress, function_selector: FunctionSelector ) { - self.call_public_function_with_packed_args(contract_address, function_selector, 0) + self.call_public_function_with_packed_args(contract_address, function_selector, 0, false) + } + + pub fn call_public_function_no_args_static( + &mut self, + contract_address: AztecAddress, + function_selector: FunctionSelector + ) { + self.call_public_function_with_packed_args(contract_address, function_selector, 0, true) } pub fn call_public_function_with_packed_args( &mut self, contract_address: AztecAddress, function_selector: FunctionSelector, - args_hash: Field + args_hash: Field, + is_static_call: bool ) { let fields = enqueue_public_function_call_internal( contract_address, function_selector, args_hash, - self.side_effect_counter + self.side_effect_counter, + is_static_call ); let mut reader = Reader::new(fields); @@ -370,7 +412,7 @@ impl PrivateContext { // the msg_sender in the nested call to be equal to our address, and the execution context address // for the nested call to be equal to the address we actually called. assert(item.public_inputs.call_context.is_delegate_call == false); - assert(item.public_inputs.call_context.is_static_call == false); + assert(item.public_inputs.call_context.is_static_call == is_static_call); assert(item.public_inputs.call_context.is_contract_deployment == false); assert( item.public_inputs.call_context.msg_sender.eq(self.inputs.call_context.storage_contract_address) diff --git a/aztec/src/context/public_context.nr b/aztec/src/context/public_context.nr index aec62ab..b20c036 100644 --- a/aztec/src/context/public_context.nr +++ b/aztec/src/context/public_context.nr @@ -193,7 +193,28 @@ impl PublicContext { ) -> [Field; RETURN_VALUES_LENGTH] { let args_hash = hash_args(args); assert(args_hash == arguments::pack_arguments(args)); - call_public_function_internal(contract_address, function_selector, args_hash) + call_public_function_internal( + contract_address, + function_selector, + args_hash, + false + ) + } + + pub fn call_public_function_static( + _self: Self, + contract_address: AztecAddress, + function_selector: FunctionSelector, + args: [Field; ARGS_COUNT], + ) -> [Field; RETURN_VALUES_LENGTH] { + let args_hash = hash_args(args); + assert(args_hash == arguments::pack_arguments(args)); + call_public_function_internal( + contract_address, + function_selector, + args_hash, + true + ) } pub fn call_public_function_no_args( @@ -201,6 +222,24 @@ impl PublicContext { contract_address: AztecAddress, function_selector: FunctionSelector ) -> [Field; RETURN_VALUES_LENGTH] { - call_public_function_internal(contract_address, function_selector, 0) + call_public_function_internal( + contract_address, + function_selector, + 0, + false, + ) + } + + pub fn call_public_function_no_args_static( + _self: Self, + contract_address: AztecAddress, + function_selector: FunctionSelector, + ) -> [Field; RETURN_VALUES_LENGTH] { + call_public_function_internal( + contract_address, + function_selector, + 0, + true, + ) } } diff --git a/aztec/src/oracle/call_private_function.nr b/aztec/src/oracle/call_private_function.nr index 069247c..a4b778b 100644 --- a/aztec/src/oracle/call_private_function.nr +++ b/aztec/src/oracle/call_private_function.nr @@ -8,20 +8,23 @@ fn call_private_function_oracle( _contract_address: AztecAddress, _function_selector: FunctionSelector, _args_hash: Field, - _start_side_effect_counter: u32 + _start_side_effect_counter: u32, + _is_static_call: bool ) -> [Field; PRIVATE_CALL_STACK_ITEM_LENGTH] {} unconstrained pub fn call_private_function_internal( contract_address: AztecAddress, function_selector: FunctionSelector, args_hash: Field, - start_side_effect_counter: u32 + start_side_effect_counter: u32, + is_static_call: bool ) -> PrivateCallStackItem { let fields = call_private_function_oracle( contract_address, function_selector, args_hash, - start_side_effect_counter + start_side_effect_counter, + is_static_call ); PrivateCallStackItem::deserialize(fields) diff --git a/aztec/src/oracle/enqueue_public_function_call.nr b/aztec/src/oracle/enqueue_public_function_call.nr index d5bafbc..7e80f5c 100644 --- a/aztec/src/oracle/enqueue_public_function_call.nr +++ b/aztec/src/oracle/enqueue_public_function_call.nr @@ -12,19 +12,22 @@ fn enqueue_public_function_call_oracle( _contract_address: AztecAddress, _function_selector: FunctionSelector, _args_hash: Field, - _side_effect_counter: u32 + _side_effect_counter: u32, + _is_static_call: bool ) -> [Field; ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE] {} unconstrained pub fn enqueue_public_function_call_internal( contract_address: AztecAddress, function_selector: FunctionSelector, args_hash: Field, - side_effect_counter: u32 + side_effect_counter: u32, + is_static_call: bool ) -> [Field; ENQUEUE_PUBLIC_FUNCTION_CALL_RETURN_SIZE] { enqueue_public_function_call_oracle( contract_address, function_selector, args_hash, - side_effect_counter + side_effect_counter, + is_static_call ) } diff --git a/aztec/src/oracle/public_call.nr b/aztec/src/oracle/public_call.nr index 26b29d9..67ebff8 100644 --- a/aztec/src/oracle/public_call.nr +++ b/aztec/src/oracle/public_call.nr @@ -4,13 +4,15 @@ use dep::protocol_types::{abis::function_selector::FunctionSelector, address::Az fn call_public_function_oracle( _contract_address: AztecAddress, _function_selector: FunctionSelector, - _args_hash: Field + _args_hash: Field, + _is_static_call: bool ) -> [Field; RETURN_VALUES_LENGTH] {} unconstrained pub fn call_public_function_internal( contract_address: AztecAddress, function_selector: FunctionSelector, - args_hash: Field + args_hash: Field, + is_static_call: bool ) -> [Field; RETURN_VALUES_LENGTH] { - call_public_function_oracle(contract_address, function_selector, args_hash) + call_public_function_oracle(contract_address, function_selector, args_hash, is_static_call) }