Skip to content

Commit 4b6dc09

Browse files
committed
fix: dual governance deployment after rebase
1 parent 96a7f3c commit 4b6dc09

File tree

10 files changed

+122
-91
lines changed

10 files changed

+122
-91
lines changed

lib/config-schemas.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,66 @@ const LidoApmSchema = z.object({
238238
ensRegDurationSec: PositiveIntSchema,
239239
});
240240

241+
// DG deployment config schemas
242+
const DGConfigDGSanityCheckParamsSchema = z.object({
243+
max_min_assets_lock_duration: PositiveIntSchema,
244+
max_sealable_withdrawal_blockers_count: PositiveIntSchema,
245+
max_tiebreaker_activation_timeout: PositiveIntSchema,
246+
min_tiebreaker_activation_timeout: NonNegativeIntSchema,
247+
min_withdrawals_batch_size: PositiveIntSchema,
248+
});
249+
250+
const DGConfigDGSchema = z.object({
251+
tiebreaker_activation_timeout: NonNegativeIntSchema,
252+
sanity_check_params: DGConfigDGSanityCheckParamsSchema,
253+
});
254+
255+
const DGConfigDGConfigProviderSchema = z.object({
256+
first_seal_rage_quit_support: BigIntStringSchema,
257+
second_seal_rage_quit_support: BigIntStringSchema,
258+
min_assets_lock_duration: NonNegativeIntSchema,
259+
rage_quit_eth_withdrawals_delay_growth: PositiveIntSchema,
260+
rage_quit_eth_withdrawals_min_delay: NonNegativeIntSchema,
261+
rage_quit_eth_withdrawals_max_delay: PositiveIntSchema,
262+
rage_quit_extension_period_duration: NonNegativeIntSchema,
263+
veto_cooldown_duration: NonNegativeIntSchema,
264+
veto_signalling_deactivation_max_duration: PositiveIntSchema,
265+
veto_signalling_min_duration: NonNegativeIntSchema,
266+
veto_signalling_max_duration: PositiveIntSchema,
267+
veto_signalling_min_active_duration: NonNegativeIntSchema,
268+
});
269+
270+
const DGConfigTimelockSanityCheckParamsSchema = z.object({
271+
min_execution_delay: NonNegativeIntSchema,
272+
max_after_submit_delay: PositiveIntSchema,
273+
max_after_schedule_delay: PositiveIntSchema,
274+
max_emergency_mode_duration: PositiveIntSchema,
275+
max_emergency_protection_duration: PositiveIntSchema,
276+
});
277+
278+
const DGConfigTimelockEmergencyProtectionSchema = z.object({
279+
emergency_mode_duration: NonNegativeIntSchema,
280+
emergency_protection_end_date: PositiveIntSchema,
281+
});
282+
283+
const DGConfigTimelockSchema = z.object({
284+
after_submit_delay: NonNegativeIntSchema,
285+
after_schedule_delay: NonNegativeIntSchema,
286+
sanity_check_params: DGConfigTimelockSanityCheckParamsSchema,
287+
emergency_protection: DGConfigTimelockEmergencyProtectionSchema,
288+
});
289+
290+
const DGConfigTiebreakerSchema = z.object({
291+
execution_delay: NonNegativeIntSchema,
292+
});
293+
294+
const DGConfigSchema = z.object({
295+
dual_governance: DGConfigDGSchema,
296+
dual_governance_config_provider: DGConfigDGConfigProviderSchema,
297+
timelock: DGConfigTimelockSchema,
298+
tiebreaker: DGConfigTiebreakerSchema,
299+
});
300+
241301
// Scratch parameters schema
242302
export const ScratchParametersSchema = z.object({
243303
chainSpec: ChainSpecSchema.omit({ genesisTime: true, depositContract: true }),
@@ -267,6 +327,7 @@ export const ScratchParametersSchema = z.object({
267327
triggerableWithdrawalsGateway: TriggerableWithdrawalsGatewaySchema,
268328
predepositGuarantee: PredepositGuaranteeSchema.omit({ genesisForkVersion: true }),
269329
operatorGrid: OperatorGridSchema,
330+
dualGovernanceConfig: DGConfigSchema,
270331
});
271332

272333
// Inferred types from zod schemas

lib/dg-installation.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import child_process from "node:child_process";
21
import fs from "node:fs/promises";
3-
import util from "node:util";
2+
3+
import { runCommand } from "./subprocess";
44

55
const DG_REPOSITORY_URL = "https://github.com/lidofinance/dual-governance.git";
66
const DG_REPOSITORY_BRANCH = "feature/scratch-deploy-support2"; // TODO: use release branch
@@ -31,18 +31,6 @@ async function runUnitTests(workingDirectory: string) {
3131
await runCommand("npm run test:unit", workingDirectory);
3232
}
3333

34-
async function runCommand(command: string, workingDirectory: string) {
35-
const exec = util.promisify(child_process.exec);
36-
37-
try {
38-
const { stdout } = await exec(command, { cwd: workingDirectory });
39-
console.log("stdout:", stdout);
40-
} catch (error) {
41-
console.error(`Error running command ${command}`, `${error}`);
42-
throw error;
43-
}
44-
}
45-
4634
main()
4735
.then(() => process.exit(0))
4836
.catch((error) => {

lib/dg-regression-tests.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { log } from "./log";
2+
import { runCommand } from "./subprocess";
3+
4+
const DG_INSTALL_DIR = `${process.cwd()}/dg`;
5+
6+
async function runDGRegressionTests() {
7+
log.header("Run Dual Governance regression tests");
8+
try {
9+
await runCommand("npm run test:regressions", DG_INSTALL_DIR);
10+
} catch (error) {
11+
// TODO: some of regression tests don't work at the moment, need to fix it.
12+
log.error("DG regression tests run failed");
13+
log(`${error}`);
14+
}
15+
}
16+
17+
runDGRegressionTests()
18+
.then(() => process.exit(0))
19+
.catch((error) => {
20+
console.error(error);
21+
process.exit(1);
22+
});

lib/subprocess.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import child_process from "node:child_process";
2+
import util from "node:util";
3+
4+
export async function runCommand(command: string, workingDirectory: string) {
5+
const exec = util.promisify(child_process.exec);
6+
7+
try {
8+
const { stdout } = await exec(command, { cwd: workingDirectory });
9+
console.log("stdout:", stdout);
10+
} catch (error) {
11+
console.error(`Error running command ${command}`, `${error}`);
12+
throw error;
13+
}
14+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"validate:configs": "yarn hardhat validate-configs",
4444
"typecheck": "tsc --noEmit",
4545
"dg:install": "yarn ts-node lib/dg-installation.ts",
46+
"dg:regression-tests": "yarn ts-node lib/dg-regression-tests.ts",
4647
"abis:extract": "hardhat abis:extract",
4748
"verify:deployed": "hardhat verify:deployed",
4849
"postinstall": "husky"

scripts/dao-local-deploy.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ export INTEGRATION_WITH_CSM="off"
2626
yarn test:integration:fork:local
2727

2828
# If Dual Governance was deployed
29-
if grep "dg:dual_governance" $NETWORK_STATE_FILE -q; then
30-
# Run DG regression tests
31-
echo "Run Dual Governance regression tests"
32-
(cd dg && npm run test:regressions)
29+
if grep "dg:dualGovernance" $NETWORK_STATE_FILE -q; then
30+
yarn dg:regression-tests
3331
fi

scripts/dao-local-upgrade.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ yarn hardhat --network $NETWORK run --no-compile scripts/utils/mine.ts
2424
yarn test:integration:fork:local
2525

2626
# If Dual Governance was deployed
27-
if grep "dg:dual_governance" $NETWORK_STATE_FILE -q; then
28-
# Run DG regression tests
29-
echo "Run Dual Governance regression tests"
30-
(cd dg && npm run test:regressions)
27+
if grep "dg:dualGovernance" $NETWORK_STATE_FILE -q; then
28+
yarn dg:regression-tests
3129
fi

scripts/scratch/steps/0150-transfer-roles.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ export async function main() {
6565
await makeTx(depositSecurityModule, "setOwner", [agent], { from: deployer });
6666
}
6767

68-
// Transfer ownership of LidoTemplate to agent
69-
const lidoTemplate = await loadContract("LidoTemplate", state[Sk.lidoTemplate].address);
70-
await makeTx(lidoTemplate, "setOwner", [agent], { from: deployer });
71-
7268
// Transfer admin for WithdrawalsManagerProxy from deployer to voting
7369
const withdrawalsManagerProxy = await loadContract("WithdrawalsManagerProxy", state.withdrawalVault.proxy.address);
7470
await makeTx(withdrawalsManagerProxy, "proxy_changeAdmin", [voting], { from: deployer });

scripts/scratch/steps/0160-deploy-dual-governance.ts

Lines changed: 17 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import child_process from "node:child_process";
21
import fs from "node:fs/promises";
3-
import util from "node:util";
42

53
import { ethers } from "hardhat";
64

75
import { LidoTemplate, WithdrawalQueueERC721 } from "typechain-types";
86

97
import { log } from "lib";
10-
import { loadContract } from "lib/contract";
8+
import { loadContract, LoadedContract } from "lib/contract";
119
import { makeTx } from "lib/deploy";
1210
import { DeploymentState, getAddress, readNetworkState, Sk, updateObjectInState } from "lib/state-file";
11+
import { runCommand } from "lib/subprocess";
1312

1413
const DG_INSTALL_DIR = `${process.cwd()}/dg`;
1514
const DG_DEPLOY_ARTIFACTS_DIR = `${DG_INSTALL_DIR}/deploy-artifacts`;
@@ -99,6 +98,16 @@ async function finalizePermissionsWithoutDGDeployment() {
9998
const lidoTemplate = await loadContract<LidoTemplate>("LidoTemplate", lidoTemplateAddress);
10099

101100
await makeTx(lidoTemplate, "finalizePermissionsWithoutDGDeployment", [], { from: deployer });
101+
102+
await transferLidoTemplateOwnershipToAgent(deployer, lidoTemplate, getAddress(Sk.appAgent, networkState));
103+
}
104+
105+
async function transferLidoTemplateOwnershipToAgent(
106+
deployer: string,
107+
lidoTemplate: LoadedContract<LidoTemplate>,
108+
aragonAgentAddress: string,
109+
) {
110+
await makeTx(lidoTemplate, "setOwner", [aragonAgentAddress], { from: deployer });
102111
}
103112

104113
async function transferRoles(deployer: string, dgDeployArtifacts: DGDeployArtifacts, networkState: DeploymentState) {
@@ -149,6 +158,8 @@ async function transferRoles(deployer: string, dgDeployArtifacts: DGDeployArtifa
149158
await makeTx(lidoTemplate, "finalizePermissionsAfterDGDeployment", [dgDeployArtifacts.admin_executor], {
150159
from: deployer,
151160
});
161+
162+
await transferLidoTemplateOwnershipToAgent(deployer, lidoTemplate, aragonAgentAddress);
152163
}
153164

154165
async function unpauseWithdrawalQueue(deployer: string, networkState: DeploymentState) {
@@ -173,18 +184,6 @@ async function prepareDGRegressionTestsRun(networkChainId: string, networkState:
173184
await writeDGDotEnvFile(dotEnvFile);
174185
}
175186

176-
async function runCommand(command: string, workingDirectory: string) {
177-
const exec = util.promisify(child_process.exec);
178-
179-
try {
180-
const { stdout } = await exec(command, { cwd: workingDirectory });
181-
log("stdout:", stdout);
182-
} catch (error) {
183-
log.error(`Error running command ${command}`, `${error}`);
184-
throw error;
185-
}
186-
}
187-
188187
async function writeDGConfigFile(dgConfig: string, filename: string) {
189188
const dgConfigFilePath = `${DG_INSTALL_DIR}/deploy-config/${filename}`;
190189

@@ -252,60 +251,13 @@ function getDGConfig(chainId: string, networkState: DeploymentState) {
252251
wst_eth: wstEth,
253252
withdrawal_queue: withdrawalQueue,
254253
},
255-
sanity_check_params: {
256-
max_min_assets_lock_duration:
257-
networkState[Sk.dualGovernanceConfig].dual_governance.sanity_check_params.max_min_assets_lock_duration,
258-
max_sealable_withdrawal_blockers_count:
259-
networkState[Sk.dualGovernanceConfig].dual_governance.sanity_check_params
260-
.max_sealable_withdrawal_blockers_count,
261-
max_tiebreaker_activation_timeout:
262-
networkState[Sk.dualGovernanceConfig].dual_governance.sanity_check_params.max_tiebreaker_activation_timeout,
263-
min_tiebreaker_activation_timeout:
264-
networkState[Sk.dualGovernanceConfig].dual_governance.sanity_check_params.min_tiebreaker_activation_timeout,
265-
min_withdrawals_batch_size:
266-
networkState[Sk.dualGovernanceConfig].dual_governance.sanity_check_params.min_withdrawals_batch_size,
267-
},
268-
},
269-
dual_governance_config_provider: {
270-
first_seal_rage_quit_support:
271-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.first_seal_rage_quit_support,
272-
second_seal_rage_quit_support:
273-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.second_seal_rage_quit_support,
274-
min_assets_lock_duration:
275-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.min_assets_lock_duration,
276-
rage_quit_eth_withdrawals_delay_growth:
277-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.rage_quit_eth_withdrawals_delay_growth,
278-
rage_quit_eth_withdrawals_min_delay:
279-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.rage_quit_eth_withdrawals_min_delay,
280-
rage_quit_eth_withdrawals_max_delay:
281-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.rage_quit_eth_withdrawals_max_delay,
282-
rage_quit_extension_period_duration:
283-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.rage_quit_extension_period_duration,
284-
veto_cooldown_duration:
285-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.veto_cooldown_duration,
286-
veto_signalling_deactivation_max_duration:
287-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.veto_signalling_deactivation_max_duration,
288-
veto_signalling_min_active_duration:
289-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.veto_signalling_min_active_duration,
290-
veto_signalling_min_duration:
291-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.veto_signalling_min_duration,
292-
veto_signalling_max_duration:
293-
networkState[Sk.dualGovernanceConfig].dual_governance_config_provider.veto_signalling_max_duration,
254+
sanity_check_params: networkState[Sk.dualGovernanceConfig].dual_governance.sanity_check_params,
294255
},
256+
dual_governance_config_provider: networkState[Sk.dualGovernanceConfig].dual_governance_config_provider,
295257
timelock: {
296258
after_submit_delay: networkState[Sk.dualGovernanceConfig].timelock.after_submit_delay,
297259
after_schedule_delay: networkState[Sk.dualGovernanceConfig].timelock.after_schedule_delay,
298-
sanity_check_params: {
299-
min_execution_delay: networkState[Sk.dualGovernanceConfig].timelock.sanity_check_params.min_execution_delay,
300-
max_after_submit_delay:
301-
networkState[Sk.dualGovernanceConfig].timelock.sanity_check_params.max_after_submit_delay,
302-
max_after_schedule_delay:
303-
networkState[Sk.dualGovernanceConfig].timelock.sanity_check_params.max_after_schedule_delay,
304-
max_emergency_mode_duration:
305-
networkState[Sk.dualGovernanceConfig].timelock.sanity_check_params.max_emergency_mode_duration,
306-
max_emergency_protection_duration:
307-
networkState[Sk.dualGovernanceConfig].timelock.sanity_check_params.max_emergency_protection_duration,
308-
},
260+
sanity_check_params: networkState[Sk.dualGovernanceConfig].timelock.sanity_check_params,
309261
emergency_protection: {
310262
emergency_activation_committee: daoVoting,
311263
emergency_execution_committee: daoVoting,

scripts/utils/scratch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,6 @@ export function scratchParametersToDeploymentState(params: ScratchParameters): R
121121
operatorGrid: {
122122
deployParameters: params.operatorGrid,
123123
},
124+
dualGovernanceConfig: params.dualGovernanceConfig,
124125
};
125126
}

0 commit comments

Comments
 (0)