Skip to content

Commit 5934207

Browse files
authored
Merge pull request #989 from lidofinance/feat/vaults-backports
feat: vaults backports
2 parents 5f66cf9 + b485286 commit 5934207

12 files changed

+2086
-1729
lines changed

.github/workflows/tests-integration-mainnet.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
services:
1515
hardhat-node:
16-
image: ghcr.io/lidofinance/hardhat-node:2.22.17
16+
image: ghcr.io/lidofinance/hardhat-node:2.22.19
1717
ports:
1818
- 8545:8545
1919
env:

.github/workflows/tests-integration-scratch.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010

1111
services:
1212
hardhat-node:
13-
image: ghcr.io/lidofinance/hardhat-node:2.22.17-scratch
13+
image: ghcr.io/lidofinance/hardhat-node:2.22.19-scratch
1414
ports:
1515
- 8555:8545
1616

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.idea/
22
.yarn/
3+
.vscode/
34

45
node_modules/
56
coverage/

.prettierignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
foundry
2-
contracts
1+
/foundry
2+
/contracts
33

44
.gitignore
55
.prettierignore

CONTRIBUTING.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ the [Lido Research Forum](https://research.lido.fi/).
5151

5252
> [!TIP]
5353
> On macOS with Homebrew, it is recommended to install Node.js using [`n`](https://github.com/tj/n) or
54-
> [ >`nvm`](https://github.com/nvm-sh/nvm) version managers.
54+
> [`nvm`](https://github.com/nvm-sh/nvm) version managers.
5555
>
5656
> Example setup process using `n` package manager for zsh users:
5757
>
@@ -259,19 +259,19 @@ maintain optimal test performance.
259259
260260
To enable tracing:
261261
262-
- Wrap the code you want to trace with `Tracer.enable()` and `Tracer.disable()` functions.
262+
- Wrap the code you want to trace with `Tracing.enable()` and `Tracing.disable()` functions.
263263
- Run the tests with the appropriate command that enables tracing (e.g., `yarn test:trace`).
264264
265265
Here's an example:
266266
267267
```typescript
268-
import { Tracer } from "test/suite";
268+
import { Tracing } from "test/suite";
269269
270270
describe("MyContract", () => {
271271
it("should do something", async () => {
272-
Tracer.enable();
272+
Tracing.enable();
273273
// code to trace
274-
Tracer.disable();
274+
Tracing.disable();
275275
});
276276
});
277277
```

docs/scratch-deploy.md

+22-22
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The repository contains bash scripts for deploying the DAO across various enviro
2020

2121
- Local Node Deployment - `scripts/dao-local-deploy.sh` (Supports Ganache, Anvil, Hardhat Network, and other local
2222
Ethereum nodes)
23-
- Holešky Testnet Deployment – `scripts/dao-holesky-deploy.sh`
23+
- Holesky Testnet Deployment – `scripts/dao-holesky-deploy.sh`
2424

2525
The protocol requires configuration of numerous parameters for a scratch deployment. The default configurations are
2626
stored in JSON files named `deployed-<deploy env>-defaults.json`, where `<deploy env>` represents the target
@@ -102,7 +102,7 @@ mnemonic.
102102

103103
Follow these steps for local deployment:
104104

105-
1. Run `yarn install` (get sure repo dependencies are installed)
105+
1. Run `yarn install` (ensure repo dependencies are installed)
106106
2. Run the node on port 8555 (for the commands, see subsections below)
107107
3. Run the deploy script `bash scripts/dao-local-deploy.sh` from root repo directory
108108
4. Check out the deploy artifacts in `deployed-local.json`
@@ -121,9 +121,9 @@ anvil -p 8555 --mnemonic "test test test test test test test test test test test
121121
yarn hardhat node
122122
```
123123

124-
### Holešky Testnet Deployment
124+
### Holesky Testnet Deployment
125125

126-
To do Holešky deployment, the following parameters must be set up via env variables:
126+
To do Holesky deployment, the following parameters must be set up via env variables:
127127

128128
- `DEPLOYER`. The deployer address. The deployer must own its private key. To ensure proper operation, it should have an
129129
adequate amount of ether. The total deployment gas cost is approximately 120,000,000 gas, and this cost can vary based
@@ -134,27 +134,27 @@ To do Holešky deployment, the following parameters must be set up via env varia
134134
- `GAS_MAX_FEE`. Gas max fee. By default set to `100`
135135
- `GATE_SEAL_FACTORY`. Address of the [GateSeal Factory](https://github.com/lidofinance/gate-seals) contract. Must be
136136
deployed in advance. Can be set to any `0x0000000000000000000000000000000000000000` to debug deployment
137-
- `WITHDRAWAL_QUEUE_BASE_URI`. BaseURI for WithdrawalQueueERC712. By default not set (left an empty string)
137+
- `WITHDRAWAL_QUEUE_BASE_URI`. BaseURI for WithdrawalQueueERC721. By default not set (left an empty string)
138138
- `DSM_PREDEFINED_ADDRESS`. Address to use instead of deploying `DepositSecurityModule` or `null` otherwise. If used,
139139
the deposits can be made by calling `Lido.deposit` from the address.
140140

141141
Also you need to specify `DEPLOYER` private key in `accounts.json` under `/eth/holesky` like `"holesky": ["<key>"]`. See
142142
`accounts.sample.json` for an example.
143143

144-
To start the deployment, run (the env variables must already defined) from the root repo directory:
144+
To start the deployment, run (the env variables must already be defined) from the root repo directory, e.g.:
145145

146146
```shell
147147
bash scripts/scratch/dao-holesky-deploy.sh
148148
```
149149

150-
Deploy artifacts information will be stored in `deployed-holesky.json`.
150+
Deployment artifacts information will be stored in `deployed-holesky.json`.
151151

152152
## Post-Deployment Tasks
153153

154154
### Publishing Sources to Etherscan
155155

156156
```shell
157-
NETWORK=<PUT-YOUR-VALUE> RPC_URL=<PUT-YOUR-VALUE> bash ./scripts/verify-contracts-code.sh
157+
yarn verify:deployed --network <network> (--file <path-to-deployed-json>)
158158
```
159159

160160
#### Issues with verification of part of the contracts deployed from factories
@@ -169,18 +169,18 @@ There are some contracts deployed from other contracts for which automatic hardh
169169
- `CallsScript` -- Aragon internal contract
170170
- `EVMScriptRegistry` -- Aragon internal contract
171171

172-
The workaround used during Holešky deployment is to deploy auxiliary instances of these contracts standalone and verify
172+
The workaround used during Holesky deployment is to deploy auxiliary instances of these contracts standalone and verify
173173
them via hardhat Etherscan plugin. After this Etherscan will mark the target contracts as verified by "Similar Match
174174
Source Code".
175175

176-
NB, that some contracts require additional auxiliary contract to be deployed. Namely, the constructor of
176+
Note that some contracts require additional auxiliary contracts to be deployed. Namely, the constructor of
177177
`AppProxyPinned` depends on proxy implementation ("base" in Aragon terms) contract with `initialize()` function and
178178
`Kernel` contract, which must return the implementation by call `kernel().getApp(KERNEL_APP_BASES_NAMESPACE, _appId)`.
179179
See `@aragon/os/contracts/apps/AppProxyBase.sol` for the details.
180180

181181
### Initialization to Fully Operational State
182182

183-
In order to make the protocol fully operational, the additional steps are required:
183+
In order to make the protocol fully operational, the following additional steps are required:
184184

185185
- add oracle committee members to `HashConsensus` contracts for `AccountingOracle` and `ValidatorsExitBusOracle`:
186186
`HashConsensus.addMember`;
@@ -194,7 +194,7 @@ In order to make the protocol fully operational, the additional steps are requir
194194
- set staking limits for the Node Operators: `NodeOperatorsRegistry.setNodeOperatorStakingLimit`.
195195

196196
> [!NOTE]
197-
> That part of the actions require prior granting of the required roles, e.g. `STAKING_MODULE_MANAGE_ROLE` for
197+
> Some of these actions require prior granting of the required roles, e.g. `STAKING_MODULE_MANAGE_ROLE` for
198198
> `StakingRouter.addStakingModule`:
199199
200200
```js
@@ -215,7 +215,7 @@ await stakingRouter.renounceRole(STAKING_MODULE_MANAGE_ROLE, agent.address, { fr
215215

216216
## Protocol Parameters
217217

218-
This section describes part of the parameters and their values used at the deployment. The values are specified in
218+
This section describes part of the parameters and their values used during deployment. The values are specified in
219219
`deployed-testnet-defaults.json`.
220220

221221
### OracleDaemonConfig
@@ -225,23 +225,23 @@ This section describes part of the parameters and their values used at the deplo
225225
# See https://research.lido.fi/t/withdrawals-for-lido-on-ethereum-bunker-mode-design-and-implementation/3890/4
226226
# and https://snapshot.org/#/lido-snapshot.eth/proposal/0xa4eb1220a15d46a1825d5a0f44de1b34644d4aa6bb95f910b86b29bb7654e330
227227
# NB: BASE_REWARD_FACTOR: https://ethereum.github.io/consensus-specs/specs/phase0/beacon-chain/#rewards-and-penalties
228-
NORMALIZED_CL_REWARD_PER_EPOCH=64
229-
NORMALIZED_CL_REWARD_MISTAKE_RATE_BP=1000 # 10%
230-
REBASE_CHECK_NEAREST_EPOCH_DISTANCE=1
231-
REBASE_CHECK_DISTANT_EPOCH_DISTANCE=23 # 10% of AO 225 epochs frame
232-
VALIDATOR_DELAYED_TIMEOUT_IN_SLOTS=7200 # 1 day
228+
NORMALIZED_CL_REWARD_PER_EPOCH = 64
229+
NORMALIZED_CL_REWARD_MISTAKE_RATE_BP = 1000 # 10%
230+
REBASE_CHECK_NEAREST_EPOCH_DISTANCE = 1
231+
REBASE_CHECK_DISTANT_EPOCH_DISTANCE = 23 # 10% of AO 225 epochs frame
232+
VALIDATOR_DELAYED_TIMEOUT_IN_SLOTS = 7200 # 1 day
233233

234234
# See https://snapshot.org/#/lido-snapshot.eth/proposal/0xa4eb1220a15d46a1825d5a0f44de1b34644d4aa6bb95f910b86b29bb7654e330 for "Requirement not be considered Delinquent"
235-
VALIDATOR_DELINQUENT_TIMEOUT_IN_SLOTS=28800 # 4 days
235+
VALIDATOR_DELINQUENT_TIMEOUT_IN_SLOTS = 28800 # 4 days
236236

237237
# See "B.3.I" of https://snapshot.org/#/lido-snapshot.eth/proposal/0xa4eb1220a15d46a1825d5a0f44de1b34644d4aa6bb95f910b86b29bb7654e330
238-
NODE_OPERATOR_NETWORK_PENETRATION_THRESHOLD_BP=100 # 1% network penetration for a single NO
238+
NODE_OPERATOR_NETWORK_PENETRATION_THRESHOLD_BP = 100 # 1% network penetration for a single NO
239239

240240
# Time period of historical observations used for prediction of the rewards amount
241241
# see https://research.lido.fi/t/withdrawals-for-lido-on-ethereum-bunker-mode-design-and-implementation/3890/4
242-
PREDICTION_DURATION_IN_SLOTS=50400 # 7 days
242+
PREDICTION_DURATION_IN_SLOTS = 50400 # 7 days
243243

244244
# Max period of delay for requests finalization in case of bunker due to negative rebase
245245
# twice min governance response time - 3 days voting duration
246-
FINALIZATION_MAX_NEGATIVE_REBASE_EPOCH_SHIFT=1350 # 6 days
246+
FINALIZATION_MAX_NEGATIVE_REBASE_EPOCH_SHIFT = 1350 # 6 days
247247
```

globals.d.ts

+10
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ declare namespace NodeJS {
7272
MAINNET_WITHDRAWAL_QUEUE_ADDRESS?: string;
7373
MAINNET_WITHDRAWAL_VAULT_ADDRESS?: string;
7474

75+
HOLESKY_RPC_URL?: string;
76+
SEPOLIA_RPC_URL?: string;
77+
7578
/* for contract sourcecode verification with `hardhat-verify` */
7679
ETHERSCAN_API_KEY?: string;
7780

@@ -80,5 +83,12 @@ declare namespace NodeJS {
8083
LOCAL_DEVNET_CHAIN_ID?: string;
8184
LOCAL_DEVNET_EXPLORER_API_URL?: string;
8285
LOCAL_DEVNET_EXPLORER_URL?: string;
86+
87+
/* scratch deploy environment variables */
88+
NETWORK_STATE_FILE?: string;
89+
90+
/* hardhat plugins options */
91+
SKIP_CONTRACT_SIZE?: boolean;
92+
SKIP_GAS_REPORT?: boolean;
8393
}
8494
}

hardhat.config.ts

+36-14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import "hardhat-tracer";
1111
import "hardhat-watcher";
1212
import "hardhat-ignore-warnings";
1313
import "hardhat-contract-sizer";
14+
import "hardhat-gas-reporter";
1415
import { HardhatUserConfig } from "hardhat/config";
1516

1617
import { mochaRootHooks } from "test/hooks";
@@ -25,18 +26,10 @@ export const ZERO_PK = "0x000000000000000000000000000000000000000000000000000000
2526

2627
const config: HardhatUserConfig = {
2728
defaultNetwork: "hardhat",
29+
gasReporter: {
30+
enabled: !process.env.SKIP_GAS_REPORT,
31+
},
2832
networks: {
29-
"local": {
30-
url: process.env.LOCAL_RPC_URL || RPC_URL,
31-
},
32-
"local-devnet": {
33-
url: process.env.LOCAL_RPC_URL || RPC_URL,
34-
accounts: [process.env.LOCAL_DEVNET_PK || ZERO_PK],
35-
},
36-
"mainnet-fork": {
37-
url: process.env.MAINNET_RPC_URL || RPC_URL,
38-
timeout: 20 * 60 * 1000, // 20 minutes
39-
},
4033
"hardhat": {
4134
// setting base fee to 0 to avoid extra calculations doesn't work :(
4235
// minimal base fee is 1 for EIP-1559
@@ -52,8 +45,24 @@ const config: HardhatUserConfig = {
5245
},
5346
forking: getHardhatForkingConfig(),
5447
},
48+
"local": {
49+
url: process.env.LOCAL_RPC_URL || RPC_URL,
50+
},
51+
"local-devnet": {
52+
url: process.env.LOCAL_RPC_URL || RPC_URL,
53+
accounts: [process.env.LOCAL_DEVNET_PK || ZERO_PK],
54+
},
55+
"mainnet-fork": {
56+
url: process.env.MAINNET_RPC_URL || RPC_URL,
57+
timeout: 20 * 60 * 1000, // 20 minutes
58+
},
59+
"holesky": {
60+
url: process.env.HOLESKY_RPC_URL || RPC_URL,
61+
chainId: 17000,
62+
accounts: loadAccounts("holesky"),
63+
},
5564
"sepolia": {
56-
url: RPC_URL,
65+
url: process.env.SEPOLIA_RPC_URL || RPC_URL,
5766
chainId: 11155111,
5867
accounts: loadAccounts("sepolia"),
5968
},
@@ -131,6 +140,16 @@ const config: HardhatUserConfig = {
131140
evmVersion: "istanbul",
132141
},
133142
},
143+
{
144+
version: "0.8.25",
145+
settings: {
146+
optimizer: {
147+
enabled: true,
148+
runs: 200,
149+
},
150+
evmVersion: "cancun",
151+
},
152+
},
134153
],
135154
},
136155
tracer: {
@@ -145,7 +164,10 @@ const config: HardhatUserConfig = {
145164
},
146165
watcher: {
147166
test: {
148-
tasks: [{ command: "test", params: { testFiles: ["{path}"] } }],
167+
tasks: [
168+
{ command: "compile", params: { quiet: true } },
169+
{ command: "test", params: { noCompile: true, testFiles: ["{path}"] } },
170+
],
149171
files: ["./test/**/*"],
150172
clearOnStart: true,
151173
start: "echo Running tests...",
@@ -172,7 +194,7 @@ const config: HardhatUserConfig = {
172194
contractSizer: {
173195
alphaSort: false,
174196
disambiguatePaths: false,
175-
runOnCompile: true,
197+
runOnCompile: process.env.SKIP_CONTRACT_SIZE ? false : true,
176198
strict: true,
177199
except: ["template", "mocks", "@aragon", "openzeppelin", "test"],
178200
},

0 commit comments

Comments
 (0)