mirror of
https://github.com/logos-messaging/logos-messaging-rlnv2-contract.git
synced 2026-02-25 16:23:09 +00:00
chore: emit rate commitment instead of idcommitment
This commit is contained in:
parent
48542f3f04
commit
df935b863d
@ -1,14 +1,14 @@
|
||||
WakuRlnV2Test:test__IdCommitmentToMetadata__DoesntExist() (gas: 16723)
|
||||
WakuRlnV2Test:test__InvalidPaginationQuery__EndIndexGTIdCommitmentIndex() (gas: 18260)
|
||||
WakuRlnV2Test:test__InvalidPaginationQuery__StartIndexGTEndIndex() (gas: 16083)
|
||||
WakuRlnV2Test:test__InvalidRegistration__DuplicateIdCommitment() (gas: 99824)
|
||||
WakuRlnV2Test:test__InvalidPaginationQuery__EndIndexGTcommitmentIndex() (gas: 18268)
|
||||
WakuRlnV2Test:test__InvalidPaginationQuery__StartIndexGTEndIndex() (gas: 16139)
|
||||
WakuRlnV2Test:test__InvalidRegistration__DuplicateIdCommitment() (gas: 99516)
|
||||
WakuRlnV2Test:test__InvalidRegistration__FullTree() (gas: 14343)
|
||||
WakuRlnV2Test:test__InvalidRegistration__InvalidIdCommitment__LargerThanField() (gas: 15258)
|
||||
WakuRlnV2Test:test__InvalidRegistration__InvalidIdCommitment__Zero() (gas: 14046)
|
||||
WakuRlnV2Test:test__InvalidRegistration__InvalidUserMessageLimit__LargerThanMax() (gas: 17639)
|
||||
WakuRlnV2Test:test__InvalidRegistration__InvalidUserMessageLimit__Zero() (gas: 14126)
|
||||
WakuRlnV2Test:test__Upgrade() (gas: 3668443)
|
||||
WakuRlnV2Test:test__ValidPaginationQuery(uint32) (runs: 1000, μ: 446587, ~: 159861)
|
||||
WakuRlnV2Test:test__ValidPaginationQuery__OneElement() (gas: 120064)
|
||||
WakuRlnV2Test:test__ValidRegistration(uint256,uint32) (runs: 1000, μ: 124674, ~: 124674)
|
||||
WakuRlnV2Test:test__ValidRegistration__kats() (gas: 96917)
|
||||
WakuRlnV2Test:test__InvalidRegistration__InvalidIdCommitment__LargerThanField() (gas: 15236)
|
||||
WakuRlnV2Test:test__InvalidRegistration__InvalidIdCommitment__Zero() (gas: 14024)
|
||||
WakuRlnV2Test:test__InvalidRegistration__InvalidUserMessageLimit__LargerThanMax() (gas: 17706)
|
||||
WakuRlnV2Test:test__InvalidRegistration__InvalidUserMessageLimit__Zero() (gas: 14104)
|
||||
WakuRlnV2Test:test__Upgrade() (gas: 1586357)
|
||||
WakuRlnV2Test:test__ValidPaginationQuery(uint32) (runs: 1000, μ: 451897, ~: 159861)
|
||||
WakuRlnV2Test:test__ValidPaginationQuery__OneElement() (gas: 119778)
|
||||
WakuRlnV2Test:test__ValidRegistration(uint256,uint32) (runs: 1000, μ: 124275, ~: 124275)
|
||||
WakuRlnV2Test:test__ValidRegistration__kats() (gas: 96609)
|
||||
@ -38,7 +38,7 @@ contract WakuRlnV2 is Initializable, OwnableUpgradeable, UUPSUpgradeable {
|
||||
uint32 public SET_SIZE;
|
||||
|
||||
/// @notice The index of the next member to be registered
|
||||
uint32 public idCommitmentIndex;
|
||||
uint32 public commitmentIndex;
|
||||
|
||||
/// @notice the membership metadata of the member
|
||||
struct MembershipInfo {
|
||||
@ -58,10 +58,9 @@ contract WakuRlnV2 is Initializable, OwnableUpgradeable, UUPSUpgradeable {
|
||||
LazyIMTData public imtData;
|
||||
|
||||
/// Emitted when a new member is added to the set
|
||||
/// @param idCommitment The idCommitment of the member
|
||||
/// @param userMessageLimit the user message limit of the member
|
||||
/// @param rateCommitment the rateCommitment of the member
|
||||
/// @param index The index of the member in the set
|
||||
event MemberRegistered(uint256 idCommitment, uint32 userMessageLimit, uint32 index);
|
||||
event MemberRegistered(uint256 rateCommitment, uint32 index);
|
||||
|
||||
/// @notice the modifier to check if the idCommitment is valid
|
||||
/// @param idCommitment The idCommitment of the member
|
||||
@ -88,7 +87,7 @@ contract WakuRlnV2 is Initializable, OwnableUpgradeable, UUPSUpgradeable {
|
||||
SET_SIZE = uint32(1 << DEPTH);
|
||||
deployedBlockNumber = uint32(block.number);
|
||||
LazyIMT.init(imtData, DEPTH);
|
||||
idCommitmentIndex = 0;
|
||||
commitmentIndex = 0;
|
||||
}
|
||||
|
||||
function _authorizeUpgrade(address newImplementation) internal override onlyOwner { } // solhint-disable-line
|
||||
@ -153,15 +152,15 @@ contract WakuRlnV2 is Initializable, OwnableUpgradeable, UUPSUpgradeable {
|
||||
/// @param userMessageLimit The message limit of the member
|
||||
function _register(uint256 idCommitment, uint32 userMessageLimit) internal {
|
||||
if (memberExists(idCommitment)) revert DuplicateIdCommitment();
|
||||
if (idCommitmentIndex >= SET_SIZE) revert FullTree();
|
||||
if (commitmentIndex >= SET_SIZE) revert FullTree();
|
||||
|
||||
uint256 rateCommitment = PoseidonT3.hash([idCommitment, userMessageLimit]);
|
||||
MembershipInfo memory member = MembershipInfo({ userMessageLimit: userMessageLimit, index: idCommitmentIndex });
|
||||
MembershipInfo memory member = MembershipInfo({ userMessageLimit: userMessageLimit, index: commitmentIndex });
|
||||
LazyIMT.insert(imtData, rateCommitment);
|
||||
memberInfo[idCommitment] = member;
|
||||
|
||||
emit MemberRegistered(idCommitment, userMessageLimit, idCommitmentIndex);
|
||||
idCommitmentIndex += 1;
|
||||
emit MemberRegistered(rateCommitment, commitmentIndex);
|
||||
commitmentIndex += 1;
|
||||
}
|
||||
|
||||
/// @notice Returns the commitments of a range of members
|
||||
@ -170,7 +169,7 @@ contract WakuRlnV2 is Initializable, OwnableUpgradeable, UUPSUpgradeable {
|
||||
/// @return The commitments of the members
|
||||
function getCommitments(uint32 startIndex, uint32 endIndex) public view returns (uint256[] memory) {
|
||||
if (startIndex > endIndex) revert InvalidPaginationQuery(startIndex, endIndex);
|
||||
if (endIndex > idCommitmentIndex) revert InvalidPaginationQuery(startIndex, endIndex);
|
||||
if (endIndex > commitmentIndex) revert InvalidPaginationQuery(startIndex, endIndex);
|
||||
|
||||
uint256[] memory commitments = new uint256[](endIndex - startIndex + 1);
|
||||
for (uint32 i = startIndex; i <= endIndex; i++) {
|
||||
|
||||
@ -27,7 +27,7 @@ contract WakuRlnV2Test is Test {
|
||||
vm.resumeGasMetering();
|
||||
w.register(idCommitment, userMessageLimit);
|
||||
vm.pauseGasMetering();
|
||||
assertEq(w.idCommitmentIndex(), 1);
|
||||
assertEq(w.commitmentIndex(), 1);
|
||||
assertEq(w.memberExists(idCommitment), true);
|
||||
(uint32 fetchedUserMessageLimit, uint32 index) = w.memberInfo(idCommitment);
|
||||
assertEq(fetchedUserMessageLimit, userMessageLimit);
|
||||
@ -138,13 +138,13 @@ contract WakuRlnV2Test is Test {
|
||||
|---------------------|-----------------------------------------------------|------|--------|-------|
|
||||
| MAX_MESSAGE_LIMIT | uint32 | 0 | 0 | 4 |
|
||||
| SET_SIZE | uint32 | 0 | 4 | 4 |
|
||||
| idCommitmentIndex | uint32 | 0 | 8 | 4 |
|
||||
| commitmentIndex | uint32 | 0 | 8 | 4 |
|
||||
| memberInfo | mapping(uint256 => struct WakuRlnV2.MembershipInfo) | 1 | 0 | 32 |
|
||||
| deployedBlockNumber | uint32 | 2 | 0 | 4 |
|
||||
| imtData | struct LazyIMTData | 3 | 0 | 64 |*/
|
||||
// we set MAX_MESSAGE_LIMIT to 20 (unaltered)
|
||||
// we set SET_SIZE to 4294967295 (1 << 20) (unaltered)
|
||||
// we set idCommitmentIndex to 4294967295 (1 << 20) (altered)
|
||||
// we set commitmentIndex to 4294967295 (1 << 20) (altered)
|
||||
vm.store(address(w), bytes32(0), 0x0000000000000000000000000000000000000000ffffffffffffffff00000014);
|
||||
vm.expectRevert(FullTree.selector);
|
||||
w.register(1, userMessageLimit);
|
||||
@ -155,7 +155,7 @@ contract WakuRlnV2Test is Test {
|
||||
w.getCommitments(1, 0);
|
||||
}
|
||||
|
||||
function test__InvalidPaginationQuery__EndIndexGTIdCommitmentIndex() external {
|
||||
function test__InvalidPaginationQuery__EndIndexGTcommitmentIndex() external {
|
||||
vm.expectRevert(abi.encodeWithSelector(InvalidPaginationQuery.selector, 0, 2));
|
||||
w.getCommitments(0, 2);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user