Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

feat: set Brillig VM state to Failure rather than panicking on invalid foreign call response #375

Merged
merged 1 commit into from
Jun 14, 2023

Conversation

TomAFrench
Copy link
Member

@TomAFrench TomAFrench commented Jun 14, 2023

Description

Problem*

Returning an incorrectly sized foreign call response to the Brillig VM will currently cause a panic. This is an issue for situations where the Brillig VM is running inside wasm as this doesn't handle panics well. As this is a case of a user providing invalid input, we should return an error rather than panicking.

Resolves #370 (comment)

Summary*

We now set the VMStatus to Failure in this situation. I've had to delay this until after the for-loop due to the borrow-checker so I'd be open to any other solutions which avoid the need for the mutable bool + break.

Additional Context

PR Checklist*

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

BEGIN_COMMIT_OVERRIDE
feat(brillig): Set VMStatus to Failure rather than panicking on invalid foreign call response (#375)
END_COMMIT_OVERRIDE

Copy link
Contributor

@ludamad ludamad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@ludamad ludamad added this pull request to the merge queue Jun 14, 2023
Merged via the queue into master with commit c49d82c Jun 14, 2023
@TomAFrench TomAFrench deleted the replace-foreign-call-panic branch June 14, 2023 15:20
@TomAFrench TomAFrench changed the title chore: set Brillig VM state to Failure rather than panicking on invalid foreign call response feat: set Brillig VM state to Failure rather than panicking on invalid foreign call response Jun 15, 2023
@kevaundray kevaundray mentioned this pull request Jun 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants