Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,6 @@ where
// returns hash is empty as per the protocol rules.
returns_hash.get_preimage()
}

/// TODO(F-130): Drop this function. This should be present only on PrivateStaticCallInterface.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not closing this issue with this PR as there are more subtasks TODO

pub fn view(self, context: &mut PrivateContext) -> T {
execution_cache::store(self.args, self.args_hash);
let returns_hash = context.call_private_function_with_args_hash(
self.target_contract,
self.selector,
self.args_hash,
true,
);
// If T is () (i.e. if the function does not return anything) then `get_preimage` will constrain that the
// returns hash is empty as per the protocol rules.
returns_hash.get_preimage()
}
}

impl<let M: u32, T> CallInterface<M> for PrivateCallInterface<M, T> {
Expand Down Expand Up @@ -234,19 +220,6 @@ where
Deserialize::deserialize(returns.as_array())
}

/// TODO(F-130): Drop this function. This should be present only on PublicStaticCallInterface.
pub unconstrained fn view(self, context: PublicContext) -> T {
let returns = context.static_call_public_function(
self.target_contract,
self.selector,
self.args,
self.gas_opts,
);
// If T is () (i.e. if the function does not return anything) then `as_array` will constrain that `returns` has
// a length of 0 (since that is ()'s deserialization length).
Deserialize::deserialize(returns.as_array())
}

/// **[DEPRECATED]**
/// This function is deprecated. Please use the new contract API:
/// `self.enqueue(MyContract::at(address).my_public_function(...args))`
Expand All @@ -263,16 +236,6 @@ where
self.enqueue_impl(context, false, true)
}

/// TODO(F-130): Drop this function. This should be present only on PublicStaticCallInterface.
pub fn enqueue_view(self, context: &mut PrivateContext) {
self.enqueue_impl(context, true, false)
}

/// TODO(F-130): Drop this function. This should be present only on PublicStaticCallInterface.
pub fn enqueue_view_incognito(self, context: &mut PrivateContext) {
self.enqueue_impl(context, true, true)
}

fn enqueue_impl(
self,
context: &mut PrivateContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,13 +827,27 @@ pub contract AvmTest {
arg_a: Field,
arg_b: Field,
) -> Field {
AvmTest::at(address).add_args_return(arg_a, arg_b).view(context)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test here relies on the static call but in other places another ugly stale monstrosity expects the called function to b e non-view so I hack around this by directly using the context thingy.

let selector =
comptime { FunctionSelector::from_signature("add_args_return(Field,Field)") };
context.static_call_public_function(
address,
selector,
[arg_a, arg_b].as_slice(),
GasOpts::default(),
)[0]
}

// Indirectly call_static `set_storage_single`. Should revert since it's accessing self.storage.
#[external("public")]
fn nested_static_call_to_set_storage() {
AvmTest::at(self.address).set_storage_single(20).view(self.context);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test here relies on the static call but in other places another ugly stale monstrosity expects the called function to b e non-view so I hack around this by directly using the context thingy.

let selector = comptime { FunctionSelector::from_signature("set_storage_single(Field)") };
let args = [20 as Field];
let _ = self.context.static_call_public_function(
self.address,
selector,
args.as_slice(),
GasOpts::default(),
);
}

#[external("public")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use dep::aztec::macros::aztec;
pub contract StaticParent {
use dep::aztec::{context::gas::GasOpts, macros::functions::{external, view}};
use dep::aztec::protocol_types::{
abis::function_selector::FunctionSelector, address::AztecAddress,
abis::function_selector::FunctionSelector, address::AztecAddress, traits::ToField,
};
use dep::static_child_contract::StaticChild;

Expand Down Expand Up @@ -98,12 +98,18 @@ pub contract StaticParent {
target_selector: FunctionSelector,
args: [Field; 2],
) -> Field {
// Not using the new self.view(...) API because that doesn't allow for static calls to non-static functions
// which this test seems to rely on. TODO(F-130): Address this and replace e2e_static_calls.test.ts with Noir
// tests.
StaticParent::at(self.address).private_call(target_contract, target_selector, args).view(
self.context,
)
// Not using the high-level self.view(...) API because that doesn't allow for static calls to non-static
// functions which this test seems to relies on.
let private_call_selector =
FunctionSelector::from_signature("private_call((Field),(u32),[Field;2])");
self
.context
.static_call_private_function(
self.address,
private_call_selector,
[target_contract.to_field(), target_selector.to_field(), args[0], args[1]],
)
.get_preimage()
}

// Just like function above but with 3 args.
Expand Down
Loading