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

fix: add new BrilligFunctionUnsatisfiedConstrain resolution error variant #6

Conversation

anaPerezGhiglia
Copy link
Member

@anaPerezGhiglia anaPerezGhiglia commented Jul 1, 2024

this is an alternate solution to #5
it has more effects outside the scope of the debugger, but it feels more accurate

Description

When an assertion fails on Brillig mode, the debugger fails to indicate the user where the program failed

image

while when running on ACIR mode it provides enough information 👇
image

Summary

Context

assert constraints are translated as "jump to trap" if the condition is not met when running in Brillig mode

Changes

  • Add a new variant OpcodeResolutionError::BrilligFunctionUnsatisfiedConstrain to represent failed constraints on Brillig
  • Return this new error when brillig code fails due to a Trap failure
  • Return the ownership of the solver to brillig context when the debugger fails due to this new resolution error so that the the last opcode is known for showing the error
  • Changed the variant checking on ACVM.map_brillig_error from OpcodeResolutionError::BrilligFunctionFailed to OpcodeResolutionError::BrilligFunctionUnsatisfiedConstrain since assertion errors will now fail with the latter
  • Add new branch on related match expressions to treat the new variant the same way as BrilligFunctionFailed for the other cases
image

Observations

  • TODO: should we return the solver ownership to the brillig context in all Err scenarios>?

Documentation

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist

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

Copy link

github-actions bot commented Jul 1, 2024

Thank you for your contribution to the Noir language.

Please do not force push to this branch after the Noir team have started review of this PR. Doing so will only delay us merging your PR as we will need to start the review process from scratch.

Thanks for your understanding.

@anaPerezGhiglia anaPerezGhiglia changed the title Fix: add new BrilligFunctionUnsatisfiedConstrain resolution error variant fix: add new BrilligFunctionUnsatisfiedConstrain resolution error variant Jul 1, 2024
@anaPerezGhiglia anaPerezGhiglia marked this pull request as ready for review July 1, 2024 19:00
@anaPerezGhiglia anaPerezGhiglia merged commit 3936c62 into fix/debugger-brillig-assertion-fail Jul 3, 2024
37 checks passed
anaPerezGhiglia added a commit that referenced this pull request Jul 3, 2024
…ariant (#6)

* Convert BrilligSolver Trap failure into `BrilligFunctionUnsatisfiedConstrain` error

* extract extract_failure_payload function to improve readability

* Changed the variant checking on ACVM.map_brillig_error from OpcodeResolutionError::BrilligFunctionFailed to OpcodeResolutionError::BrilligFunctionUnsatisfiedConstrain

* return ownership of the solver to brillig context when the debugger fails due to `BrilligFunctionUnsatisfiedConstrain`
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.

2 participants