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

Narrow mismatch when throwing AbiError::TypeMismatch on large types #3560

Closed
TomAFrench opened this issue Nov 24, 2023 · 0 comments · Fixed by #4798
Closed

Narrow mismatch when throwing AbiError::TypeMismatch on large types #3560

TomAFrench opened this issue Nov 24, 2023 · 0 comments · Fixed by #4798
Labels
enhancement New feature or request

Comments

@TomAFrench
Copy link
Member

Problem

When passing an invalid value for a type when ABI encoding we throw the AbiError::TypeMismatch error.

#[error("The parameter {} is expected to be a {:?} but found incompatible value {value:?}", .param.name, .param.typ)]
TypeMismatch { param: AbiParameter, value: InputValue },

This prints out the passed value and the type which it is supposed to satisfy. The trouble with this is that it can be hard to find the reason for the mismatch when dealing with large complicated types.

Happy Case

Ideally the ABI encoder would gives more information on why the type and value don't match when throwing this error.

  • Arrays could be printed along with their length next to them
  • Structs we can inspect each field individually to narrow down to just the fields which have issues.

Alternatives Considered

No response

Additional Context

#3533 (comment)

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@TomAFrench TomAFrench added the enhancement New feature or request label Nov 24, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Nov 24, 2023
github-merge-queue bot pushed a commit that referenced this issue Apr 12, 2024
#4798)

# Description

## Problem\*

Resolves #3560 
Resolves #4778 

## Summary\*

This PR updates `InputValue.matches_abi` to
`InputValue.find_type_mismatch` which returns an error related to the
type which is failing to be abi encoded.

## Additional Context

This should help @alexghr with debugging #4778 

## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant