mirror of
https://github.com/vacp2p/rln-contract.git
synced 2026-01-09 12:58:00 -05:00
chore: waku-rln test deployment with LazyIMT
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -3,11 +3,12 @@ pragma solidity >=0.8.19;
|
||||
|
||||
import { Verifier } from "../src/RlnVerifier.sol";
|
||||
import { Rln } from "../src/Rln.sol";
|
||||
import { WakuRln } from "../src/WakuRln.sol";
|
||||
import { BaseScript } from "./Base.s.sol";
|
||||
import { DeploymentConfig } from "./DeploymentConfig.s.sol";
|
||||
|
||||
contract Deploy is BaseScript {
|
||||
function run() public returns (Rln rln, DeploymentConfig deploymentConfig) {
|
||||
function run() public returns (Rln rln, WakuRln wakuRln, DeploymentConfig deploymentConfig) {
|
||||
deploymentConfig = new DeploymentConfig(broadcaster);
|
||||
|
||||
vm.startBroadcast(broadcaster);
|
||||
@@ -15,6 +16,9 @@ contract Deploy is BaseScript {
|
||||
Verifier verifier = new Verifier();
|
||||
// step 2: deploy the rln contract
|
||||
rln = new Rln(0, 20, address(verifier));
|
||||
// step 3: deploy WakuRln
|
||||
wakuRln = new WakuRln(0, 20, address(verifier));
|
||||
vm.stopBroadcast();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,29 +67,29 @@ if [ "$contract_name" = "rln" ]; then
|
||||
fi
|
||||
|
||||
|
||||
forge script script/Deploy.s.sol:Deploy --chain $chain_name --rpc-url $rpc_url --private-key "$PRIVATE_KEY" --broadcast -v
|
||||
# forge script script/Deploy.s.sol:Deploy --chain $chain_name --rpc-url $rpc_url --private-key "$PRIVATE_KEY" --broadcast -v --legacy
|
||||
echo "Deployed Rln contracts, Now verifying"
|
||||
|
||||
# Get the PoseidonT3 contract address from ./broadcast/Deploy.s.sol/$chain_id/run-latest.json
|
||||
poseidon_t3_name=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][0]["contractName"]')
|
||||
poseidon_t3_address=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][0]["contractAddress"]')
|
||||
poseidon_t3_name=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][1]["contractName"]')
|
||||
poseidon_t3_address=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][1]["contractAddress"]')
|
||||
|
||||
echo "Verifying $poseidon_t3_name library"
|
||||
forge verify-contract $poseidon_t3_address \
|
||||
forge verify-contract $poseidon_t3_address --verifier-url "https://api-cardona-zkevm.polygonscan.com/api" \
|
||||
--watch \
|
||||
--chain $chain_name \
|
||||
$poseidon_t3_name
|
||||
|
||||
# Get the LazyIMT contract address from ./broadcast/Deploy.s.sol/$chain_id/run-latest.json
|
||||
lazy_imt_name=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][1]["contractName"]')
|
||||
lazy_imt_address=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][1]["contractAddress"]')
|
||||
lazy_imt_name=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][0]["contractName"]')
|
||||
lazy_imt_address=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][0]["contractAddress"]')
|
||||
|
||||
echo "Verifying $lazy_imt_name library"
|
||||
forge verify-contract $lazy_imt_address \
|
||||
--libraries "poseidon-solidity/PoseidonT3.sol:$poseidon_t3_name:$poseidon_t3_address" \
|
||||
--watch \
|
||||
--chain $chain_name \
|
||||
$lazy_imt_name
|
||||
$lazy_imt_name
|
||||
|
||||
# Get the Verifier contract address from ./broadcast/Deploy.s.sol/$chain_id/run-latest.json
|
||||
verifier_name=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][2]["contractName"]')
|
||||
@@ -108,7 +108,7 @@ if [ "$contract_name" = "rln" ]; then
|
||||
echo "Verifying $rln_name contract"
|
||||
forge verify-contract $rln_address \
|
||||
--libraries "poseidon-solidity/PoseidonT3.sol:$poseidon_t3_name:$poseidon_t3_address" \
|
||||
--libraries "@zk-kit/imt.sol/BinaryIMT.sol:$binary_imt_name:$binary_imt_address" \
|
||||
--libraries "@zk-kit/imt.sol/LazyIMT.sol:$lazy_imt_name:$lazy_imt_address" \
|
||||
--watch \
|
||||
--chain $chain_name \
|
||||
$rln_name \
|
||||
@@ -116,9 +116,21 @@ if [ "$contract_name" = "rln" ]; then
|
||||
|
||||
echo "Verified $rln_name contract, now dumping the artifacts to ./deployments/$chain_id/latest.json"
|
||||
|
||||
waku_rln_name=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][4]["contractName"]')
|
||||
waku_rln_address=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][4]["contractAddress"]')
|
||||
|
||||
echo "Verifying $waku_rln_name contract"
|
||||
forge verify-contract $waku_rln_address \
|
||||
--libraries "poseidon-solidity/PoseidonT3.sol:$poseidon_t3_name:$poseidon_t3_address" \
|
||||
--libraries "@zk-kit/imt.sol/LazyIMT.sol:$lazy_imt_name:$lazy_imt_address" \
|
||||
--watch \
|
||||
--chain $chain_name \
|
||||
$waku_rln_name \
|
||||
--constructor-args $(cast abi-encode "constructor(uint256,uint256,address)" 0 20 "$verifier_address")
|
||||
|
||||
# Dump the artifacts to ./deployments/$chain_id/latest.json
|
||||
mkdir -p ./deployments/$chain_id
|
||||
cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"]' > ./deployments/$chain_id/latest.json
|
||||
else
|
||||
echo "Invalid contract name, please use rln."
|
||||
fi
|
||||
fi
|
||||
|
||||
46
src/WakuRln.sol
Normal file
46
src/WakuRln.sol
Normal file
@@ -0,0 +1,46 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.19;
|
||||
|
||||
import "./RlnBase.sol";
|
||||
|
||||
contract WakuRln is RlnBase {
|
||||
uint16 public usingStorageIndex = 0;
|
||||
|
||||
function storages(uint16 index) public view returns (address) {
|
||||
return address(this);
|
||||
}
|
||||
|
||||
function register(uint16 storageIndex, uint256[] calldata commitments) public {
|
||||
for (uint i = 0; i < commitments.length; i++) {
|
||||
_register(commitments[i], 0);
|
||||
}
|
||||
}
|
||||
|
||||
function register(uint256[] calldata commitments) public {
|
||||
register(usingStorageIndex, commitments);
|
||||
}
|
||||
|
||||
function register(uint16 storageIndex, uint256 commitment) public {
|
||||
_register(commitment, 0);
|
||||
}
|
||||
|
||||
constructor(
|
||||
uint256 membershipDeposit,
|
||||
uint256 depth,
|
||||
address _verifier
|
||||
)
|
||||
RlnBase(membershipDeposit, depth, _verifier)
|
||||
{ }
|
||||
|
||||
function _validateRegistration(uint256 idCommitment) internal pure override { }
|
||||
|
||||
function _validateSlash(
|
||||
uint256 idCommitment,
|
||||
address payable receiver,
|
||||
uint256[8] calldata proof
|
||||
)
|
||||
internal
|
||||
pure
|
||||
override
|
||||
{ }
|
||||
}
|
||||
Reference in New Issue
Block a user