Skip to content

Commit

Permalink
deploy: Move treasury deploy to deploy_contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
victorges committed Sep 28, 2023
1 parent 1125bdc commit dc597e1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 95 deletions.
59 changes: 57 additions & 2 deletions deploy/deploy_contracts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {HardhatRuntimeEnvironment} from "hardhat/types"
import {DeployFunction} from "hardhat-deploy/types"
import {ethers} from "hardhat"
import {Contract} from "ethers"
import {Contract, constants} from "ethers"
import {DeployResult, Export} from "hardhat-deploy/dist/types"
import fs from "fs"

Expand All @@ -11,7 +11,9 @@ import {
RoundsManager,
TicketBroker,
LivepeerToken,
Governor
Governor,
LivepeerGovernor,
Treasury
} from "../typechain"

import ContractDeployer from "../utils/deployer"
Expand Down Expand Up @@ -213,6 +215,59 @@ const func: DeployFunction = async function(hre: HardhatRuntimeEnvironment) {
await (await Governor.stage(transferOwnershipUpdate, 0)).wait()
await (await Governor.execute(transferOwnershipUpdate)).wait()

// Treasury (LivepeerGovernor)

const treasury = await contractDeployer.deployAndRegister({
contract: "Treasury",
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",
name: "LivepeerGovernor",
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(
"BondingManager",
Expand Down
87 changes: 0 additions & 87 deletions deploy/deploy_livepeer_governor.ts

This file was deleted.

6 changes: 3 additions & 3 deletions doc/devnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

## Deployment

- `yarn deploy --network <network>` to deploy the `Contracts` and `Poll` tags
- `yarn deploy --network <network>` to deploy all the core protocol contracts
- `npx hardhat deploy --tags ARBITRUM_LPT_DUMMIES --network <network>` to deploy the L2 bridge no-ops
- `npx hardhat deploy --tags LivepeerGovernor --network <network>` to deploy the treasury and governor contracts

## Verification

To verify all contracts that have been deployed in the network:
- `yarn verify --network <network>`

- `yarn verify --network <network>`

## Housekeeping

Expand Down
4 changes: 1 addition & 3 deletions test/integration/LivepeerGovernor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ describe("LivepeerGovernor", () => {
signers = await ethers.getSigners()
proposer = signers[0]

const fixture = await setupIntegrationTest({
tags: ["LivepeerGovernor"]
})
const fixture = await setupIntegrationTest()
controller = await ethers.getContractAt(
"Controller",
fixture.Controller.address
Expand Down

0 comments on commit dc597e1

Please sign in to comment.