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

feat: Adding internal keyword #1873

Merged
merged 8 commits into from
Jul 8, 2023

Conversation

LHerskind
Copy link
Contributor

@LHerskind LHerskind commented Jul 6, 2023

Description

Adding internal as a keyword for functions to specify that only the contracts itself can execute this function.

Related to #1168. But functions are not internal by default, instead it is callable by other contracts and itself.

Problem*

When building noir contracts for Aztec, we want to support flows such as:

  • Private functions does some access check and calls a public function to mint tokens

Currently, we could do this by inserting a commitment from private and then nullify it in public, but that is very wasteful.

Instead we can introduce internal as a keyword and store is_internal as part of the contracts tree, which allows the kernel to check that the contract itself is the caller, and reject anyone else from calling it.

Similar to solidity internal.

Summary*

  • Adds internal keyword.
  • Adds is_internal to json output

Documentation

  • This PR requires documentation updates when merged.

    • I will submit a noir-lang/docs PR.
    • I will request for and support Dev Rel's help in documenting this PR.

For documentation only of interest to contract noir, which don't seem to have documentation at the moment.

Additional Context

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

crates/noirc_frontend/src/parser/parser.rs Outdated Show resolved Hide resolved
crates/noirc_frontend/src/hir_def/function.rs Outdated Show resolved Hide resolved
crates/noirc_frontend/src/hir/resolution/resolver.rs Outdated Show resolved Hide resolved
@jfecher
Copy link
Contributor

jfecher commented Jul 6, 2023

Looks good, sans one more parser comment.

Since this is still a draft, what work remains on this?

@LHerskind LHerskind marked this pull request as ready for review July 7, 2023 07:55
@LHerskind LHerskind marked this pull request as draft July 7, 2023 07:55
@LHerskind
Copy link
Contributor Author

Looks good, sans one more parser comment.

Since this is still a draft, what work remains on this?

The idea was that it should be behind a feature flag to see how easily we could use those to get things into noir for Aztec without wrecking master, just have not gotten around to it.

@LHerskind LHerskind changed the base branch from aztec3 to master July 7, 2023 10:18
@LHerskind LHerskind marked this pull request as ready for review July 7, 2023 10:41
Co-authored-by: jfecher <jfecher11@gmail.com>
@kevaundray kevaundray enabled auto-merge July 8, 2023 09:54
@kevaundray kevaundray added this pull request to the merge queue Jul 8, 2023
Merged via the queue into noir-lang:master with commit 7a85493 Jul 8, 2023
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