feat!: make TestEnvironment be unconstrained#8747
Merged
Merged
Conversation
sklppy88
approved these changes
Sep 25, 2024
sklppy88
left a comment
Contributor
There was a problem hiding this comment.
Looks nice ! I think overall we should be more explicit on the rule which you summed up really well, which is mut references cannot cross between constrained <-> unconstrained. Imo this is obvious with context but not so obvious without, and it took me even awhile to see how this affects the code, even if I understood the reason behind it.
… nv/unconstrained-tests
Collaborator
Docs PreviewHey there! 👋 You can check your preview at https://66f3e0893305781a4b646c50--aztec-docs-dev.netlify.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TestEnvironment throws a gazillion warnings due to calling oracles in constrained functions. We could have
unsafeblocks, but this would be misleading since we're not constraining anything, and there'd be risk of user error. The correct call is to make these functions be unconstrained.However, since they work with mutable references, these themselves cannot be called from constrained functions. Nor should they - this would again require unsafe blocks, but we cannot constrain these results, and we don't anyway since tests are run in a non-adversarial environment.
There should be no difference between constrained and unconstrained tests (except unconstrained tests might be a smidge faster). Therefore, the simplest and most correct way forward is to make all tests and helpers unconstrained, which is what I do here. This ends up removing a ton of 'missing unsafe' warnings.