Skip to content

Commit

Permalink
feat(WakuRln): zero indexed deployments and updated dependency (#8)
Browse files Browse the repository at this point in the history
* fix: update submodule

* feat(rln): zero indexed deployment
  • Loading branch information
rymnc committed Sep 5, 2023
1 parent 63a7856 commit e5eefe4
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
35 changes: 23 additions & 12 deletions contracts/WakuRln.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -19,15 +22,16 @@ 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;
}

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;
Expand All @@ -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();
}

Expand Down
25 changes: 22 additions & 3 deletions deployments/allDeployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"chainId": "11155111",
"contracts": {
"PoseidonHasher": {
"address": "0xcBC443bAE23a0BeF71d7f23588108C9929C582C2",
"address": "0x9c1c939aCB5c356c91fF2f27E9FD29C5C95E671b",
"abi": [
{
"inputs": [],
Expand Down Expand Up @@ -42,7 +42,7 @@
]
},
"WakuRlnRegistry": {
"address": "0x8e1F3742B987d8BA376c0CBbD7357fE1F003ED71",
"address": "0x0A988fd9CA5BAebDf098b8A73621b2AaDa6492E8",
"abi": [
{
"inputs": [
Expand Down Expand Up @@ -289,7 +289,7 @@
]
},
"WakuRlnStorage_0": {
"address": "0xb61a949493847FF51A82d2617FEdAeD5D67cf785",
"address": "0x02A29114ECDE0Da4D6DB61eAE73a86486cB88c10",
"abi": [
{
"inputs": [
Expand Down Expand Up @@ -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": [
{
Expand Down
18 changes: 9 additions & 9 deletions deployments/sepolia/PoseidonHasher.json

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions deployments/sepolia/WakuRlnRegistry.json

Large diffs are not rendered by default.

33 changes: 26 additions & 7 deletions deployments/sepolia/WakuRlnStorage_0.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/rln-contract

0 comments on commit e5eefe4

Please sign in to comment.