Skip to content

Commit

Permalink
Merge pull request #215 from kroma-network/chore/add-deploy-config-l2…
Browse files Browse the repository at this point in the history
…-governance

chore: add deploy config for l2 protocol governance
  • Loading branch information
seolaoh authored Oct 19, 2023
2 parents ae1cfd7 + 275cede commit 3c793cf
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 108 deletions.
3 changes: 2 additions & 1 deletion packages/contracts/deploy-config/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"governorVotingPeriodBlocks": 21600,
"governorProposalThreshold": 1,
"governorVotesQuorumFractionPercent": 51,
"timeLockMinDelaySeconds": 604800,
"timeLockMinDelaySeconds": 2592000,
"l2GovernorVotingPeriodBlocks": 129600,
"zkVerifierHashScalar": "0x163b85414bb5a9c97d8249f96b9c4ffd8db3e8081133101a14fc8546b704e2b",
"zkVerifierM56Px": "0x2aa452092865578d9b68a69f053df3db7a563b7cc7d17c9cce524632ccb30d85",
"zkVerifierM56Py": "0xafcccd2c2ebc8ffb530403bb07d4e1bcfc1aa910d4dd08d7cd81fcafef5e556"
Expand Down
1 change: 1 addition & 0 deletions packages/contracts/deploy-config/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"governorProposalThreshold": 1,
"governorVotesQuorumFractionPercent": 30,
"timeLockMinDelaySeconds": 300,
"l2GovernorVotingPeriodBlocks": 150,
"zkVerifierHashScalar": "0x8a18470eb27ae5b84622ad66cc5607a7ce6b876569d2fb9ce5aa32cdda5cfc6",
"zkVerifierM56Px": "0x1b43785e34e12914d2e6fea816de6821f802c1ecf0bbeacba23600352027fcfd",
"zkVerifierM56Py": "0xb8e6f17043e36148aa467bea5a21b670072446b89f9612c229af2709dc83a28"
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/deploy/L2/103-UpgradeGovernor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const deployFn: DeployFunction = async (hre) => {
securityCouncilTokenProxyAddress,
timeLockProxyAddress,
deployConfig.governorVotingDelayBlocks,
deployConfig.governorVotingPeriodBlocks,
deployConfig.l2GovernorVotingPeriodBlocks,
deployConfig.governorProposalThreshold,
deployConfig.governorVotesQuorumFractionPercent,
],
Expand All @@ -49,7 +49,7 @@ const deployFn: DeployFunction = async (hre) => {
)
assert(
(await governor.votingPeriod()).toNumber() ===
deployConfig.governorVotingPeriodBlocks
deployConfig.l2GovernorVotingPeriodBlocks
)
assert(
(await governor.proposalThreshold()).toNumber() ===
Expand Down
92 changes: 0 additions & 92 deletions packages/contracts/deploy/L2/999-TransferOwnerships.ts

This file was deleted.

8 changes: 8 additions & 0 deletions packages/contracts/src/deploy-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ interface RequiredDeployConfig {
*/
governorVotesQuorumFractionPercent: number

/**
* L2 : Governor voting period in block.
*/
l2GovernorVotingPeriodBlocks: number

/**
* Initial minimum delay for operations.
*/
Expand Down Expand Up @@ -462,6 +467,9 @@ export const deployConfigSpec: {
governorVotesQuorumFractionPercent: {
type: 'number',
},
l2GovernorVotingPeriodBlocks: {
type: 'number',
},
timeLockMinDelaySeconds: {
type: 'number',
},
Expand Down
1 change: 1 addition & 0 deletions packages/contracts/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ import './accounts'
import './check-l2'
import './generate-deploy-config'
import './deployments-l2'
import './transfer-ownership'
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import assert from 'assert'
import readline from 'readline'

import '@kroma/hardhat-deploy-config'
import { DeployFunction } from 'hardhat-deploy/dist/types'
import '@nomiclabs/hardhat-ethers'
import { task } from 'hardhat/config'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

import { getDeploymentAddress } from '../../src/deploy-utils'
import { getDeploymentAddress } from '../src/deploy-utils'

const deployFn: DeployFunction = async (hre) => {
const timeLockProxyAddress = await getDeploymentAddress(hre, 'TimeLockProxy')
await transferProxyAdminOwnership(hre, timeLockProxyAddress)

const scTokenOwnerAddress = hre.deployConfig.securityCouncilTokenOwner
await transferSecurityCouncilTokenOwnership(hre, scTokenOwnerAddress)
const isL1Network = (hre: HardhatRuntimeEnvironment): boolean => {
const networkName = hre.network.name
const l1Network = ['mainnet', 'sepolia', 'easel', 'devnetL1']
return l1Network.includes(networkName)
}

const transferProxyAdminOwnership = async (
hre: HardhatRuntimeEnvironment,
newOwner: string
) => {
console.log('transfer ProxyAdmin ownership to TimeLock')
const proxyAdminAddress = await getDeploymentAddress(hre, 'ProxyAdmin')
const proxyAdminAddress = isL1Network(hre)
? await getDeploymentAddress(hre, 'ProxyAdmin')
: await getDeploymentAddress(hre, 'ProxyAdminProxy')
let proxyAdmin = await hre.ethers.getContractAt(
'ProxyAdmin',
proxyAdminAddress
)

const currentProxyAdminOwner = await proxyAdmin.owner()
if (currentProxyAdminOwner === newOwner) {
console.log(
Expand Down Expand Up @@ -68,6 +70,7 @@ const transferSecurityCouncilTokenOwnership = async (
console.log(
'skip the SecurityCouncilToken owner transfer process because the owner has already been transferred.'
)
return
}

scToken = scToken.connect(hre.ethers.provider.getSigner(currentScTokenOwner))
Expand All @@ -84,7 +87,51 @@ const transferSecurityCouncilTokenOwnership = async (
console.log('successfully transferred ownership of SecurityCouncilToken')
}

deployFn.runAtTheEnd = true
deployFn.tags = ['setup', 'l1']
task('transfer-ownership', 'Transfer ownership').setAction(
async (args, hre) => {
const readLineAsync = () => {
const rl = readline.createInterface({
input: process.stdin,
})

return new Promise((resolve) => {
rl.prompt()
rl.on('line', (line) => {
rl.close()
resolve(line)
})
})
}

export default deployFn
const run = async () => {
const networkName = hre.network.name
const yes = 'yes'
console.warn(
'*******************************************************************************************************'
)
console.warn(
' [WARNING] Do you want to continue with the transferOwnership operation for the ' +
networkName +
' network?'
)
console.warn(" Type and enter 'yes' to continue")
console.warn(
'*******************************************************************************************************'
)
const line = await readLineAsync()
if (line.toString() !== yes) {
console.log('The response is invalid. Terminate the task.')
return
}

const timeLockProxyAddress = await getDeploymentAddress(
hre,
'TimeLockProxy'
)
await transferProxyAdminOwnership(hre, timeLockProxyAddress)
await transferSecurityCouncilTokenOwnership(hre, timeLockProxyAddress)
}

await run()
}
)
2 changes: 2 additions & 0 deletions utils/chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ type DeployConfig struct {
GovernorProposalThreshold uint64 `json:"governorProposalThreshold"`
// The initial value of the votes quorum fraction(unit:percent)
GovernorVotesQuorumFractionPercent uint64 `json:"governorVotesQuorumFractionPercent"`
// The initial value of the L2 voting period(unit:block)
L2GovernorVotingPeriodBlocks uint64 `json:"l2GovernorVotingPeriodBlocks"`
// The latency value of the proposal executing(unit:second)
TimeLockMinDelaySeconds uint64 `json:"timeLockMinDelaySeconds"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"governorVotingPeriodBlocks": 25,
"governorProposalThreshold": 1,
"governorVotesQuorumFractionPercent": 51,
"l2GovernorVotingPeriodBlocks": 150,
"timeLockMinDelaySeconds": 1,
"zkVerifierHashScalar": "0x1545b1bf82c58ee35648bd877da9c5010193e82b036b16bf382acf31bc2ab576",
"zkVerifierM56Px": "0x15ae1a8e3b993dd9aadc8f9086d1ea239d4cd5c09cfa445f337e1b60d7b3eb87",
Expand Down

0 comments on commit 3c793cf

Please sign in to comment.