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

[VEN-2687]: give permission on ZKsync using ACMAggregator for multichain governance #93

Merged
merged 9 commits into from
Nov 6, 2024
122 changes: 122 additions & 0 deletions deploy/009-initial-configuration-multichain-governance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { ethers, network } from "hardhat";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { ACMCommandsAggregator } from "typechain";

import { SUPPORTED_NETWORKS } from "../helpers/deploy/constants";
import { guardian } from "../helpers/deploy/deploymentUtils";

const functionSignatures = {
normal: [
"setSendVersion(uint16)",
"setReceiveVersion(uint16)",
"setMaxDailyReceiveLimit(uint256)",
"pause()",
"setPrecrime(address)",
"setMinDstGas(uint16,uint16,uint256)",
"setPayloadSizeLimit(uint16,uint256)",
"setConfig(uint16,uint16,uint256,bytes)",
"addTimelocks(address[])",
"setTrustedRemoteAddress(uint16,bytes)",
"setTimelockPendingAdmin(address,uint8)",
"retryMessage(uint16,bytes,uint64,bytes)",
"setGuardian(address)",
"setSrcChainId(uint16)",
"transferBridgeOwnership(address)",
],
fasttrack: [
"setReceiveVersion(uint16)",
"setMaxDailyReceiveLimit(uint256)",
"pause()",
"setConfig(uint16,uint16,uint256,bytes)",
"addTimelocks(address[])",
"retryMessage(uint16,bytes,uint64,bytes)",
],
critical: [
"setReceiveVersion(uint16)",
"setMaxDailyReceiveLimit(uint256)",
"pause()",
"setConfig(uint16,uint16,uint256,bytes)",
"addTimelocks(address[])",
"retryMessage(uint16,bytes,uint64,bytes)",
],
guardian: [
"setReceiveVersion(uint16)",
"forceResumeReceive(uint16,bytes)",
"setMaxDailyReceiveLimit(uint256)",
"pause()",
"unpause()",
"setConfig(uint16,uint16,uint256,bytes)",
"addTimelocks(address[])",
"setTrustedRemoteAddress(uint16,bytes)",
"setTimelockPendingAdmin(address,uint8)",
"retryMessage(uint16,bytes,uint64,bytes)",
"setSrcChainId(uint16)",
"transferBridgeOwnership(address)",
],
};

const grantPermissions = (
OMNICHAIN_EXECUTOR_OWNER: string,
functionSigs: string[],
account: string,
): ACMCommandsAggregator.PermissionStruct[] =>
functionSigs.map(functionSig => ({
contractAddress: OMNICHAIN_EXECUTOR_OWNER,
functionSig: functionSig,
account: account,
}));

const func: DeployFunction = async function () {
const NORMAL_TIMELOCK = await ethers.getContract("NormalTimelock");
const FASTTRACK_TIMELOCK = await ethers.getContract("FastTrackTimelock");
const CRITICAL_TIMELOCK = await ethers.getContract("CriticalTimelock");
const OMNICHAIN_EXECUTOR_OWNER = await ethers.getContract("OmnichainExecutorOwner");
const GUARDIAN = await guardian(network.name as SUPPORTED_NETWORKS);
const acmCommandsAggregator: ACMCommandsAggregator = await ethers.getContract("ACMCommandsAggregator");

// Grant permissions for each category
const normalGrantPermissions = grantPermissions(
OMNICHAIN_EXECUTOR_OWNER.address,
functionSignatures.normal,
NORMAL_TIMELOCK.address,
);
const fasttrackGrantPermissions = grantPermissions(
OMNICHAIN_EXECUTOR_OWNER.address,
functionSignatures.fasttrack,
FASTTRACK_TIMELOCK.address,
);
const criticalGrantPermissions = grantPermissions(
OMNICHAIN_EXECUTOR_OWNER.address,
functionSignatures.critical,
CRITICAL_TIMELOCK.address,
);
const guardianGrantPermissions = grantPermissions(
OMNICHAIN_EXECUTOR_OWNER.address,
functionSignatures.guardian,
GUARDIAN,
);

const allGrantPermissions: ACMCommandsAggregator.PermissionStruct[] = [
...normalGrantPermissions,
...fasttrackGrantPermissions,
...criticalGrantPermissions,
...guardianGrantPermissions,
];

try {
const tx = await acmCommandsAggregator.addGrantPermissions(allGrantPermissions);

const receipt = await tx.wait();
const events = receipt.events?.filter(event => event.event === "GrantPermissionsAdded");
console.log(`Grant Permissions for ${network.name} added with indexes: `, events?.[0].args?.index.toString());
} catch (error) {
console.error("Error adding grant permissions:", error);
}
};
func.tags = ["multichain-governance-permissions"];

func.skip = async (hre: HardhatRuntimeEnvironment) =>
hre.network.name === "bsctestnet" || hre.network.name === "bscmainnet";

export default func;
245 changes: 245 additions & 0 deletions deployments/zksyncsepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,251 @@
"name": "zksyncsepolia",
"chainId": "300",
"contracts": {
"ACMCommandsAggregator": {
"address": "0x920Bb18c4bd4D7bc41Bf39933BCAa3D078641502",
"abi": [
{
"inputs": [
{
"internalType": "contract IAccessControlManagerV8",
"name": "_acm",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "EmptyPermissions",
"type": "error"
},
{
"inputs": [],
"name": "ZeroAddressNotAllowed",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "GrantPermissionsAdded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "GrantPermissionsExecuted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "RevokePermissionsAdded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "RevokePermissionsExecuted",
"type": "event"
},
{
"inputs": [],
"name": "ACM",
"outputs": [
{
"internalType": "contract IAccessControlManagerV8",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "contractAddress",
"type": "address"
},
{
"internalType": "string",
"name": "functionSig",
"type": "string"
},
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"internalType": "struct ACMCommandsAggregator.Permission[]",
"name": "_permissions",
"type": "tuple[]"
}
],
"name": "addGrantPermissions",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "contractAddress",
"type": "address"
},
{
"internalType": "string",
"name": "functionSig",
"type": "string"
},
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"internalType": "struct ACMCommandsAggregator.Permission[]",
"name": "_permissions",
"type": "tuple[]"
}
],
"name": "addRevokePermissions",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "executeGrantPermissions",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "executeRevokePermissions",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "grantPermissions",
"outputs": [
{
"internalType": "address",
"name": "contractAddress",
"type": "address"
},
{
"internalType": "string",
"name": "functionSig",
"type": "string"
},
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "revokePermissions",
"outputs": [
{
"internalType": "address",
"name": "contractAddress",
"type": "address"
},
{
"internalType": "string",
"name": "functionSig",
"type": "string"
},
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
]
},
"AccessControlManager": {
"address": "0xD07f543d47c3a8997D6079958308e981AC14CD01",
"abi": [
Expand Down
Loading
Loading