@@ -4,7 +4,11 @@ import util from "node:util";
4
4
5
5
import { ethers } from "hardhat" ;
6
6
7
+ import { LidoTemplate , WithdrawalQueueERC721 } from "typechain-types" ;
8
+
7
9
import { log } from "lib" ;
10
+ import { loadContract } from "lib/contract" ;
11
+ import { makeTx } from "lib/deploy" ;
8
12
import { DeploymentState , getAddress , readNetworkState , Sk , updateObjectInState } from "lib/state-file" ;
9
13
10
14
const DG_INSTALL_DIR = `${ process . cwd ( ) } /dg` ;
@@ -13,6 +17,7 @@ const DG_DEPLOY_ARTIFACTS_DIR = `${DG_INSTALL_DIR}/deploy-artifacts`;
13
17
export async function main ( ) {
14
18
if ( process . env . DG_DEPLOYMENT_ENABLED == "false" ) {
15
19
log . header ( "DG deployment disabled" ) ;
20
+ await finalizePermissionsWithoutDGDeployment ( ) ;
16
21
return ;
17
22
}
18
23
70
75
etherscanApiKey = process . env . ETHERSCAN_API_KEY ;
71
76
}
72
77
78
+ await unpauseWithdrawalQueue ( deployer , state ) ;
79
+
73
80
await runCommand (
74
81
`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 } ` ,
75
82
DG_INSTALL_DIR ,
76
83
) ;
77
84
78
- await runDGRegressionTests ( chainId , state , process . env . LOCAL_RPC_URL ) ;
79
-
80
85
const dgDeployArtifacts = await getDGDeployArtifacts ( chainId ) ;
81
86
87
+ await transferRoles ( deployer , dgDeployArtifacts , state ) ;
88
+
89
+ await prepareDGRegressionTestsRun ( chainId , state , process . env . LOCAL_RPC_URL ) ;
90
+
82
91
saveDGNetworkState ( dgDeployArtifacts ) ;
83
92
}
84
93
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" ) ;
87
169
88
170
const deployArtifactFilename = await getLatestDGDeployArtifactFilename ( networkChainId ) ;
89
171
90
172
const dotEnvFile = getDGDotEnvFile ( deployArtifactFilename , networkState , rpcUrl ) ;
91
173
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
- }
100
174
}
101
175
102
176
async function runCommand ( command : string , workingDirectory : string ) {
@@ -168,7 +242,7 @@ function getDGConfig(chainId: string, networkState: DeploymentState) {
168
242
dual_governance : {
169
243
admin_proposer : daoVoting ,
170
244
proposals_canceller : daoVoting ,
171
- sealable_withdrawal_blockers : [ ] , // TODO: add withdrawalQueue
245
+ sealable_withdrawal_blockers : [ withdrawalQueue ] ,
172
246
reseal_committee : daoVoting ,
173
247
tiebreaker_activation_timeout :
174
248
networkState [ Sk . dualGovernanceConfig ] . dual_governance . tiebreaker_activation_timeout ,
@@ -266,6 +340,7 @@ function getDGDotEnvFile(deployArtifactFilename: string, networkState: Deploymen
266
340
const elRewardsVault = getAddress ( Sk . executionLayerRewardsVault , networkState ) ;
267
341
const withdrawalVault = getAddress ( Sk . withdrawalVault , networkState ) ;
268
342
const oracleReportSanityChecker = getAddress ( Sk . oracleReportSanityChecker , networkState ) ;
343
+ const stakingRouter = getAddress ( Sk . stakingRouter , networkState ) ;
269
344
const acl = getAddress ( Sk . aragonAcl , networkState ) ;
270
345
const ldo = getAddress ( Sk . ldo , networkState ) ;
271
346
const daoAgent = getAddress ( Sk . appAgent , networkState ) ;
@@ -283,11 +358,13 @@ DG_TESTS_LIDO_ACCOUNTING_ORACLE=${accountingOracle}
283
358
DG_TESTS_LIDO_EL_REWARDS_VAULT=${ elRewardsVault }
284
359
DG_TESTS_LIDO_WITHDRAWAL_VAULT=${ withdrawalVault }
285
360
DG_TESTS_LIDO_ORACLE_REPORT_SANITY_CHECKER=${ oracleReportSanityChecker }
361
+ DG_TESTS_LIDO_STAKING_ROUTER=${ stakingRouter }
286
362
DG_TESTS_LIDO_DAO_ACL=${ acl }
287
363
DG_TESTS_LIDO_LDO_TOKEN=${ ldo }
288
364
DG_TESTS_LIDO_DAO_AGENT=${ daoAgent }
289
365
DG_TESTS_LIDO_DAO_VOTING=${ daoVoting }
290
366
DG_TESTS_LIDO_DAO_TOKEN_MANAGER=${ daoTokenManager }
367
+ DG_DISABLE_REGRESSION_TESTS_FOR_SCRATCH_DEPLOY=true
291
368
` ;
292
369
}
293
370
@@ -357,7 +434,6 @@ async function getDGDeployArtifacts(networkChainId: string): Promise<DGDeployArt
357
434
358
435
( Object . keys ( contractsAddressesRe ) as ( keyof DGDeployArtifacts ) [ ] ) . forEach ( ( key ) => {
359
436
const address = deployArtifactFile . match ( contractsAddressesRe [ key ] ) ;
360
- log ( "ADDRESS" , ( address && address [ 0 ] ) || "" , ( address && address [ 1 ] ) || "" ) ;
361
437
if ( ! address || address . length < 2 || ! address [ 1 ] . length ) {
362
438
throw new Error ( `DG deploy artifact file corrupted: ${ key } not found` ) ;
363
439
}
0 commit comments