diff --git a/scripts/simpledvt/01-deploy-app-proxy.js b/scripts/simpledvt/01-deploy-app-proxy.js index edf814856..fe2d62a58 100644 --- a/scripts/simpledvt/01-deploy-app-proxy.js +++ b/scripts/simpledvt/01-deploy-app-proxy.js @@ -3,7 +3,7 @@ const chalk = require('chalk') const runOrWrapScript = require('../helpers/run-or-wrap-script') const { log, yl } = require('../helpers/log') -const { getDeployer, readStateAppAddress } = require('./helpers') +const { getDeployer, readStateAppAddress, _checkEq } = require('./helpers') const { readNetworkState, assertRequiredNetworkState, @@ -11,6 +11,7 @@ const { } = require('../helpers/persisted-network-state') const { hash: namehash } = require('eth-ens-namehash') +const { ZERO_ADDRESS } = require('../../test/helpers/utils') const APP_TRG = process.env.APP_TRG || 'simple-dvt' const DEPLOYER = process.env.DEPLOYER || '' @@ -48,38 +49,43 @@ async function deployEmptyProxy({ web3, artifacts, trgAppName = APP_TRG }) { trgProxyAddress = readStateAppAddress(state, `app:${trgAppName}`) } - if (trgProxyAddress && (await web3.eth.getCode(trgProxyAddress)) !== '0x') { - log.error(`Target app proxy is already deployed at ${yl(trgProxyAddress)}`) - return - } - - const kernel = await artifacts.require('Kernel').at(kernelAddress) - const tx = await log.tx( - `Deploying proxy for ${trgAppName}`, - kernel.newAppProxy(kernelAddress, trgAppId, { from: deployer }) - ) - // Find the deployed proxy address in the tx logs. - const e = tx.logs.find((l) => l.event === 'NewAppProxy') - trgProxyAddress = e.args.proxy - - // upd deployed state - persistNetworkState2(network.name, netId, state, { - [`app:${trgAppName}`]: { - aragonApp: { - name: trgAppName, - fullName: trgAppFullName, - id: trgAppId, + if (!trgProxyAddress || (await web3.eth.getCode(trgProxyAddress)) === '0x') { + const kernel = await artifacts.require('Kernel').at(kernelAddress) + const tx = await log.tx( + `Deploying proxy for ${trgAppName}`, + kernel.newAppProxy(kernelAddress, trgAppId, { from: deployer }) + ) + // Find the deployed proxy address in the tx logs. + const e = tx.logs.find((l) => l.event === 'NewAppProxy') + trgProxyAddress = e.args.proxy + + // upd deployed state + persistNetworkState2(network.name, netId, state, { + [`app:${trgAppName}`]: { + aragonApp: { + name: trgAppName, + fullName: trgAppFullName, + id: trgAppId, + }, + proxy: { + address: trgProxyAddress, + contract: '@aragon/os/contracts/apps/AppProxyUpgradeable.sol', + constructorArgs: [kernelAddress, trgAppId, '0x'], + }, }, - proxy: { - address: trgProxyAddress, - contract: '@aragon/os/contracts/apps/AppProxyUpgradeable.sol', - constructorArgs: [kernelAddress, trgAppId, '0x'], - }, - }, - }) + }) + } log(`Target app proxy deployed at`, yl(trgProxyAddress)) + log.splitter() + log('Checking deployed proxy...') + + const proxy = await artifacts.require('AppProxyUpgradeable').at(trgProxyAddress) + + _checkEq(await proxy.kernel(), kernelAddress, 'App proxy kernel address matches Lido DAO') + _checkEq(await proxy.appId(), trgAppId, 'App proxy AppId matches SimpleDVT') + _checkEq(await proxy.implementation(), ZERO_ADDRESS, 'App proxy has ZERO_ADDRESS implementations') } module.exports = runOrWrapScript(deployEmptyProxy, module) diff --git a/scripts/simpledvt/02-clone-nor.js b/scripts/simpledvt/02-clone-nor.js index 3f6413067..19b9fc77d 100644 --- a/scripts/simpledvt/02-clone-nor.js +++ b/scripts/simpledvt/02-clone-nor.js @@ -46,7 +46,7 @@ const REQUIRED_NET_STATE = [ `app:${APP_NAMES.ARAGON_TOKEN_MANAGER}`, ] -async function deployNORClone({ web3, artifacts, trgAppName = APP_TRG, ipfsCid = APP_IPFS_CID }) { +async function deploySimpleDVT({ web3, artifacts, trgAppName = APP_TRG, ipfsCid = APP_IPFS_CID }) { const netId = await web3.eth.net.getId() const srcAppName = APP_NAMES.NODE_OPERATORS_REGISTRY @@ -471,4 +471,4 @@ function getVoters(agentAddress, vestingParams, daoTokenTotalSupply, quorumPcnt) return voters } -module.exports = runOrWrapScript(deployNORClone, module) +module.exports = runOrWrapScript(deploySimpleDVT, module) diff --git a/scripts/simpledvt/03-check-deployed.js b/scripts/simpledvt/03-check-deployed.js index 600c86a5f..af5970f25 100644 --- a/scripts/simpledvt/03-check-deployed.js +++ b/scripts/simpledvt/03-check-deployed.js @@ -1,12 +1,12 @@ const { network, ethers } = require('hardhat') const { Contract, utils } = require('ethers') const chalk = require('chalk') -const { assert } = require('chai') const runOrWrapScript = require('../helpers/run-or-wrap-script') const { log, yl, gr } = require('../helpers/log') const { getDeployer, readStateAppAddress, + _checkEq, MANAGE_SIGNING_KEYS, MANAGE_NODE_OPERATOR_ROLE, SET_NODE_OPERATOR_LIMIT_ROLE, @@ -37,12 +37,7 @@ const REQUIRED_NET_STATE = [ `app:${APP_NAMES.ARAGON_TOKEN_MANAGER}`, ] -function _checkEq(a, b, descr = '') { - assert.equal(a, b, descr) - log.success(descr) -} - -async function deployNORClone({ web3, artifacts, trgAppName = APP_TRG, ipfsCid = APP_IPFS_CID }) { +async function checkSimpleDVT({ web3, artifacts, trgAppName = APP_TRG, ipfsCid = APP_IPFS_CID }) { const netId = await web3.eth.net.getId() log.splitter() @@ -455,4 +450,4 @@ async function deployNORClone({ web3, artifacts, trgAppName = APP_TRG, ipfsCid = } } -module.exports = runOrWrapScript(deployNORClone, module) +module.exports = runOrWrapScript(checkSimpleDVT, module) diff --git a/scripts/simpledvt/helpers.js b/scripts/simpledvt/helpers.js index b3abac822..8f8b24968 100644 --- a/scripts/simpledvt/helpers.js +++ b/scripts/simpledvt/helpers.js @@ -1,3 +1,6 @@ +const { assert } = require('chai') +const { log } = require('../helpers/log') + const KERNEL_APP_BASES_NAMESPACE = '0xf1f3eb40f5bc1ad1344716ced8b8a0431d840b5783aea1fd01786bc26f35ac0f' const MANAGE_SIGNING_KEYS = '0x75abc64490e17b40ea1e66691c3eb493647b24430b358bd87ec3e5127f1621ee' @@ -30,10 +33,16 @@ function getSignature(instance, method) { return methodAbi.signature } +function _checkEq(a, b, descr = '') { + assert.equal(a, b, descr) + log.success(descr) +} + module.exports = { readStateAppAddress, getDeployer, getSignature, + _checkEq, KERNEL_APP_BASES_NAMESPACE, MANAGE_SIGNING_KEYS, MANAGE_NODE_OPERATOR_ROLE,