fix: address comments
This commit is contained in:
parent
8106f45bba
commit
54053b1086
|
@ -198,13 +198,6 @@ abstract contract RlnBase {
|
|||
payable(msg.sender).transfer(amount);
|
||||
}
|
||||
|
||||
/// Hashes a value using the Poseidon hasher
|
||||
/// NOTE: The variant of Poseidon we use accepts only 1 input, assume n=2
|
||||
/// @param inputs The values to hash
|
||||
function hash(uint256[2] memory inputs) internal view returns (uint256) {
|
||||
return poseidonHasher.hash(inputs);
|
||||
}
|
||||
|
||||
function isValidCommitment(uint256 idCommitment) public view returns (bool) {
|
||||
return idCommitment != 0 && idCommitment < poseidonHasher.Q();
|
||||
}
|
||||
|
@ -224,7 +217,7 @@ abstract contract RlnBase {
|
|||
);
|
||||
}
|
||||
|
||||
function computeRoot() external view returns (uint256) {
|
||||
function root() external view returns (uint256) {
|
||||
return imtData.root;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -389,21 +389,6 @@ function withdraw() external virtual
|
|||
|
||||
Allows a user to withdraw funds allocated to them upon slashing a member
|
||||
|
||||
### hash
|
||||
|
||||
```solidity
|
||||
function hash(uint256[2] inputs) internal view returns (uint256)
|
||||
```
|
||||
|
||||
Hashes a value using the Poseidon hasher
|
||||
NOTE: The variant of Poseidon we use accepts only 1 input, assume n=2
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------ | ---------- | ------------------ |
|
||||
| inputs | uint256[2] | The values to hash |
|
||||
|
||||
### isValidCommitment
|
||||
|
||||
```solidity
|
||||
|
@ -418,10 +403,10 @@ function _verifyProof(uint256 idCommitment, address receiver, uint256[8] proof)
|
|||
|
||||
_Groth16 proof verification_
|
||||
|
||||
### computeRoot
|
||||
### root
|
||||
|
||||
```solidity
|
||||
function computeRoot() external view returns (uint256)
|
||||
function root() external view returns (uint256)
|
||||
```
|
||||
|
||||
## Pairing
|
||||
|
|
|
@ -204,15 +204,25 @@ contract RlnTest is Test {
|
|||
assertEq(rln.withdrawalBalance(to), 0);
|
||||
}
|
||||
|
||||
function test__computeRoot() public {
|
||||
uint256 idCommitment = 19014214495641488759237505126948346942972912379615652741039992445865937985820;
|
||||
function test__root() public {
|
||||
uint256[] memory idCommitments = new uint256[](10);
|
||||
idCommitments[0] = 19143711682366759980911001457853255795836264632723844153354310748778748156460;
|
||||
idCommitments[1] = 16984765328852711772291441487727981184905800779020079168989152080434188364678;
|
||||
idCommitments[2] = 10972315136095845343447418815139813428649316683283020632475608655814722712541;
|
||||
idCommitments[3] = 2709631781045191277266130708832884002577134582503944059038971337978087532997;
|
||||
idCommitments[4] = 8255654132980945447086418574686169461187805238257784695584517016324877809505;
|
||||
idCommitments[5] = 20291701150251695209910387548168084091751201746043024067531503187703236470983;
|
||||
idCommitments[6] = 11817872986033932471261438074921403500882957864164537515599299873089437746577;
|
||||
idCommitments[7] = 18475838919635792169148272767721284591038756730004222133003018558598315558783;
|
||||
idCommitments[8] = 10612118277928165031660389522171737855229037400929675201853245490188277695983;
|
||||
idCommitments[9] = 17318633845296358766427229711888486415250435256643711009388405482885762601797;
|
||||
|
||||
rln.register{value: MEMBERSHIP_DEPOSIT}(idCommitment);
|
||||
assertEq(rln.stakedAmounts(idCommitment), MEMBERSHIP_DEPOSIT);
|
||||
assertEq(rln.computeRoot(), 7919895337495550471953660523154055129542864206434083474237224229170626792564);
|
||||
vm.pauseGasMetering();
|
||||
for (uint256 i = 0; i < idCommitments.length; i++) {
|
||||
rln.register{value: MEMBERSHIP_DEPOSIT}(idCommitments[i]);
|
||||
}
|
||||
vm.resumeGasMetering();
|
||||
|
||||
rln.register{value: MEMBERSHIP_DEPOSIT}(idCommitment + 1);
|
||||
assertEq(rln.stakedAmounts(idCommitment + 1), MEMBERSHIP_DEPOSIT);
|
||||
assertEq(rln.computeRoot(), 4478280093730386416628343710916187522643918890809710321703190604649709696518);
|
||||
assertEq(rln.root(), 5210724218081541877101688952118136930297124697603087561558225712176057209122);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue