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

Add more readable serialisation of InputValues representing boolean values. #1324

Closed
1 task done
TomAFrench opened this issue May 9, 2023 · 3 comments · Fixed by #1655
Closed
1 task done

Add more readable serialisation of InputValues representing boolean values. #1324

TomAFrench opened this issue May 9, 2023 · 3 comments · Fixed by #1655
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@TomAFrench
Copy link
Member

Problem

Currently we allow users to set boolean arguments in the toml files as a true/false value. However when noirc_abi saves them to file, they all get converted to 0x0000000000000000000000000000000000000000000000000000000000000001 or 0x0000000000000000000000000000000000000000000000000000000000000000.

This isn't particularly readable, ideally we'd preserve the "booleanness" of these args rather than treating them as arbitrary fields.

Proposed solution

The reason for this issue is that InputValue represents all of fields, integers and bools as InputValue::Field.

pub enum InputValue {
Field(FieldElement),
Vec(Vec<FieldElement>),
String(String),
Struct(BTreeMap<String, InputValue>),
}

We could address this by either adding a InputValue::Boolean variant or passing the ABI into the serialisation method similarly to how we do for parsing.

Alternatives considered

No response

Additional context

No response

Submission Checklist

  • Once I hit submit, I will assign this issue to the Project Board with the appropriate tags.
@TomAFrench TomAFrench added enhancement New feature or request good first issue Good for newcomers labels May 9, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir May 9, 2023
@TomAFrench
Copy link
Member Author

If anyone would like to contribute with this issue, please reach out here beforehand so we can discuss which option would be best.

@chirag-bgh
Copy link

hey! hey! @TomAFrench
i would like to work on this issue.

@TomAFrench
Copy link
Member Author

Awesome! Thanks @chirag-bgh. I've had a little think about which option would be best and I think we should pass the ABI to the serialisation method rather than adding InputValue::Boolean. This would have the benefit of catching any booleans which are stored in arrays as well.

I'm going to assign this issue to you and feel free to reach out if you run into troubles.

@TomAFrench TomAFrench self-assigned this Jun 13, 2023
@TomAFrench TomAFrench moved this from 📋 Backlog to ✅ Done in Noir Jun 13, 2023
@TomAFrench TomAFrench moved this from ✅ Done to 🏗 In progress in Noir Jun 13, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Noir Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants