Skip to content

Commit

Permalink
Merge branch 'develop' into feat/VEN-2904
Browse files Browse the repository at this point in the history
  • Loading branch information
GitGuru7 committed Feb 4, 2025
2 parents 5d5e658 + db98828 commit 1bc373f
Show file tree
Hide file tree
Showing 138 changed files with 61,944 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ ARCHIVE_NODE_ethereum=https://eth-mainnet.nodereal.io/v1/<YOUR_KEY_HERE>
#ARCHIVE_NODE_zksyncmainnet=https://open-platform.nodereal.io/<YOUR_KEY_HERE>/zksync
#ARCHIVE_NODE_opsepolia=https://sepolia.optimism.io
#ARCHIVE_NODE_opmainnet=https://opt-mainnet.nodereal.io/v1/<YOUR_KEY_HERE>
ARCHIVE_NODE_basesepolia=https://sepolia.base.org
ARCHIVE_NODE_basemainnet=https://open-platform.nodereal.io/<YOUR_KEY_HERE>/base
#ARCHIVE_NODE_unichainsepolia=https://unichain-sepolia.g.alchemy.com/v2/<YOUR_KEY_HERE>

ETHERSCAN_API_KEY=
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:

- name: Export deployments
run: |
for NETWORK in bsctestnet bscmainnet ethereum sepolia opbnbtestnet opbnbmainnet arbitrumsepolia arbitrumone opsepolia opmainnet unichainsepolia; do
for NETWORK in bsctestnet bscmainnet ethereum sepolia opbnbtestnet opbnbmainnet arbitrumsepolia arbitrumone opsepolia opmainnet basesepolia basemainnet unichainsepolia; do
EXPORT=true yarn hardhat export --network ${NETWORK} --export ./deployments/${NETWORK}.json
jq -M '{name, chainId, addresses: .contracts | map_values(.address)}' ./deployments/${NETWORK}.json > ./deployments/${NETWORK}_addresses.json
done
Expand Down
345 changes: 345 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

Binary file not shown.
153 changes: 153 additions & 0 deletions contracts/Utils/ACMCommandsAggregator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

import { IAccessControlManagerV8 } from "../Governance/IAccessControlManagerV8.sol";
import { ensureNonzeroAddress } from "@venusprotocol/solidity-utilities/contracts/validators.sol";

/**
* @title ACMCommandsAggregator
* @author Venus
* @notice This contract is a helper to aggregate multiple grant and revoke permissions in batches and execute them in one go.
*/
contract ACMCommandsAggregator {
/*
* @notice Struct to store permission details
*/
struct Permission {
/*
* @notice Address of the contract
*/
address contractAddress;
/*
* @notice Function signature
*/
string functionSig;
/*
* @notice Address of the account
*/
address account;
}

/**
* @notice Access control manager contract
*/
IAccessControlManagerV8 public immutable ACM;

/*
* @notice 2D array to store grant permissions in batches
*/
Permission[][] public grantPermissions;

/*
* @notice 2D array to store revoke permissions in batches
*/
Permission[][] public revokePermissions;

/*
* @notice Event emitted when grant permissions are added
*/
event GrantPermissionsAdded(uint256 index);

/*
* @notice Event emitted when revoke permissions are added
*/
event RevokePermissionsAdded(uint256 index);

/*
* @notice Event emitted when grant permissions are executed
*/
event GrantPermissionsExecuted(uint256 index);

/*
* @notice Event emitted when revoke permissions are executed
*/
event RevokePermissionsExecuted(uint256 index);

/*
* @notice Error to be thrown when permissions are empty
*/
error EmptyPermissions();

/*
* @notice Constructor to set the access control manager
* @param _acm Address of the access control manager
*/
constructor(IAccessControlManagerV8 _acm) {
ensureNonzeroAddress(address(_acm));
ACM = _acm;
}

/*
* @notice Function to add grant permissions
* @param _permissions Array of permissions
* @custom:event Emits GrantPermissionsAdded event
*/
function addGrantPermissions(Permission[] memory _permissions) external {
if (_permissions.length == 0) {
revert EmptyPermissions();
}

uint256 index = grantPermissions.length;
grantPermissions.push();

for (uint256 i; i < _permissions.length; ++i) {
grantPermissions[index].push(
Permission(_permissions[i].contractAddress, _permissions[i].functionSig, _permissions[i].account)
);
}

emit GrantPermissionsAdded(index);
}

/*
* @notice Function to add revoke permissions
* @param _permissions Array of permissions
* @custom:event Emits RevokePermissionsAdded event
*/
function addRevokePermissions(Permission[] memory _permissions) external {
if (_permissions.length == 0) {
revert EmptyPermissions();
}

uint256 index = revokePermissions.length;
revokePermissions.push();

for (uint256 i; i < _permissions.length; ++i) {
revokePermissions[index].push(
Permission(_permissions[i].contractAddress, _permissions[i].functionSig, _permissions[i].account)
);
}

emit RevokePermissionsAdded(index);
}

/*
* @notice Function to execute grant permissions
* @param index Index of the permissions array
* @custom:event Emits GrantPermissionsExecuted event
*/
function executeGrantPermissions(uint256 index) external {
uint256 length = grantPermissions[index].length;
for (uint256 i; i < length; ++i) {
Permission memory permission = grantPermissions[index][i];
ACM.giveCallPermission(permission.contractAddress, permission.functionSig, permission.account);
}

emit GrantPermissionsExecuted(index);
}

/*
* @notice Function to execute revoke permissions
* @param index Index of the permissions array
* @custom:event Emits RevokePermissionsExecuted event
*/
function executeRevokePermissions(uint256 index) external {
uint256 length = revokePermissions[index].length;
for (uint256 i; i < length; ++i) {
Permission memory permission = revokePermissions[index][i];
ACM.revokeCallPermission(permission.contractAddress, permission.functionSig, permission.account);
}

emit RevokePermissionsExecuted(index);
}
}
1 change: 1 addition & 0 deletions deploy/004-omnichain-executor-remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
args: [await getLzEndpoint(networkName), await guardian(networkName), await getSourceChainId(networkName)],
log: true,
autoMine: true,
skipIfAlreadyDeployed: true,
});
};
func.tags = ["OmnichainGovernanceExecutor", "Remote"];
Expand Down
28 changes: 28 additions & 0 deletions deploy/005-remote-timelock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export enum REMOTE_NETWORKS {
ARBITRUM_SEPOLIA = "arbitrumsepolia",
ZKSYNCSEPOLIA = "zksyncsepolia",
ZKSYNCMAINNET = "zksyncmainnet",
OPSEPOLIA = "opsepolia",
OPMAINNET = "opmainnet",
BASESEPOLIA = "basesepolia",
BASEMAINNET = "basemainnet",
HARDHAT = "hardhat",
}
type DelayTypes = {
Expand Down Expand Up @@ -68,7 +72,28 @@ export const delayConfig: DelayConfig = {
fast: 21600,
critical: 3600,
},
opsepolia: {
normal: 600,
fast: 300,
critical: 100,
},
opmainnet: {
normal: 172800,
fast: 21600,
critical: 3600,
},
basesepolia: {
normal: 600,
fast: 300,
critical: 100,
},
basemainnet: {
normal: 172800,
fast: 21600,
critical: 3600,
},
};

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
Expand All @@ -85,6 +110,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
args: [omnichainGovernanceExecutorAddress, delayConfig[networkName].normal],
log: true,
autoMine: true,
skipIfAlreadyDeployed: true,
});

await deploy(live ? "FastTrackTimelock" : "FastTrackTimelockRemote", {
Expand All @@ -93,6 +119,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
args: [omnichainGovernanceExecutorAddress, delayConfig[networkName].fast],
log: true,
autoMine: true,
skipIfAlreadyDeployed: true,
});

await deploy(live ? "CriticalTimelock" : "CriticalTimelockRemote", {
Expand All @@ -101,6 +128,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
args: [omnichainGovernanceExecutorAddress, delayConfig[networkName].critical],
log: true,
autoMine: true,
skipIfAlreadyDeployed: true,
});
};

Expand Down
23 changes: 23 additions & 0 deletions deploy/007-acm-commands-aggregator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ethers } from "hardhat";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const acm = await ethers.getContract("AccessControlManager");

await deploy("ACMCommandsAggregator", {
contract: "ACMCommandsAggregator",
from: deployer,
args: [acm.address],
log: true,
autoMine: true,
});
};

func.tags = ["ACMCommandsAggregator"];

export default func;
Loading

0 comments on commit 1bc373f

Please sign in to comment.