Skip to content

Commit d7844ec

Browse files
committed
feat: fix code review comments
1 parent 4a91c5a commit d7844ec

File tree

10 files changed

+280
-137
lines changed

10 files changed

+280
-137
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ GAS_PRIORITY_FEE=1
6060
GAS_MAX_FEE=100
6161

6262
# Dual Governance deployment
63-
DG_DEPLOYER_ACCOUNT_NAME=
63+
DG_DEPLOYMENT_ENABLED=true
64+
DG_DEPLOYER_ACCOUNT_NETWORK_NAME=
65+
DG_ETHERSCAN_VERIFY=false
6466

6567
# Etherscan API key for verifying contracts
6668
ETHERSCAN_API_KEY=

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ artifacts/
1818
foundry/cache/
1919
foundry/out/
2020

21+
# Dual Governance files
22+
dg/
23+
2124
# Extracted ABI files
2225
lib/abi/*.json
2326

lib/dg-installation.ts

Lines changed: 13 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,79 +2,25 @@ import child_process from "node:child_process";
22
import fs from "node:fs/promises";
33
import util from "node:util";
44

5-
async function main() {
6-
const dgDir = `${process.cwd()}/node_modules/@lido/dual-governance`;
7-
const gitmodulesPath = `${dgDir}/.gitmodules`;
8-
9-
const gitmodulesExists = await checkFileExists(gitmodulesPath);
10-
if (!gitmodulesExists) {
11-
console.log(`.gitmodules file not found at ${gitmodulesPath}`);
12-
return;
13-
}
14-
15-
console.log(`.gitmodules file found at ${gitmodulesPath}`);
16-
17-
const gitmodulesFile = (await fs.readFile(gitmodulesPath)).toString().replaceAll(/\t/g, "");
5+
const DG_REPOSITORY_URL = "https://github.com/lidofinance/dual-governance.git";
6+
const DG_REPOSITORY_BRANCH = "feature/scratch-deploy-support"; // TODO: use release branch
7+
const DG_INSTALL_DIR = `${process.cwd()}/dg`;
188

19-
const submodules = parseGitmodules(gitmodulesFile);
20-
console.log(submodules);
21-
22-
await fs.rm(`${dgDir}/lib`, { force: true, recursive: true });
9+
async function main() {
10+
console.log("Delete DG folder", DG_INSTALL_DIR);
11+
await fs.rm(DG_INSTALL_DIR, { force: true, recursive: true });
2312

24-
await cloneSubmodules(submodules);
13+
console.log("Clone DG repo to", DG_INSTALL_DIR);
14+
await runCommand(
15+
`git clone --branch ${DG_REPOSITORY_BRANCH} --single-branch ${DG_REPOSITORY_URL} ${DG_INSTALL_DIR}`,
16+
process.cwd(),
17+
);
2518

2619
console.log("Building DualGovernance contracts");
27-
await runForgeBuild(dgDir);
20+
await runForgeBuild(DG_INSTALL_DIR);
2821

2922
console.log("Running unit tests");
30-
await runUnitTests(dgDir);
31-
}
32-
33-
type GitSubmodule = {
34-
path: string;
35-
url: string;
36-
branch?: string;
37-
};
38-
39-
/**
40-
* @param {String} gitmodulesFile .gitmodules file content
41-
*/
42-
function parseGitmodules(gitmodulesFile: string) {
43-
const submoduleSectionRe = /\[submodule(\s+)('|")(.+)('|")\]([^\[]+)/gm;
44-
const submodulePropertyRe = /(path)(.+)|(url)(.+)|(branch)(.+)/g;
45-
const submodulesList = [...gitmodulesFile.matchAll(submoduleSectionRe)];
46-
const result: Record<string, GitSubmodule> = {};
47-
48-
if (!submodulesList.length) {
49-
return result;
50-
}
51-
52-
submodulesList.forEach((submoduleText) => {
53-
const item: GitSubmodule = {
54-
path: "",
55-
url: ""
56-
};
57-
const submodulePropertiesList = [...(submoduleText[5] || "").matchAll(submodulePropertyRe)];
58-
submodulePropertiesList.forEach((conf) => {
59-
const [key = "", value = ""] = (conf[0] ?? "").split("=");
60-
const pureKey = key.trim() as "path" | "url" | "branch";
61-
if (pureKey) {
62-
item[pureKey] = value.trim();
63-
}
64-
});
65-
result[item.path] = item;
66-
})
67-
return result;
68-
}
69-
70-
async function cloneSubmodules(submodules: Record<string, GitSubmodule>) {
71-
for (const key of Object.keys(submodules)) {
72-
let branch = submodules[key].branch || "";
73-
if (branch.length && branch.indexOf("tag") != -1) {
74-
branch = branch.replace("tags/", "");
75-
}
76-
await runCommand(`git clone ${branch.length ? `--branch ${branch}` : ""} --single-branch ${submodules[key].url} ${process.cwd()}/node_modules/@lido/dual-governance/${submodules[key].path}`, process.cwd());
77-
}
23+
await runUnitTests(DG_INSTALL_DIR);
7824
}
7925

8026
async function runForgeBuild(workingDirectory: string) {
@@ -97,12 +43,6 @@ async function runCommand(command: string, workingDirectory: string) {
9743
}
9844
}
9945

100-
async function checkFileExists(path: string) {
101-
return fs.access(path)
102-
.then(() => true)
103-
.catch(() => false);
104-
}
105-
10646
main()
10747
.then(() => process.exit(0))
10848
.catch((error) => {

lib/state-file.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ export enum Sk {
8686
chainSpec = "chainSpec",
8787
scratchDeployGasUsed = "scratchDeployGasUsed",
8888
minFirstAllocationStrategy = "minFirstAllocationStrategy",
89+
dualGovernanceConfig = "dualGovernanceConfig",
90+
dgAdminExecutor = "dg:admin_executor",
91+
dualGovernance = "dg:dual_governance",
92+
dgConfigProvider = "dg:dual_governance_config_provider",
93+
dgEmergencyGovernance = "dg:emergency_governance",
94+
dgEscrowMasterCopy = "dg:escrow_master_copy",
95+
dgResealManager = "dg:reseal_manager",
96+
dgTiebreakerCoreCommittee = "dg:tiebreaker_core_committee",
97+
dgTimelock = "dg:timelock",
8998
}
9099

91100
export function getAddress(contractKey: Sk, state: DeploymentState): string {
@@ -130,6 +139,14 @@ export function getAddress(contractKey: Sk, state: DeploymentState): string {
130139
case Sk.oracleReportSanityChecker:
131140
case Sk.wstETH:
132141
case Sk.depositContract:
142+
case Sk.dgAdminExecutor:
143+
case Sk.dualGovernance:
144+
case Sk.dgConfigProvider:
145+
case Sk.dgEmergencyGovernance:
146+
case Sk.dgEscrowMasterCopy:
147+
case Sk.dgResealManager:
148+
case Sk.dgTiebreakerCoreCommittee:
149+
case Sk.dgTimelock:
133150
return state[contractKey].address;
134151
default:
135152
throw new Error(`Unsupported contract entry key ${contractKey}`);

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
"test:integration:fork:local": "MODE=scratch hardhat test test/integration/**/*.ts --network local",
3232
"test:integration:fork:mainnet": "MODE=forking hardhat test test/integration/**/*.ts --network mainnet-fork",
3333
"test:integration:fork:mainnet:custom": "MODE=forking hardhat test --network mainnet-fork",
34+
"dg:install": "yarn ts-node lib/dg-installation.ts",
3435
"typecheck": "tsc --noEmit",
3536
"prepare": "husky",
36-
"postinstall": "yarn ts-node lib/dg-installation.ts",
3737
"abis:extract": "hardhat abis:extract",
3838
"verify:deployed": "hardhat verify:deployed"
3939
},
@@ -107,7 +107,6 @@
107107
"@aragon/id": "2.1.1",
108108
"@aragon/minime": "1.0.0",
109109
"@aragon/os": "4.4.0",
110-
"@lido/dual-governance": "https://github.com/lidofinance/dual-governance.git#feature/scratch-deploy-support",
111110
"@openzeppelin/contracts": "3.4.0",
112111
"@openzeppelin/contracts-v4.4": "npm:@openzeppelin/[email protected]",
113112
"openzeppelin-solidity": "2.0.0"

scripts/dao-deploy.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ echo "NETWORK is $NETWORK"
1818
rm -f "${NETWORK_STATE_FILE}"
1919
cp "${NETWORK_STATE_DEFAULTS_FILE}" "${NETWORK_STATE_FILE}"
2020

21+
yarn dg:install
22+
2123
# Compile contracts
2224
yarn compile
2325

scripts/dao-upgrade.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ if [[ -z "${NETWORK}" ]]; then
1515
fi
1616
echo "NETWORK is $NETWORK"
1717

18+
yarn dg:install
19+
1820
# Compile contracts
1921
yarn compile
2022

scripts/scratch/deployed-testnet-defaults.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,49 @@
149149
"symbol": "unstETH",
150150
"baseUri": null
151151
}
152+
},
153+
"dualGovernanceConfig": {
154+
"dual_governance": {
155+
"tiebreaker_activation_timeout": 31536000,
156+
"sanity_check_params": {
157+
"max_min_assets_lock_duration": 4147200,
158+
"max_sealable_withdrawal_blockers_count": 255,
159+
"max_tiebreaker_activation_timeout": 63072000,
160+
"min_tiebreaker_activation_timeout": 15768000,
161+
"min_withdrawals_batch_size": 4
162+
}
163+
},
164+
"dual_governance_config_provider": {
165+
"first_seal_rage_quit_support": "10000000000000000",
166+
"second_seal_rage_quit_support": "100000000000000000",
167+
"min_assets_lock_duration": 18000,
168+
"rage_quit_eth_withdrawals_delay_growth": 1296000,
169+
"rage_quit_eth_withdrawals_min_delay": 5184000,
170+
"rage_quit_eth_withdrawals_max_delay": 15552000,
171+
"rage_quit_extension_period_duration": 604800,
172+
"veto_cooldown_duration": 18000,
173+
"veto_signalling_deactivation_max_duration": 259200,
174+
"veto_signalling_min_active_duration": 18000,
175+
"veto_signalling_min_duration": 432000,
176+
"veto_signalling_max_duration": 3888000
177+
},
178+
"timelock": {
179+
"after_submit_delay": 259200,
180+
"after_schedule_delay": 86400,
181+
"sanity_check_params": {
182+
"min_execution_delay": 259200,
183+
"max_after_submit_delay": 2592000,
184+
"max_after_schedule_delay": 864000,
185+
"max_emergency_mode_duration": 31536000,
186+
"max_emergency_protection_duration": 94608000
187+
},
188+
"emergency_protection": {
189+
"emergency_mode_duration": 2592000,
190+
"emergency_protection_end_date": 1781913600
191+
}
192+
},
193+
"tiebreaker": {
194+
"execution_delay": 2592000
195+
}
152196
}
153197
}

0 commit comments

Comments
 (0)