Skip to content

Commit

Permalink
fix: add REQUEST_BURN_SHARES_ROLE
Browse files Browse the repository at this point in the history
  • Loading branch information
krogla committed Oct 17, 2023
1 parent fc7f4d8 commit dfb4353
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
27 changes: 23 additions & 4 deletions scripts/simpledvt/02-clone-nor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const {
SET_NODE_OPERATOR_LIMIT_ROLE,
STAKING_ROUTER_ROLE,
STAKING_MODULE_MANAGE_ROLE,
REQUEST_BURN_SHARES_ROLE,
SIMPLE_DVT_IPFS_CID,
} = require('./helpers')
const { ETH, toBN } = require('../../test/helpers/utils')
Expand Down Expand Up @@ -152,6 +153,9 @@ async function deployNORClone({ web3, artifacts, trgAppName = APP_TRG, ipfsCid =
const daoTokenAddress = await tokenManager.token()
const daoToken = await artifacts.require('MiniMeToken').at(daoTokenAddress)

const burnerAddress = readStateAppAddress(state, `burner`)
const burner = await artifacts.require('Burner').at(burnerAddress)

const easytrackABI = [
{
inputs: [
Expand Down Expand Up @@ -308,15 +312,30 @@ async function deployNORClone({ web3, artifacts, trgAppName = APP_TRG, ipfsCid =

// check missed STAKING_MODULE_MANAGE_ROLE role on Agent
if (!(await stakingRouter.hasRole(STAKING_MODULE_MANAGE_ROLE, voting.address))) {
const grantRoleCallData = await stakingRouter.contract.methods
.grantRole(STAKING_MODULE_MANAGE_ROLE, agent.address)
.encodeABI()
evmScriptCalls.push({
to: agent.address,
calldata: await agent.contract.methods.execute(stakingRouter.address, 0, grantRoleCallData).encodeABI(),
calldata: await agent.contract.methods
.execute(
stakingRouter.address,
0,
await stakingRouter.contract.methods.grantRole(STAKING_MODULE_MANAGE_ROLE, agent.address).encodeABI()
)
.encodeABI(),
})
}

// allow to request burner, add REQUEST_BURN_SHARES_ROLE
evmScriptCalls.push({
to: agent.address,
calldata: await agent.contract.methods
.execute(
burner.address,
0,
await burner.contract.methods.grantRole(REQUEST_BURN_SHARES_ROLE, trgProxyAddress).encodeABI()
)
.encodeABI(),
})

// add module to SR
const addModuleCallData = await stakingRouter.contract.methods
.addStakingModule(
Expand Down
20 changes: 9 additions & 11 deletions scripts/simpledvt/03-check-deployed.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
SET_NODE_OPERATOR_LIMIT_ROLE,
STAKING_ROUTER_ROLE,
STAKING_MODULE_MANAGE_ROLE,
REQUEST_BURN_SHARES_ROLE,
SIMPLE_DVT_IPFS_CID,
} = require('./helpers')
const { readNetworkState, assertRequiredNetworkState } = require('../helpers/persisted-network-state')
Expand Down Expand Up @@ -71,7 +72,6 @@ async function deployNORClone({ web3, artifacts, trgAppName = APP_TRG, ipfsCid =
const trgAppFullName = `${trgAppName}.${state.lidoApmEnsName}`
const trgAppId = namehash(trgAppFullName)

console.log({ trgAppId, ens, artifacts })
const { semanticVersion, contractAddress, contentURI } = await resolveLatestVersion(trgAppId, ens, artifacts)

_checkEq(contractAddress, srcContractAddress, 'App APM repo last version: implementation is the same to NOR')
Expand Down Expand Up @@ -112,13 +112,21 @@ async function deployNORClone({ web3, artifacts, trgAppName = APP_TRG, ipfsCid =
const srAddress = readStateAppAddress(state, 'stakingRouter')
const dsmAddress = readStateAppAddress(state, 'depositSecurityModule')
const stakingRouter = await artifacts.require('StakingRouter').at(srAddress)
const burnerAddress = readStateAppAddress(state, `burner`)
const burner = await artifacts.require('Burner').at(burnerAddress)

_checkEq(
await stakingRouter.hasRole(STAKING_MODULE_MANAGE_ROLE, agentAddress),
true,
'Agent has role: STAKING_MODULE_MANAGE_ROLE'
)

_checkEq(
await burner.hasRole(REQUEST_BURN_SHARES_ROLE, trgProxyAddress),
true,
'App has role: REQUEST_BURN_SHARES_ROLE'
)

_checkEq(
await acl.getPermissionManager(trgProxyAddress, MANAGE_SIGNING_KEYS),
easyTrackEVMScriptExecutor,
Expand Down Expand Up @@ -168,16 +176,6 @@ async function deployNORClone({ web3, artifacts, trgAppName = APP_TRG, ipfsCid =
'StakingRouter has permission: STAKING_ROUTER_ROLE'
)

if (state.easytrackAddress) {
_checkEq(
await acl.hasPermission(state.easytrackAddress, trgProxyAddress, SET_NODE_OPERATOR_LIMIT_ROLE),
true,
'Easytrack has permission: SET_NODE_OPERATOR_LIMIT_ROLE'
)
} else {
log(yl('[-]'), 'No Easytrack address set - skip!')
}

log.splitter()

_checkEq(await stakingRouter.getStakingModulesCount(), 2, 'StakingRouter: modules count = 2')
Expand Down
2 changes: 2 additions & 0 deletions scripts/simpledvt/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const MANAGE_NODE_OPERATOR_ROLE = '0x78523850fdd761612f46e844cf5a16bda6b3151d6ae
const SET_NODE_OPERATOR_LIMIT_ROLE = '0x07b39e0faf2521001ae4e58cb9ffd3840a63e205d288dc9c93c3774f0d794754'
const STAKING_ROUTER_ROLE = '0xbb75b874360e0bfd87f964eadd8276d8efb7c942134fc329b513032d0803e0c6'
const STAKING_MODULE_MANAGE_ROLE = '0x3105bcbf19d4417b73ae0e58d508a65ecf75665e46c2622d8521732de6080c48'
const REQUEST_BURN_SHARES_ROLE = '0x4be29e0e4eb91f98f709d98803cba271592782e293b84a625e025cbb40197ba8'
const SIMPLE_DVT_IPFS_CID = 'QmaSSujHCGcnFuetAPGwVW5BegaMBvn5SCsgi3LSfvraSo'

async function getDeployer(web3, defaultDeployer) {
Expand Down Expand Up @@ -39,5 +40,6 @@ module.exports = {
SET_NODE_OPERATOR_LIMIT_ROLE,
STAKING_ROUTER_ROLE,
STAKING_MODULE_MANAGE_ROLE,
REQUEST_BURN_SHARES_ROLE,
SIMPLE_DVT_IPFS_CID,
}

0 comments on commit dfb4353

Please sign in to comment.