feat(WakuRln): zero indexed deployments and updated dependency (#8)

* fix: update submodule

* feat(rln): zero indexed deployment
This commit is contained in:
Aaryamann Challani 2023-09-05 22:29:02 +05:30 committed by GitHub
parent 63a7856eb2
commit e5eefe4891
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 110 additions and 60 deletions

1
.gitmodules vendored
View File

@ -5,6 +5,7 @@
[submodule "lib/rln-contract"]
path = lib/rln-contract
url = https://github.com/vacp2p/rln-contract
branch = 35f2182
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/Openzeppelin/openzeppelin-contracts

View File

@ -10,7 +10,10 @@ error NotImplemented();
contract WakuRln is Ownable, RlnBase {
uint16 public immutable contractIndex;
constructor(address _poseidonHasher, uint16 _contractIndex) Ownable() RlnBase(0, 20, _poseidonHasher, address(0)) {
constructor(
address _poseidonHasher,
uint16 _contractIndex
) Ownable() RlnBase(0, 20, _poseidonHasher, address(0)) {
contractIndex = _contractIndex;
}
@ -19,7 +22,8 @@ contract WakuRln is Ownable, RlnBase {
function _register(uint256 idCommitment) internal {
_validateRegistration(idCommitment);
members[idCommitment] = 1;
members[idCommitment] = idCommitmentIndex;
memberExists[idCommitment] = true;
emit MemberRegistered(idCommitment, idCommitmentIndex);
idCommitmentIndex += 1;
@ -27,7 +31,7 @@ contract WakuRln is Ownable, RlnBase {
function register(uint256[] calldata idCommitments) external onlyOwner {
uint256 len = idCommitments.length;
for (uint256 i = 0; i < len;) {
for (uint256 i = 0; i < len; ) {
_register(idCommitments[i]);
unchecked {
++i;
@ -39,21 +43,28 @@ contract WakuRln is Ownable, RlnBase {
revert NotImplemented();
}
function slash(uint256 idCommitment, address payable receiver, uint256[8] calldata proof) external pure override {
function slash(
uint256 idCommitment,
address payable receiver,
uint256[8] calldata proof
) external pure override {
revert NotImplemented();
}
function _validateRegistration(uint256 idCommitment) internal view override {
if (!isValidCommitment(idCommitment)) revert InvalidIdCommitment(idCommitment);
if (members[idCommitment] != 0) revert DuplicateIdCommitment();
function _validateRegistration(
uint256 idCommitment
) internal view override {
if (!isValidCommitment(idCommitment))
revert InvalidIdCommitment(idCommitment);
if (memberExists[idCommitment] == true) revert DuplicateIdCommitment();
if (idCommitmentIndex >= SET_SIZE) revert FullTree();
}
function _validateSlash(uint256 idCommitment, address payable receiver, uint256[8] calldata proof)
internal
pure
override
{
function _validateSlash(
uint256 idCommitment,
address payable receiver,
uint256[8] calldata proof
) internal pure override {
revert NotImplemented();
}

View File

@ -5,7 +5,7 @@
"chainId": "11155111",
"contracts": {
"PoseidonHasher": {
"address": "0xcBC443bAE23a0BeF71d7f23588108C9929C582C2",
"address": "0x9c1c939aCB5c356c91fF2f27E9FD29C5C95E671b",
"abi": [
{
"inputs": [],
@ -42,7 +42,7 @@
]
},
"WakuRlnRegistry": {
"address": "0x8e1F3742B987d8BA376c0CBbD7357fE1F003ED71",
"address": "0x0A988fd9CA5BAebDf098b8A73621b2AaDa6492E8",
"abi": [
{
"inputs": [
@ -289,7 +289,7 @@
]
},
"WakuRlnStorage_0": {
"address": "0xb61a949493847FF51A82d2617FEdAeD5D67cf785",
"address": "0x02A29114ECDE0Da4D6DB61eAE73a86486cB88c10",
"abi": [
{
"inputs": [
@ -487,6 +487,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "memberExists",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
Subproject commit bd8403a74e327707afb70e60f582e2546e487891
Subproject commit 35f2182669264e222bb6de6eb58465d81c5719b0