Skip to content

Conversation

@winderica
Copy link
Contributor

@winderica winderica commented Dec 20, 2023

Description

Hi there, thanks for your amazing work!

In the current implementation of gnark, builder.Select introduces a constraint to enforce that the condition is boolean. However, when the condition is from the result of builder.IsZero, this constraint is unnecessary, as builder.IsZero always returns a value m that is guaranteed to be either 0 or 1.

This PR marks m in builder.IsZero as boolean, so that we can save 1 constraint when using the result in subsequent operations like Select.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas (N/A)
  • I have made corresponding changes to the documentation (N/A)
  • I have added tests that prove my fix is effective or that my feature works (N/A)
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules (N/A)

@CLAassistant
Copy link

CLAassistant commented Dec 20, 2023

CLA assistant check
All committers have signed the CLA.

@ivokub
Copy link
Collaborator

ivokub commented Dec 21, 2023

Hi @winderica - thanks for the contribution. I have been busy before holidays to review but will definitely get to it next year. Sorry for the delay.

I think the fix would be useful but I would first have to see thoroughly the test suite to see if there are not unintended side-effects.

@gbotrel gbotrel self-requested a review January 4, 2024 15:06
Copy link
Collaborator

@gbotrel gbotrel left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@gbotrel gbotrel merged commit 84ffe1c into Consensys:master Jan 4, 2024
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.

4 participants