Skip to content

Commit

Permalink
feat(scratch): transfer all ownership to Agent at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
arwer13 committed Oct 2, 2023
1 parent 36c103a commit 352ba49
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dao-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ msg "Roles granted"
yarn hardhat --network $NETWORK run ./scripts/scratch/16-plug-curated-staking-module.js --no-compile
msg "Plugged NodeOperatorsRegistry as Curated staking module"

yarn hardhat --network $NETWORK run ./scripts/scratch/17-transfer-roles.js --no-compile
msg "Role admin permissions transferred to Agent"

yarn hardhat --network $NETWORK run ./scripts/scratch/12-check-dao.js --no-compile
msg "The deployed protocol state checked"

Expand Down
71 changes: 71 additions & 0 deletions scripts/scratch/17-transfer-roles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const runOrWrapScript = require('../helpers/run-or-wrap-script')
const { log, logSplitter, logWideSplitter, yl, gr, OK } = require('../helpers/log')
const { readNetworkState, assertRequiredNetworkState } = require('../helpers/persisted-network-state')

const REQUIRED_NET_STATE = [
"app:aragon-agent",
"accountingOracle",
"burner",
"daoInitialSettings",
"hashConsensusForAccounting",
"hashConsensusForValidatorsExitBus",
"lidoLocator",
"stakingRouter",
"validatorsExitBusOracle",
"withdrawalQueueERC721",
]

const DEFAULT_ADMIN_ROLE = "0x00"


async function transferOZAdmin(contractName, contractAddress, currentAdmin, newAdmin) {
console.log(`Transferring OZ admin of ${contractAddress} from ${currentAdmin} to ${newAdmin}:`)
const contract = await artifacts.require(contractName).at(contractAddress)
await log.makeTx(contract, 'grantRole', [DEFAULT_ADMIN_ROLE, newAdmin], { from: currentAdmin })
await log.makeTx(contract, 'renounceRole', [DEFAULT_ADMIN_ROLE, currentAdmin], { from: currentAdmin })
console.log()
}

async function changeOssifiableProxyAdmin(contractAddress, currentAdmin, newAdmin) {
console.log(`Transferring OssifiableProxy admin of ${contractAddress} from ${currentAdmin} to ${newAdmin}...`)
const contract = await artifacts.require('OssifiableProxy').at(contractAddress)
await log.makeTx(contract, 'proxy__changeAdmin', [newAdmin], { from: currentAdmin })
console.log()
}

async function changeDepositSecurityModuleAdmin(contractAddress, currentAdmin, newAdmin) {
console.log(`Changing DepositSecurityModule owner of ${contractAddress} from ${currentAdmin} to ${newAdmin}...`)
const depositSecurityModule = await artifacts.require('DepositSecurityModule').at(contractAddress)
await log.makeTx(depositSecurityModule, 'setOwner', [newAdmin], { from: currentAdmin } )
console.log()
}

async function deployNewContracts({ web3, artifacts }) {
const netId = await web3.eth.net.getId()
logWideSplitter()
log(`Network ID:`, yl(netId))

let state = readNetworkState(network.name, netId)
assertRequiredNetworkState(state, REQUIRED_NET_STATE)

const owner = state.owner
const agent = state["app:aragon-agent"].proxyAddress

await transferOZAdmin('Burner', state.burner.address, owner, agent)
await transferOZAdmin('HashConsensus', state.hashConsensusForAccounting.address, owner, agent)
await transferOZAdmin('HashConsensus', state.hashConsensusForValidatorsExitBus.address, owner, agent)
await transferOZAdmin('StakingRouter', state.stakingRouter.address, owner, agent)
await transferOZAdmin('AccountingOracle', state.accountingOracle.address, owner, agent)
await transferOZAdmin('ValidatorsExitBusOracle', state.validatorsExitBusOracle.address, owner, agent)
await transferOZAdmin('WithdrawalQueueERC721', state.withdrawalQueueERC721.address, owner, agent)

await changeOssifiableProxyAdmin(state.lidoLocator.address, owner, agent)
await changeOssifiableProxyAdmin(state.stakingRouter.address, owner, agent)
await changeOssifiableProxyAdmin(state.accountingOracle.address, owner, agent)
await changeOssifiableProxyAdmin(state.validatorsExitBusOracle.address, owner, agent)
await changeOssifiableProxyAdmin(state.withdrawalQueueERC721.address, owner, agent)

await changeDepositSecurityModuleAdmin(state.depositSecurityModule.address, owner, agent)
}

module.exports = runOrWrapScript(deployNewContracts, module)

0 comments on commit 352ba49

Please sign in to comment.