diff --git a/deploy/deploy_contracts.ts b/deploy/deploy_contracts.ts index a7b30b54..7f2dd8b8 100644 --- a/deploy/deploy_contracts.ts +++ b/deploy/deploy_contracts.ts @@ -224,17 +224,6 @@ const func: DeployFunction = async function(hre: HardhatRuntimeEnvironment) { name: "Treasury", args: [] }) - const Treasury: Treasury = await ethers.getContractAt( - "Treasury", - treasury.address - ) - - await Treasury.initialize( - config.treasury.minDelay, - [], // governor will be added as a proposer later - [constants.AddressZero], // let anyone execute proposals - deployer // temporary admin role for deployer - ).then(tx => tx.wait()) const livepeerGovernor = await contractDeployer.deployAndRegister({ contract: "LivepeerGovernor", @@ -242,33 +231,6 @@ const func: DeployFunction = async function(hre: HardhatRuntimeEnvironment) { args: [Controller.address], proxy: true }) - const LivepeerGovernor: LivepeerGovernor = await ethers.getContractAt( - "LivepeerGovernor", - livepeerGovernor.address - ) - - await LivepeerGovernor.initialize( - config.livepeerGovernor.initialVotingDelay, - config.livepeerGovernor.initialVotingPeriod, - config.livepeerGovernor.initialProposalThreshold, - config.livepeerGovernor.initialQuorum, - config.livepeerGovernor.quota - ).then(tx => tx.wait()) - - // Now grant proposer and executor roles to governor and renounce deployer admin role - const roles = { - proposer: await Treasury.PROPOSER_ROLE(), - canceller: await Treasury.CANCELLER_ROLE(), - executor: await Treasury.EXECUTOR_ROLE(), - admin: await Treasury.TIMELOCK_ADMIN_ROLE() - } - for (const role of [roles.proposer, roles.canceller, roles.executor]) { - await Treasury.grantRole(role, LivepeerGovernor.address).then(tx => - tx.wait() - ) - } - - await Treasury.renounceRole(roles.admin, deployer).then(tx => tx.wait()) // Set BondingManager parameters const BondingManager: BondingManager = (await ethers.getContractAt( @@ -332,6 +294,48 @@ const func: DeployFunction = async function(hre: HardhatRuntimeEnvironment) { } } + // Initialize Treasury and LivepeerGovernor + + const Treasury: Treasury = await ethers.getContractAt( + "Treasury", + treasury.address + ) + + await Treasury.initialize( + config.treasury.minDelay, + [], // governor will be added as a proposer later + [constants.AddressZero], // let anyone execute proposals + deployer // temporary admin role for deployer + ).then(tx => tx.wait()) + + const LivepeerGovernor: LivepeerGovernor = await ethers.getContractAt( + "LivepeerGovernor", + livepeerGovernor.address + ) + + await LivepeerGovernor.initialize( + config.livepeerGovernor.initialVotingDelay, + config.livepeerGovernor.initialVotingPeriod, + config.livepeerGovernor.initialProposalThreshold, + config.livepeerGovernor.initialQuorum, + config.livepeerGovernor.quota + ).then(tx => tx.wait()) + + // Now grant proposer and executor roles to governor and renounce deployer admin role + const roles = { + proposer: await Treasury.PROPOSER_ROLE(), + canceller: await Treasury.CANCELLER_ROLE(), + executor: await Treasury.EXECUTOR_ROLE(), + admin: await Treasury.TIMELOCK_ADMIN_ROLE() + } + for (const role of [roles.proposer, roles.canceller, roles.executor]) { + await Treasury.grantRole(role, LivepeerGovernor.address).then(tx => + tx.wait() + ) + } + + await Treasury.renounceRole(roles.admin, deployer).then(tx => tx.wait()) + // Set TicketBroker parameters const Broker: TicketBroker = (await ethers.getContractAt( "TicketBroker", diff --git a/test/integration/LivepeerGovernor.ts b/test/integration/LivepeerGovernor.ts index c24fcc85..2a53ec2a 100644 --- a/test/integration/LivepeerGovernor.ts +++ b/test/integration/LivepeerGovernor.ts @@ -47,7 +47,9 @@ describe("LivepeerGovernor", () => { signers = await ethers.getSigners() proposer = signers[0] - const fixture = await setupIntegrationTest() + const fixture = await setupIntegrationTest({ + tags: ["Contracts", "Poll"] + }) controller = await ethers.getContractAt( "Controller", fixture.Controller.address