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

Non-entry point methods in contracts #2688

Open
kevaundray opened this issue Sep 13, 2023 · 1 comment
Open

Non-entry point methods in contracts #2688

kevaundray opened this issue Sep 13, 2023 · 1 comment
Labels
aztec.nr Helpful for development of Aztec.nr the smart contract framework discussion
Milestone

Comments

@kevaundray
Copy link
Contributor

This is a retroactive issue.

Problem

Consider the following method:

contract Foo {
    
    struct PlaceholderStruct{x : u32 }

    fn utility_method(_context : &mut PlaceholderStruct) {}
}

Since entry point functions cannot contain references, the following method will fail.

Discussion

One solution is to have a way to specify some methods as non-entry point methods. There would be two ways to define a non-entry point function, since if you pull in a Noir library, its method will be seen as non-entrypoint. There are other considerations here related to whether a function should by default be an entry point.

Another solution is to say that all methods in a contract are entry point functions and if you want a non-entry point function, you need to define it outside of the contract scope.

@jfecher
Copy link
Contributor

jfecher commented Sep 18, 2023

Another solution is to say that all methods in a contract are entry point functions and if you want a non-entry point function, you need to define it outside of the contract scope.

This is the current was the previous design. If you want the code above to work you can lift PlaceholderStruct and utility_method out of the contract declaration. Therefore, "if it's not in the contract, it's not in the contract."

I think adding a required annotation like #[contract_library_method] just makes this interaction more complex than needed.

@Savio-Sou Savio-Sou added the aztec.nr Helpful for development of Aztec.nr the smart contract framework label Oct 6, 2023
@kevaundray kevaundray added this to the 1.0 milestone Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aztec.nr Helpful for development of Aztec.nr the smart contract framework discussion
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants