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: constraint on bn254 values #26

Merged
merged 3 commits into from
Aug 16, 2023
Merged

fix: constraint on bn254 values #26

merged 3 commits into from
Aug 16, 2023

Conversation

rymnc
Copy link
Contributor

@rymnc rymnc commented Aug 9, 2023

@rymnc rymnc marked this pull request as ready for review August 16, 2023 07:04
@rymnc rymnc requested a review from 0x-r4bbit August 16, 2023 07:05
@github-actions
Copy link

LCOV of commit cca45ef during CI #32

Summary coverage rate:
  lines......: 84.0% (497 of 592 lines)
  functions..: 50.0% (13 of 26 functions)
  branches...: 52.5% (21 of 40 branches)

Files changed coverage rate:
                              |Lines       |Functions  |Branches    
  Filename                    |Rate     Num|Rate    Num|Rate     Num
  ==================================================================
  contracts/PoseidonHasher.sol| 100%    461| 100%     2|    -      0
  contracts/RlnBase.sol       |97.1%     34|87.5%     8| 100%     18
  test/RLNApp.t.sol           | 100%      2| 100%     2|75.0%      4

@@ -10,7 +10,7 @@ import "forge-std/console.sol";

contract RlnApp is RlnBase {
uint256 public constant allowedIdCommitment =
21888242871839275222246405745257275088548364400416034343698204186575808495617;
19014214495641488759237505126948346942972912379615652741039992445865937985820;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why exactly has this been changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it was earlier the order of the field, i.e p = 21888242871839275222246405745257275088548364400416034343698204186575808495617, and no number in the field can exceed it. switched it out to make sure people dont get confused about it

uint256 badDepositAmount = MEMBERSHIP_DEPOSIT - 1;
vm.expectRevert(abi.encodeWithSelector(InsufficientDeposit.selector, MEMBERSHIP_DEPOSIT, badDepositAmount));
rln.register{value: badDepositAmount}(idCommitment);
}

function test__InvalidRegistration__FullSet(uint256 idCommitmentSeed) public {
vm.assume(idCommitmentSeed < 2 ** 255 - SET_SIZE);
function test__InvalidRegistration__FullSet() public {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for me to understand: why did we move away from a fuzz test here? Has anything changed with regards to the seed that we can't/aren't relying on it anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

technically we are not testing any logic here, we're just checking if an error is thrown based on the size of the tree - thats why we dont need to fuzz id commitments here

test/Rln.t.sol Show resolved Hide resolved
@github-actions
Copy link

LCOV of commit 4cc2a27 during CI #33

Summary coverage rate:
  lines......: 84.0% (497 of 592 lines)
  functions..: 50.0% (13 of 26 functions)
  branches...: 52.5% (21 of 40 branches)

Files changed coverage rate:
                              |Lines       |Functions  |Branches    
  Filename                    |Rate     Num|Rate    Num|Rate     Num
  ==================================================================
  contracts/PoseidonHasher.sol| 100%    461| 100%     2|    -      0
  contracts/RlnBase.sol       |97.1%     34|87.5%     8| 100%     18
  test/RLNApp.t.sol           | 100%      2| 100%     2|75.0%      4

@github-actions
Copy link

LCOV of commit 077be32 during CI #34

Summary coverage rate:
  lines......: 84.0% (497 of 592 lines)
  functions..: 50.0% (13 of 26 functions)
  branches...: 52.5% (21 of 40 branches)

Files changed coverage rate:
                              |Lines       |Functions  |Branches    
  Filename                    |Rate     Num|Rate    Num|Rate     Num
  ==================================================================
  contracts/PoseidonHasher.sol| 100%    461| 100%     2|    -      0
  contracts/RlnBase.sol       |97.1%     34|87.5%     8| 100%     18
  test/RLNApp.t.sol           | 100%      2| 100%     2|75.0%      4

Copy link
Contributor

@0x-r4bbit 0x-r4bbit left a comment

Choose a reason for hiding this comment

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

Well done and thanks for the prompt update!

@rymnc rymnc merged commit d899a0c into main Aug 16, 2023
1 check passed
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.

None yet

2 participants