@@ -4,7 +4,11 @@ import util from "node:util";
44
55import { ethers } from "hardhat" ;
66
7+ import { LidoTemplate , WithdrawalQueueERC721 } from "typechain-types" ;
8+
79import { log } from "lib" ;
10+ import { loadContract } from "lib/contract" ;
11+ import { makeTx } from "lib/deploy" ;
812import { DeploymentState , getAddress , readNetworkState , Sk , updateObjectInState } from "lib/state-file" ;
913
1014const DG_INSTALL_DIR = `${ process . cwd ( ) } /dg` ;
@@ -13,6 +17,7 @@ const DG_DEPLOY_ARTIFACTS_DIR = `${DG_INSTALL_DIR}/deploy-artifacts`;
1317export async function main ( ) {
1418 if ( process . env . DG_DEPLOYMENT_ENABLED == "false" ) {
1519 log . header ( "DG deployment disabled" ) ;
20+ await finalizePermissionsWithoutDGDeployment ( ) ;
1621 return ;
1722 }
1823
7075 etherscanApiKey = process . env . ETHERSCAN_API_KEY ;
7176 }
7277
78+ await unpauseWithdrawalQueue ( deployer , state ) ;
79+
7380 await runCommand (
7481 `DEPLOY_CONFIG_FILE_NAME="${ dgDeployConfigFilename } " RPC_URL="${ process . env . LOCAL_RPC_URL } " ETHERSCAN_API_KEY="${ etherscanApiKey } " DEPLOYER_ADDRESS="${ deployer } " npm run forge:script scripts/deploy/DeployConfigurable.s.sol -- --broadcast --slow ${ etherscanVerifyOption } --private-key ${ deployerPrivateKey } ` ,
7582 DG_INSTALL_DIR ,
7683 ) ;
7784
78- await runDGRegressionTests ( chainId , state , process . env . LOCAL_RPC_URL ) ;
79-
8085 const dgDeployArtifacts = await getDGDeployArtifacts ( chainId ) ;
8186
87+ await transferRoles ( deployer , dgDeployArtifacts , state ) ;
88+
89+ await prepareDGRegressionTestsRun ( chainId , state , process . env . LOCAL_RPC_URL ) ;
90+
8291 saveDGNetworkState ( dgDeployArtifacts ) ;
8392}
8493
85- async function runDGRegressionTests ( networkChainId : string , networkState : DeploymentState , rpcUrl : string ) {
86- log . header ( "Run DG regression tests" ) ;
94+ async function finalizePermissionsWithoutDGDeployment ( ) {
95+ const deployer = ( await ethers . provider . getSigner ( ) ) . address ;
96+ const networkState = readNetworkState ( { deployer } ) ;
97+
98+ const lidoTemplateAddress = getAddress ( Sk . lidoTemplate , networkState ) ;
99+ const lidoTemplate = await loadContract < LidoTemplate > ( "LidoTemplate" , lidoTemplateAddress ) ;
100+
101+ await makeTx ( lidoTemplate , "finalizePermissionsWithoutDGDeployment" , [ ] , { from : deployer } ) ;
102+ }
103+
104+ async function transferRoles ( deployer : string , dgDeployArtifacts : DGDeployArtifacts , networkState : DeploymentState ) {
105+ const aragonAgentAddress = getAddress ( Sk . appAgent , networkState ) ;
106+ const votingAddress = getAddress ( Sk . appVoting , networkState ) ;
107+ const withdrawalQueueAddress = getAddress ( Sk . withdrawalQueueERC721 , networkState ) ;
108+ const lidoTemplateAddress = getAddress ( Sk . lidoTemplate , networkState ) ;
109+
110+ const lidoTemplate = await loadContract < LidoTemplate > ( "LidoTemplate" , lidoTemplateAddress ) ;
111+ const withdrawalQueue = await loadContract < WithdrawalQueueERC721 > ( "WithdrawalQueueERC721" , withdrawalQueueAddress ) ;
112+
113+ const DEFAULT_ADMIN_ROLE = ethers . ZeroHash ;
114+
115+ await makeTx ( withdrawalQueue , "grantRole" , [ DEFAULT_ADMIN_ROLE , aragonAgentAddress ] , {
116+ from : deployer ,
117+ } ) ;
118+
119+ await makeTx (
120+ withdrawalQueue ,
121+ "grantRole" ,
122+ [ await withdrawalQueue . PAUSE_ROLE ( ) , votingAddress /* = reseal_committee */ ] ,
123+ {
124+ from : deployer ,
125+ } ,
126+ ) ;
127+
128+ await makeTx (
129+ withdrawalQueue ,
130+ "grantRole" ,
131+ [ await withdrawalQueue . RESUME_ROLE ( ) , votingAddress /* = reseal_committee */ ] ,
132+ {
133+ from : deployer ,
134+ } ,
135+ ) ;
136+
137+ await makeTx ( withdrawalQueue , "grantRole" , [ await withdrawalQueue . PAUSE_ROLE ( ) , dgDeployArtifacts . reseal_manager ] , {
138+ from : deployer ,
139+ } ) ;
140+
141+ await makeTx ( withdrawalQueue , "grantRole" , [ await withdrawalQueue . RESUME_ROLE ( ) , dgDeployArtifacts . reseal_manager ] , {
142+ from : deployer ,
143+ } ) ;
144+
145+ await makeTx ( withdrawalQueue , "renounceRole" , [ await withdrawalQueue . DEFAULT_ADMIN_ROLE ( ) , deployer ] , {
146+ from : deployer ,
147+ } ) ;
148+
149+ await makeTx ( lidoTemplate , "finalizePermissionsAfterDGDeployment" , [ dgDeployArtifacts . admin_executor ] , {
150+ from : deployer ,
151+ } ) ;
152+ }
153+
154+ async function unpauseWithdrawalQueue ( deployer : string , networkState : DeploymentState ) {
155+ const withdrawalQueueAddress = getAddress ( Sk . withdrawalQueueERC721 , networkState ) ;
156+ const withdrawalQueue = await loadContract < WithdrawalQueueERC721 > ( "WithdrawalQueueERC721" , withdrawalQueueAddress ) ;
157+
158+ await makeTx ( withdrawalQueue , "grantRole" , [ await withdrawalQueue . RESUME_ROLE ( ) , deployer ] , {
159+ from : deployer ,
160+ } ) ;
161+
162+ await makeTx ( withdrawalQueue , "resume" , [ ] , {
163+ from : deployer ,
164+ } ) ;
165+ }
166+
167+ async function prepareDGRegressionTestsRun ( networkChainId : string , networkState : DeploymentState , rpcUrl : string ) {
168+ log . header ( "Prepare DG regression tests run: update DG .env file" ) ;
87169
88170 const deployArtifactFilename = await getLatestDGDeployArtifactFilename ( networkChainId ) ;
89171
90172 const dotEnvFile = getDGDotEnvFile ( deployArtifactFilename , networkState , rpcUrl ) ;
91173 await writeDGDotEnvFile ( dotEnvFile ) ;
92-
93- try {
94- await runCommand ( "npm run test:regressions" , DG_INSTALL_DIR ) ;
95- } catch ( error ) {
96- // TODO: some of regression tests don't work at the moment, need to fix it.
97- log . error ( "DG regression tests run failed" ) ;
98- log ( `${ error } ` ) ;
99- }
100174}
101175
102176async function runCommand ( command : string , workingDirectory : string ) {
@@ -168,7 +242,7 @@ function getDGConfig(chainId: string, networkState: DeploymentState) {
168242 dual_governance : {
169243 admin_proposer : daoVoting ,
170244 proposals_canceller : daoVoting ,
171- sealable_withdrawal_blockers : [ ] , // TODO: add withdrawalQueue
245+ sealable_withdrawal_blockers : [ withdrawalQueue ] ,
172246 reseal_committee : daoVoting ,
173247 tiebreaker_activation_timeout :
174248 networkState [ Sk . dualGovernanceConfig ] . dual_governance . tiebreaker_activation_timeout ,
@@ -266,6 +340,7 @@ function getDGDotEnvFile(deployArtifactFilename: string, networkState: Deploymen
266340 const elRewardsVault = getAddress ( Sk . executionLayerRewardsVault , networkState ) ;
267341 const withdrawalVault = getAddress ( Sk . withdrawalVault , networkState ) ;
268342 const oracleReportSanityChecker = getAddress ( Sk . oracleReportSanityChecker , networkState ) ;
343+ const stakingRouter = getAddress ( Sk . stakingRouter , networkState ) ;
269344 const acl = getAddress ( Sk . aragonAcl , networkState ) ;
270345 const ldo = getAddress ( Sk . ldo , networkState ) ;
271346 const daoAgent = getAddress ( Sk . appAgent , networkState ) ;
@@ -283,11 +358,13 @@ DG_TESTS_LIDO_ACCOUNTING_ORACLE=${accountingOracle}
283358DG_TESTS_LIDO_EL_REWARDS_VAULT=${ elRewardsVault }
284359DG_TESTS_LIDO_WITHDRAWAL_VAULT=${ withdrawalVault }
285360DG_TESTS_LIDO_ORACLE_REPORT_SANITY_CHECKER=${ oracleReportSanityChecker }
361+ DG_TESTS_LIDO_STAKING_ROUTER=${ stakingRouter }
286362DG_TESTS_LIDO_DAO_ACL=${ acl }
287363DG_TESTS_LIDO_LDO_TOKEN=${ ldo }
288364DG_TESTS_LIDO_DAO_AGENT=${ daoAgent }
289365DG_TESTS_LIDO_DAO_VOTING=${ daoVoting }
290366DG_TESTS_LIDO_DAO_TOKEN_MANAGER=${ daoTokenManager }
367+ DG_DISABLE_REGRESSION_TESTS_FOR_SCRATCH_DEPLOY=true
291368` ;
292369}
293370
@@ -357,7 +434,6 @@ async function getDGDeployArtifacts(networkChainId: string): Promise<DGDeployArt
357434
358435 ( Object . keys ( contractsAddressesRe ) as ( keyof DGDeployArtifacts ) [ ] ) . forEach ( ( key ) => {
359436 const address = deployArtifactFile . match ( contractsAddressesRe [ key ] ) ;
360- log ( "ADDRESS" , ( address && address [ 0 ] ) || "" , ( address && address [ 1 ] ) || "" ) ;
361437 if ( ! address || address . length < 2 || ! address [ 1 ] . length ) {
362438 throw new Error ( `DG deploy artifact file corrupted: ${ key } not found` ) ;
363439 }
0 commit comments