Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: waku-rln test deployment with LazyIMT #38

Open
wants to merge 2 commits into
base: compute-root-view-fn
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 61 additions & 22 deletions deployments/2442/latest.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ 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);
// step 1: deploy the verifier
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();
}
}
30 changes: 21 additions & 9 deletions script/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"]')
Expand All @@ -108,17 +108,29 @@ 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 \
--constructor-args $(cast abi-encode "constructor(uint256,uint256,address)" 0 20 "$verifier_address")

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 changes: 46 additions & 0 deletions src/WakuRln.sol
Original file line number Diff line number Diff line change
@@ -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 (uint256 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
{ }
}
Loading