-
Notifications
You must be signed in to change notification settings - Fork 200
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
Refactor and simplify string formatting #4238
Comments
I don't think this would be possible to add as a type. It is similar to a string slice but if we return it from an oracle and its dependent on some other data's display method then we wouldn't know the length of the string at compile-time. |
You are correct we couldn't return it from the unconstrained environment to the constrained environment, but I was thinking we could still have it as a type similar to slices. We would then have a It would just be a way to make sure each foreign call has it owns separate functionality.
|
…l/aztec-packages#5086) Closes #4520. I did some work adding tests for this, but ultimately decided to go back on it. We don't really have any tests for other parts of the `addNotes` flow (such as the checks for note existence, inclusion in the provided tx, non-nullification, etc.), and this didn't feel like the right place to work on those. We definitely should however. Part of the problem is that writing a contract that allows for manual note creation, deletion and retrieval from a test is quite annoying - I did some of this in `TestContract` for #4238. For this we'd also need to have different functions for different note types, and even then some of these notes can only be added automatically via broadcast due to the random values in the note.
…l/aztec-packages#5086) Closes #4520. I did some work adding tests for this, but ultimately decided to go back on it. We don't really have any tests for other parts of the `addNotes` flow (such as the checks for note existence, inclusion in the provided tx, non-nullification, etc.), and this didn't feel like the right place to work on those. We definitely should however. Part of the problem is that writing a contract that allows for manual note creation, deletion and retrieval from a test is quite annoying - I did some of this in `TestContract` for #4238. For this we'd also need to have different functions for different note types, and even then some of these notes can only be added automatically via broadcast due to the random values in the note.
Problem
Before this PR #4101 the
fmtstr
type is only resolved when trying to print the type using a Brillig foreign call. Now withresolve_assert_message
we also must handle formatting of strings as we are saving an assertion message during execution that is to be displayed upon an unsatisfied constrain. The new dynamic assertion message resolution also reuses the same methodsprintln
does for formatting.Happy Case
We should have a uniform startegy for formatting strings. Ideally this would not be in the "backend" and done by foreign calls. Foreign calls should be only for requesting a service from the caller that is executing the program such as printing to stdout or saving a failure message. Right now the current foreign call builtins on
nargo
perform these functions but also format the string output.A possible solution was posted here (#4101 (comment)). We should settle on the strategy for simplifying formatting in this discussion issue.
Alternatives Considered
We could lean into a
format
oracle that returns a string of variable length (this would have to be added to the language).println
andresolve_assert_message
would then have more isolated functionality and callformat
themselves.A Display trait of some kind could be added and then it would be up to users to format their types in Noir (with the core team formatting the primitive and stdlib types). It would most likely only be available in an unconstrained environment. This would most likely require some kind of string builtins or a format oracle, so we would still have formatting in the "backend".
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: