Skip to content

Commit

Permalink
test: set deployer as timelock admin
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Dec 6, 2023
1 parent af9426e commit f0bcec3
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 13 deletions.
59 changes: 57 additions & 2 deletions deploy/000-governance-access-control.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,65 @@
import timelock from '@venusprotocol/governance-contracts/dist/deploy/001-timelock';
import accessControl from '@venusprotocol/governance-contracts/dist/deploy/002-access-control';
import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

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

const networkName = hre.network.name;

const delayConfig = {
hardhat: {
normal: 600,
fast: 300,
critical: 100,
},
bscmainnet: {
normal: 172800,
fast: 21600,
critical: 3600,
},
bsctestnet: {
normal: 600,
fast: 300,
critical: 100,
},
sepolia: {
normal: 600,
fast: 300,
critical: 100,
},
ethereum: {
normal: 172800,
fast: 21600,
critical: 3600,
},
};

await deploy("NormalTimelock", {
contract: "TestTimelockV8",
from: deployer,
args: [deployer, delayConfig[networkName].normal],
log: true,
autoMine: true,
});

await deploy("FastTrackTimelock", {
contract: "TestTimelockV8",
from: deployer,
args: [deployer, delayConfig[networkName].fast],
log: true,
autoMine: true,
});

await deploy("CriticalTimelock", {
contract: "TestTimelockV8",
from: deployer,
args: [deployer, delayConfig[networkName].critical],
log: true,
autoMine: true,
});

await accessControl(hre);
};
Expand Down
22 changes: 19 additions & 3 deletions deploy/018-governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await getNamedAccounts();
const signers = await ethers.getSigners();

const timelock = await ethers.getContract('CriticalTimelock');
const timelock = await ethers.getContract('NormalTimelock');
const xvsVault = await ethers.getContract('XVSVaultProxy');

const governorAlphaTimelock = await ethers.getContract('CriticalTimelock');
await deploy('GovernorAlphaTimelock', {
contract: 'Timelock',
from: deployer,
args: [deployer, 3600],
log: true,
autoMine: true,
});

const governorAlphaTimelock = await ethers.getContract('GovernorAlphaTimelock');
await deploy('GovernorAlpha', {
from: deployer,
args: [governorAlphaTimelock.address, xvsVault.address, deployer],
Expand Down Expand Up @@ -39,7 +47,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

await governorAlpha.__acceptAdmin();

const governorAlpha2Timelock = await ethers.getContract('CriticalTimelock');
await deploy('GovernorAlpha2Timelock', {
contract: 'Timelock',
from: deployer,
args: [deployer, 3600],
log: true,
autoMine: true,
});

const governorAlpha2Timelock = await ethers.getContract('GovernorAlpha2Timelock');

await deploy('GovernorAlpha2', {
from: deployer,
Expand Down
6 changes: 3 additions & 3 deletions subgraphs/venus-governance/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const main = () => {
network: 'hardhat',
accessControlManagerAddress: '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9',
accessControlManagerStartBlock: '0',
governorAlphaAddress: '0x95775fD3Afb1F4072794CA4ddA27F2444BCf8Ac3',
governorAlphaAddress: '0xd9fEc8238711935D6c8d79Bef2B9546ef23FC046',
governorAlphaStartBlock: '0',
governorAlpha2Address: '0x512F7469BcC83089497506b5df64c6E246B39925',
governorAlpha2Address: '0xCBBe2A5c3A22BE749D5DDF24e9534f98951983e2',
governorAlpha2StartBlock: '0',
governorBravoDelegatorAddress: '0xE8F7d98bE6722d42F29b50500B0E318EF2be4fc8',
governorBravoDelegatorAddress: '0x2c8ED11fd7A058096F2e5828799c68BE88744E2F',
governorBravoDelegatorStartBlock: '0',
xvsTokenAddress: '0x1343248Cbd4e291C6979e70a138f4c774e902561',
xvsTokenStartBlock: '0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('AccessControlManager', function () {
const { data } = await subgraphClient.getPermissions();

const { permissions } = data!;
expect(permissions.length).to.be.equal(12);
expect(permissions.length).to.be.equal(13);

permissions.forEach(pe => {
expect(pe.type).to.be.equal('GRANTED');
Expand All @@ -36,7 +36,7 @@ describe('AccessControlManager', function () {
const { data } = await subgraphClient.getPermissions();

const { permissions } = data!;
expect(permissions.length).to.be.equal(13);
expect(permissions.length).to.be.equal(14);

expect(permissions[0].type).to.be.equal('REVOKED');
});
Expand All @@ -54,7 +54,7 @@ describe('AccessControlManager', function () {
const { data } = await subgraphClient.getPermissions();

const { permissions } = data!;
expect(permissions.length).to.be.equal(13);
expect(permissions.length).to.be.equal(14);

expect(permissions[0].type).to.be.equal('GRANTED');
});
Expand Down
4 changes: 2 additions & 2 deletions subgraphs/venus-governance/tests/integration/bravo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('GovernorBravo', function () {
const governorAlpha2 = await ethers.getContract('GovernorAlpha2');

// Impersonating timelock for convenience
const timelock = await ethers.getContract('Timelock');
const timelock = await ethers.getContract('CriticalTimelock');

await signers[0].sendTransaction({
to: timelock.address,
Expand All @@ -48,7 +48,7 @@ describe('GovernorBravo', function () {
params: [timelock.address],
});

await governorBravo._initiate(governorAlpha2.address);
await governorBravoDelegator._initiate(governorAlpha2.address);
// Finished setup
await waitForSubgraphToBeSynced(SYNC_DELAY);
});
Expand Down

0 comments on commit f0bcec3

Please sign in to comment.