mirror of
https://github.com/logos-messaging/logos-messaging-rlnv2-contract.git
synced 2026-01-07 08:23:09 +00:00
test: integrate transparent proxy
This commit is contained in:
parent
ffe9ed0d7f
commit
dd84bdde54
12
foundry.toml
12
foundry.toml
@ -5,7 +5,7 @@
|
||||
block_timestamp = 1_680_220_800 # March 31, 2023 at 00:00 GMT
|
||||
bytecode_hash = "none"
|
||||
cbor_metadata = false
|
||||
evm_version = "paris"
|
||||
evm_version = "cancun"
|
||||
fuzz = { runs = 1_000 }
|
||||
gas_reports = ["*"]
|
||||
libs = ["lib"]
|
||||
@ -13,9 +13,14 @@
|
||||
optimizer_runs = 10_000
|
||||
out = "out"
|
||||
script = "script"
|
||||
solc = "0.8.19"
|
||||
solc = "0.8.24"
|
||||
src = "src"
|
||||
test = "test"
|
||||
ast = true
|
||||
ffi = true
|
||||
build_info = true
|
||||
extra_output = ["storageLayout"]
|
||||
fs_permissions = [{ access = "read", path = "./out"}]
|
||||
|
||||
[fuzz]
|
||||
max_test_rejects = 128_000
|
||||
@ -41,3 +46,6 @@ max_test_rejects = 128_000
|
||||
[rpc_endpoints]
|
||||
localhost = "http://localhost:8545"
|
||||
sepolia = "https://eth-sepolia.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
|
||||
|
||||
[profile.sepolia]
|
||||
libraries = ["node_modules/@zk-kit/imt.sol/contracts/LazyIMT.sol:LazyIMT:0x22317F732AE9f9015b0866d03319a441FB42cd7f", "node_modules/poseidon-solidity/PoseidonT3.sol:PoseidonT3:0x4CF6285AC1E3ddAD6E1E378146CbCd3A6CA3Ed60"]
|
||||
|
||||
2
lib/forge-std
vendored
2
lib/forge-std
vendored
@ -1 +1 @@
|
||||
Subproject commit 74cfb77e308dd188d2f58864aaf44963ae6b88b1
|
||||
Subproject commit 978ac6fadb62f5f0b723c996f64be52eddba6801
|
||||
2
lib/openzeppelin-contracts-upgradeable
vendored
2
lib/openzeppelin-contracts-upgradeable
vendored
@ -1 +1 @@
|
||||
Subproject commit 723f8cab09cdae1aca9ec9cc1cfa040c2d4b06c1
|
||||
Subproject commit 0a71a5ebfbf4136cae3176e5cc9bcc5efc23f76b
|
||||
12
package.json
12
package.json
@ -15,15 +15,7 @@
|
||||
"@zk-kit/imt.sol": "https://gitpkg.now.sh/privacy-scaling-explorations/zk-kit/packages/imt.sol?0699fd1e5ad3683ae0090e0626f75d7834145500",
|
||||
"poseidon-solidity": "^0.0.5"
|
||||
},
|
||||
"keywords": [
|
||||
"blockchain",
|
||||
"ethereum",
|
||||
"forge",
|
||||
"foundry",
|
||||
"smart-contracts",
|
||||
"solidity",
|
||||
"template"
|
||||
],
|
||||
"keywords": ["blockchain", "ethereum", "forge", "foundry", "smart-contracts", "solidity", "template"],
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"clean": "rm -rf cache out",
|
||||
@ -34,7 +26,7 @@
|
||||
"gas-report": "forge test --gas-report 2>&1 | (tee /dev/tty | awk '/Test result:/ {found=1; buffer=\"\"; next} found && !/Ran/ {buffer=buffer $0 ORS} /Ran/ {found=0} END {printf \"%s\", buffer}' > .gas-report)",
|
||||
"release": "commit-and-tag-version",
|
||||
"adorno": "pnpm prettier:write && forge fmt && forge snapshot && pnpm gas-report",
|
||||
"deploy:sepolia": "./envCheck.sh && forge script --chain sepolia script/Deploy.s.sol:Deploy --rpc-url $RPC_URL --broadcast --verify -vv --account $ACCOUNT --legacy",
|
||||
"deploy:sepolia": "./envCheck.sh && FOUNDRY_PROFILE=sepolia forge script --chain sepolia script/Deploy.s.sol:Deploy --rpc-url $RPC_URL --broadcast --verify -vv --account $ACCOUNT --legacy",
|
||||
"deploy:localhost": "./envCheck.sh && forge script script/Deploy.s.sol:Deploy --rpc-url $RPC_URL --broadcast -vv --account $ACCOUNT"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
forge-std/=lib/forge-std/src/
|
||||
@zk-kit/imt.sol/=node_modules/@zk-kit/imt.sol/contracts
|
||||
poseidon-solidity/=node_modules/poseidon-solidity/
|
||||
@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/
|
||||
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
|
||||
|
||||
@ -2,11 +2,23 @@
|
||||
pragma solidity >=0.8.19 <=0.9.0;
|
||||
|
||||
import { WakuRlnV2 } from "../src/WakuRlnV2.sol";
|
||||
import { PoseidonT3 } from "poseidon-solidity/PoseidonT3.sol";
|
||||
import { LazyIMT } from "@zk-kit/imt.sol/LazyIMT.sol";
|
||||
import { BaseScript } from "./Base.s.sol";
|
||||
import "forge-std/console.sol";
|
||||
import {Upgrades, Options} from "openzeppelin-foundry-upgrades/Upgrades.sol";
|
||||
import { DeploymentConfig } from "./DeploymentConfig.s.sol";
|
||||
|
||||
contract Deploy is BaseScript {
|
||||
function run() public broadcast returns (WakuRlnV2 w) {
|
||||
w = new WakuRlnV2(20);
|
||||
Options memory opts;
|
||||
/*opts.unsafeAllow = "external-library-linking";*/
|
||||
opts.unsafeSkipAllChecks = true;
|
||||
address proxy = Upgrades.deployTransparentProxy(
|
||||
"WakuRlnV2.sol:WakuRlnV2",
|
||||
msg.sender,
|
||||
abi.encodeCall(WakuRlnV2.initialize, (msg.sender, 20)), opts
|
||||
);
|
||||
w = WakuRlnV2(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity 0.8.19;
|
||||
pragma solidity 0.8.24;
|
||||
|
||||
import { LazyIMT, LazyIMTData } from "@zk-kit/imt.sol/LazyIMT.sol";
|
||||
import { PoseidonT3 } from "poseidon-solidity/PoseidonT3.sol";
|
||||
|
||||
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
||||
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
||||
|
||||
/// The tree is full
|
||||
error FullTree();
|
||||
|
||||
@ -20,22 +22,22 @@ error InvalidUserMessageLimit(uint32 messageLimit);
|
||||
/// Invalid pagination query
|
||||
error InvalidPaginationQuery(uint256 startIndex, uint256 endIndex);
|
||||
|
||||
contract WakuRlnV2 {
|
||||
contract WakuRlnV2 is Initializable, OwnableUpgradeable {
|
||||
/// @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;
|
||||
|
||||
/// @notice The max message limit per epoch
|
||||
uint32 public immutable MAX_MESSAGE_LIMIT;
|
||||
uint32 public MAX_MESSAGE_LIMIT;
|
||||
|
||||
/// @notice The depth of the merkle tree
|
||||
uint8 public constant DEPTH = 20;
|
||||
|
||||
/// @notice The size of the merkle tree, i.e 2^depth
|
||||
uint32 public immutable SET_SIZE;
|
||||
uint32 public SET_SIZE;
|
||||
|
||||
/// @notice The index of the next member to be registered
|
||||
uint32 public idCommitmentIndex = 0;
|
||||
uint32 public idCommitmentIndex;
|
||||
|
||||
/// @notice the membership metadata of the member
|
||||
struct MembershipInfo {
|
||||
@ -49,7 +51,7 @@ contract WakuRlnV2 {
|
||||
mapping(uint256 => MembershipInfo) public memberInfo;
|
||||
|
||||
/// @notice the deployed block number
|
||||
uint32 public immutable deployedBlockNumber;
|
||||
uint32 public deployedBlockNumber;
|
||||
|
||||
/// @notice the stored imt data
|
||||
LazyIMTData public imtData;
|
||||
@ -74,12 +76,13 @@ contract WakuRlnV2 {
|
||||
_;
|
||||
}
|
||||
|
||||
/// @notice the constructor of the contract
|
||||
constructor(uint32 maxMessageLimit) {
|
||||
function initialize(address initialOwner, uint32 maxMessageLimit) public initializer {
|
||||
__Ownable_init(initialOwner);
|
||||
MAX_MESSAGE_LIMIT = maxMessageLimit;
|
||||
SET_SIZE = uint32(1 << DEPTH);
|
||||
deployedBlockNumber = uint32(block.number);
|
||||
LazyIMT.init(imtData, DEPTH);
|
||||
idCommitmentIndex = 0;
|
||||
}
|
||||
|
||||
/// @notice Checks if a commitment is valid
|
||||
|
||||
@ -90,7 +90,7 @@ contract WakuRlnV2Test is Test {
|
||||
assertEq(fetchedRateCommitment, rateCommitment);
|
||||
}
|
||||
|
||||
function test__IdCommitmentToMetadata__DoesntExist() external {
|
||||
function test__IdCommitmentToMetadata__DoesntExist() external view {
|
||||
uint256 idCommitment = 2;
|
||||
(uint32 userMessageLimit, uint32 index, uint256 rateCommitment) = w.idCommitmentToMetadata(idCommitment);
|
||||
assertEq(userMessageLimit, 0);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user