Skip to content
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

Noir Contract Interfaces: generate 'callable from private' and 'callable from public' interfaces #1782

Closed
iAmMichaelConnor opened this issue Aug 24, 2023 · 0 comments · Fixed by #1860 or #1882
Assignees
Labels
C-aztec.nr Component: Aztec smart contract framework T-bug Type: Bug. Something is broken.

Comments

@iAmMichaelConnor
Copy link
Contributor

iAmMichaelConnor commented Aug 24, 2023

From @LHerskind:
"The interfaces seems to have wrappers for private -> something but not from public to something. Many public functions are callable from both, but they have different return values and contexts etc."

Options seem to be:

  1. Align the return values of public and private calls (but that ruins the safety of the interface, and would confuse users who'll receive useless return values when making public calls from private)
  2. Create two MyContractInterface structs: MyContractInterface_CallableFromPrivate and MyContractInterface_CallableFromPublic (naming could be improved 😅). A bit ugly, but would actually make it clear that you can't make a conventional 'call' to a private function from a public function (because we'd omit private functions from the MyContractInterface_CallableFromPublic interface.
  3. Create two versions of each function, within a single interface MyContractInterface, foo_from_private and foo_from_public, but that's pretty disgusting, as these names don't match the names of the original contract!

There's consensus that Option 2 is the best approach.

With option 2, the importing contract would do:

fn main(
        inputs: PrivateContextInputs,
        target: Field
    ) -> distinct pub abi::PrivateCircuitPublicInputs {
        let mut context = PrivateContext::new(inputs, abi::hash_args([target]));
        let test_contract_instance = TestContractInterface_CallableFromPrivate::at(target);
        let return_values = test_contract_instance.testCodeGen(&mut context, ...)
        // etc
}
@github-project-automation github-project-automation bot moved this to Todo in A3 Aug 24, 2023
@iAmMichaelConnor iAmMichaelConnor added T-bug Type: Bug. Something is broken. public-release!!!! and removed public-release labels Aug 24, 2023
@iAmMichaelConnor iAmMichaelConnor added this to the 📢 Initial Public Sandbox Release milestone Aug 25, 2023
@iAmMichaelConnor iAmMichaelConnor added the C-aztec.nr Component: Aztec smart contract framework label Aug 25, 2023
@spalladino spalladino self-assigned this Aug 29, 2023
@spalladino spalladino moved this from Todo to In Review in A3 Aug 29, 2023
spalladino added a commit that referenced this issue Aug 30, 2023
Generates two interface structs for each contract `Foo`: a
`FooPrivateContextInterface` and a `FooPublicContextInterface`. The
former is exactly as the one we had already, while the latter only
contains public methods and uses public contexts instead of private
ones.

Fixes #1782
@github-project-automation github-project-automation bot moved this from In Review to Done in A3 Aug 30, 2023
PhilWindle pushed a commit that referenced this issue Aug 30, 2023
🤖 I have created a new Aztec Packages release
---


##
[0.1.0-alpha49](v0.1.0-alpha48...v0.1.0-alpha49)
(2023-08-30)


### Features

* Generate public context contract interfaces
([#1860](#1860))
([2f4045e](2f4045e)),
closes
[#1782](#1782)


### Bug Fixes

* Do not warn on mismatched cli/sandbox version
([#1894](#1894))
([a44a0f6](a44a0f6))
* remove extra transfer arg in CLI Guide
([#1887](#1887))
([55728b8](55728b8))
* Reset keccak var inputs to 0
([#1881](#1881))
([382f07e](382f07e))


### Miscellaneous

* **1074:** remove read request data from final private kernel circuit
public inputs
([#1840](#1840))
([c61557a](c61557a))
* Reenable and refactor nested calls e2e tests
([#1868](#1868))
([570de80](570de80)),
closes
[#1587](#1587)
* Update formatting
([#1874](#1874))
([fb973ca](fb973ca))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-aztec.nr Component: Aztec smart contract framework T-bug Type: Bug. Something is broken.
Projects
Archived in project
2 participants