feat: Ownable2StepUpgradeable to OwnableUpgradeable

This allows the contract to transfer ownership to address 0x000...000 as defined in https://github.com/waku-org/specs/pull/34: `At some point, the _Owner_ SHOULD renounce their privileges, and the contract MUST become immutable`. The problem with `Ownable2StepUpgradeable` is that it requires accepting the ownership transfer, which is not possible with address 0x0
This commit is contained in:
Richard Ramos 2024-10-03 09:41:32 -04:00
parent 3fea0a5201
commit 113b571021
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760
3 changed files with 7 additions and 8 deletions

View File

@ -1,21 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import { Ownable2Step } from "openzeppelin-contracts/contracts/access/Ownable2Step.sol";
import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol";
import { IPriceCalculator } from "./IPriceCalculator.sol";
/// Address 0x0000...0000 was used instead of an ERC20 token address
error OnlyTokensAllowed();
/// @title Linear Price Calculator to determine the price to acquire a membership
contract LinearPriceCalculator is IPriceCalculator, Ownable2Step {
contract LinearPriceCalculator is IPriceCalculator, Ownable {
/// @notice Address of the ERC20 token accepted by this contract.
address public token;
/// @notice The price per message per epoch
uint256 public pricePerMessagePerEpoch;
constructor(address _token, uint256 _pricePerMessagePerEpoch) Ownable2Step() {
constructor(address _token, uint256 _pricePerMessagePerEpoch) Ownable() {
_setTokenAndPrice(_token, _pricePerMessagePerEpoch);
}

View File

@ -4,7 +4,7 @@ pragma solidity 0.8.24;
import { LazyIMT, LazyIMTData } from "@zk-kit/imt.sol/LazyIMT.sol";
import { PoseidonT3 } from "poseidon-solidity/PoseidonT3.sol";
import { Ownable2StepUpgradeable } from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
@ -20,7 +20,7 @@ error InvalidIdCommitment(uint256 idCommitment);
/// Invalid pagination query
error InvalidPaginationQuery(uint256 startIndex, uint256 endIndex);
contract WakuRlnV2 is Initializable, Ownable2StepUpgradeable, UUPSUpgradeable, MembershipUpgradeable {
contract WakuRlnV2 is Initializable, OwnableUpgradeable, UUPSUpgradeable, MembershipUpgradeable {
/// @notice The Field
uint256 public constant Q =
21_888_242_871_839_275_222_246_405_745_257_275_088_548_364_400_416_034_343_698_204_186_575_808_495_617;

View File

@ -691,8 +691,7 @@ contract WakuRlnV2Test is Test {
/*| Name | Type | Slot | Offset | Bytes |
|---------------------|-----------------------------------------------------|------|--------|-------|
| nextFreeIndex | uint32 | 256 | 0 | 4 | */
| nextFreeIndex | uint32 | 206 | 0 | 4 | */
/*
Pro tip: to easily find the storage slot of a variable, without having to calculate the storage layout
based on the variable declaration, set the variable to an easily grepable value like 0xDEADBEEF, and then
@ -710,7 +709,7 @@ contract WakuRlnV2Test is Test {
*/
// we set nextFreeIndex to 4294967295 (1 << 20) = 0x00100000
vm.store(address(w), bytes32(uint256(256)), 0x0000000000000000000000000000000000000000000000000000000000100000);
vm.store(address(w), bytes32(uint256(206)), 0x0000000000000000000000000000000000000000000000000000000000100000);
token.approve(address(w), price);
vm.expectRevert(bytes("Membership set is full"));
w.register(1, membershipRateLimit, noIdCommitmentsToErase);