Skip to content

feat: new external function call interface#18274

Merged
AztecBot merged 1 commit intonextfrom
11-07-feat_new_external_function_call_interface
Nov 10, 2025
Merged

feat: new external function call interface#18274
AztecBot merged 1 commit intonextfrom
11-07-feat_new_external_function_call_interface

Conversation

@benesjan
Copy link
Contributor

@benesjan benesjan commented Nov 7, 2025

Fixes F-135

In this PR I implement the following API:

self.{call, view, enqueue, enqueue_view, enqueue_view_incognito, set_as_teardown, set_as_teardown_incognito}(MyContract::at(address).my_function(...args))

that can now be used instead of:

MyContract::at(address).my_function(...args).{call, view, enqueue, enqueue_view, enqueue_view_incognito, set_as_teardown, set_as_teardown_incognito}(self.context)

I've also updated all the places to use the new API.

Now self.context is used in contracts fairly rarely.

@@ -51,68 +51,10 @@ where
}
}

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 docs from this file were moved over to ContractSelf and I marked the functions as deprecated to point devs to the new API.

/// # Returns
/// * `T` - Whatever data the called function has returned.
///
/// 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.

Will drop this function in a followup PR. It shouldn't exist.

{
emit_event_in_private(event, self.context, recipient, delivery_mode);
}

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 docs here are mostly a copy-paster from call_interfaces.nr. I just:

  • updated the arguments as they are different here,
  • added the Example section which I thought is important because devs might not know how tho get the CallInterface arg.

* General Opcodes
************************************************************************/
#[external("public")]
#[view]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed to do this because where it's called it's called statically and the new API doesn't support calling of non-view function statically because self.view(...) expects PublicStaticCallInterface on the input and not PublicCallInterface.

#[external("private")]
fn enqueue_public_from_private() {
AvmTest::at(self.address).set_opcode_u8().enqueue_view(self.context);
self.enqueue_self_static.set_opcode_u8();
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 naming here is inconsistent. Somewhere we use "static" and somewhere we use "view". Noted that in the final renaming task.

@benesjan benesjan marked this pull request as ready for review November 7, 2025 18:55
@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch from 548002b to baf4cef Compare November 7, 2025 20:21
@benesjan benesjan force-pushed the 11-07-refactor_cleaning_up_flow_of_call_interface_generation branch from 5c45a7f to e9e3a26 Compare November 7, 2025 20:21

#[external("public")]
#[view]
fn set_opcode_u8_view() -> u8 {
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 new API doesn't allow me to call non-view function statically but we also need the set_opcode_u8 to be non-static for typescript test so I just created this copy here.

@benesjan benesjan marked this pull request as draft November 8, 2025 22:17
@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch from 1448ef8 to 9f627cf Compare November 8, 2025 22:18
@benesjan benesjan force-pushed the 11-07-refactor_cleaning_up_flow_of_call_interface_generation branch from e9e3a26 to dc586db Compare November 8, 2025 22:18
@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch from 9f627cf to 22ad496 Compare November 8, 2025 22:32
@benesjan benesjan force-pushed the 11-07-refactor_cleaning_up_flow_of_call_interface_generation branch 2 times, most recently from 5843610 to ffe6c15 Compare November 8, 2025 23:16
@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch 2 times, most recently from 4645315 to 1b0eb6f Compare November 8, 2025 23:31
@benesjan benesjan force-pushed the 11-07-refactor_cleaning_up_flow_of_call_interface_generation branch from 6eedab5 to cc4088d Compare November 9, 2025 13:06
@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch from 1b0eb6f to 50e1222 Compare November 9, 2025 13:06
@benesjan benesjan marked this pull request as ready for review November 9, 2025 13:27
@AztecBot
Copy link
Collaborator

AztecBot commented Nov 9, 2025

Flakey Tests

🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033[38;2;188;109;208mFLAKED\033[0m (\033[38;2;250;217;121m8;;http://ci.aztec-labs.com/9a4d2ddb3a46072f�9a4d2ddb3a46072f8;;�\033[0m): BOX=react BROWSER=firefox run_compose_test react-firefox box boxes (61s) (code: 1) (\033[38;2;188;109;208mAztec Bot\033[0m: feat: new external function call interface (#18274))

Copy link
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

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

Best jan ever

@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch from 8bb0e31 to 4463791 Compare November 10, 2025 14:48
@benesjan benesjan force-pushed the 11-07-refactor_cleaning_up_flow_of_call_interface_generation branch from cc4088d to 09bfcdb Compare November 10, 2025 14:48
@benesjan benesjan marked this pull request as draft November 10, 2025 14:50
@benesjan benesjan force-pushed the 11-07-refactor_cleaning_up_flow_of_call_interface_generation branch from 09bfcdb to afc0612 Compare November 10, 2025 15:52
@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch from 4463791 to 39a98d3 Compare November 10, 2025 15:52
@AztecBot AztecBot force-pushed the 11-07-refactor_cleaning_up_flow_of_call_interface_generation branch from afc0612 to e82cde7 Compare November 10, 2025 16:14
Base automatically changed from 11-07-refactor_cleaning_up_flow_of_call_interface_generation to next November 10, 2025 18:03
@benesjan benesjan force-pushed the 11-07-feat_new_external_function_call_interface branch from 39a98d3 to 26b8165 Compare November 10, 2025 18:12
@benesjan benesjan marked this pull request as ready for review November 10, 2025 18:13
Fixes F-135

In this PR I implement the following API:

```rust
self.{call, view, enqueue, enqueue_view, enqueue_view_incognito, set_as_teardown, set_as_teardown_incognito}(MyContract::at(address).my_function(...args))
```

that can now be used instead of:

```rust
MyContract::at(address).my_function(...args).{call, view, enqueue, enqueue_view, enqueue_view_incognito, set_as_teardown, set_as_teardown_incognito}(self.context)
```

I've also updated all the places to use the new API.

Now `self.context` is used in contracts fairly rarely.
@AztecBot AztecBot force-pushed the 11-07-feat_new_external_function_call_interface branch from 26b8165 to 7de49f6 Compare November 10, 2025 18:38
@AztecBot AztecBot enabled auto-merge November 10, 2025 18:38
@AztecBot AztecBot added this pull request to the merge queue Nov 10, 2025
auto-merge was automatically disabled November 10, 2025 18:49

Pull Request is not mergeable

Merged via the queue into next with commit 0ed91fa Nov 10, 2025
16 checks passed
@AztecBot AztecBot deleted the 11-07-feat_new_external_function_call_interface branch November 10, 2025 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants