Skip to content

Commit

Permalink
Merge pull request #214 from lidofinance/repovation
Browse files Browse the repository at this point in the history
chore: repovation update
  • Loading branch information
TheDZhon committed Sep 30, 2024
2 parents 9eb1257 + 25f9583 commit 9fb4503
Show file tree
Hide file tree
Showing 13 changed files with 1,157 additions and 891 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests-integration-mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

services:
hardhat-node:
image: feofanov/hardhat-node:2.22.9
image: ghcr.io/lidofinance/hardhat-node:2.22.12
ports:
- 8545:8545
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-integration-scratch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

services:
hardhat-node:
image: feofanov/hardhat-node:2.22.9-scratch
image: ghcr.io/lidofinance/hardhat-node:2.22.12-scratch
ports:
- 8555:8545

Expand Down
482 changes: 325 additions & 157 deletions CONTRIBUTING.md

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions contracts/COMPILERS.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# Why we use different compilers
# Compiler Versions Used in Lido Project

For Lido project coordination, governance and funds management we use [Aragon](https://aragon.org/dao), a well-developed and proven DAO Framework. The current stable release of its Kernel, [4.4.0](https://github.com/aragon/aragonOS/tree/v4.4.0) is fixed on the specific compiler version - [solc 0.4.24](https://solidity.readthedocs.io/en/v0.4.24/), that is currently outdated. Keeping security and consistency in mind, we decided to stay on an older yet proven combination - for all the contracts under Aragon management (`Lido`, `stETH`, `LegacyOracle`) we use solc 0.4.24 release.
For Lido project coordination, governance, and funds management, we use [Aragon](https://aragon.org/dao), a
well-developed and proven DAO Framework. The current stable release of its
Kernel, [4.4.0](https://github.com/aragon/aragonOS/tree/v4.4.0), is fixed on a specific compiler
version - [solc 0.4.24](https://solidity.readthedocs.io/en/v0.4.24/), which is currently outdated. Keeping security and
consistency in mind, we decided to stay on an older yet proven combination. Therefore, for all the contracts under
Aragon management (`Lido`, `stETH`, `LegacyOracle`), we use the `solc 0.4.24` release.

cstETH token, that acts as autonomous wrapper and not governed by Aragon, was inherited from OpenZeppelin's library, using one of its stable releases [3.1.0](https://github.com/OpenZeppelin/openzeppelin-contracts/releases/tag/v3.1.0).
For the `wstETH` contract, we use `solc 0.6.12`, as it is non-upgradeable and bound to this version.

# How to compile
For the other contracts, newer compiler versions are used.

Separately:

```bash
yarn compile:4
yarn compile:6
```

All at once:
# Compilation Instructions

```bash
yarn compile
Expand Down
20 changes: 20 additions & 0 deletions contracts/common/interfaces/IGateSealFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

// See contracts/COMPILERS.md
// solhint-disable-next-line
pragma solidity >=0.4.24 <0.9.0;

// https://github.com/lidofinance/gate-seals/blob/main/contracts/GateSealFactory.vy
interface IGateSealFactory {

event GateSealCreated(address gate_seal);

function create_gate_seal(
address _sealing_committee,
uint256 _seal_duration_seconds,
address[] memory _sealables,
uint256 _expiry_timestamp
) external;

}
146 changes: 74 additions & 72 deletions docs/scratch-deploy.md
Original file line number Diff line number Diff line change
@@ -1,124 +1,127 @@
# Deploy Lido protocol from scratch
# Deploy Lido protocol middleware from scratch

## Disclaimer: WIP!

This scratch deployment manual is partially outdated and is a subject of further refinement.

## TLDR: local deployment

Do
## TL;DR

```shell
# Start a local Ethereum node
anvil -p 8555 --base-fee 0 --gas-price 0
```

and

```shell
# In a separate terminal, run the deployment script
bash scripts/dao-local-deploy.sh
```

## Requirements

- same as for the rest of the repo
Same as for the rest of the repo, see [CONTRIBUTING.md](../CONTRIBUTING.md).

## General Information

The repository contains bash scripts for deploying the DAO across various environments:

## General info
- Local Node Deployment - `scripts/dao-local-deploy.sh` (Supports Ganache, Anvil, Hardhat Network, and other local
Ethereum nodes)
- Holešky Testnet Deployment – `scripts/dao-holesky-deploy.sh`

The repo contains bash scripts for deployment of the DAO under multiple environments:
The protocol requires configuration of numerous parameters for a scratch deployment. The default configurations are
stored in JSON files named `deployed-<deploy env>-defaults.json`, where `<deploy env>` represents the target
environment. Currently, a single default configuration file exists: `deployed-testnet-defaults.json`, which is tailored
for testnet deployments. This configuration differs from the mainnet setup, featuring shorter vote durations and more
frequent oracle report cycles, among other adjustments.

- local node (ganache, anvil, hardhat network) `scripts/dao-local-deploy.sh`
- holesky testnet - `scripts/dao-holesky-deploy.sh`
> [!NOTE]
> Some parameters in the default configuration file are intentionally set to `null`, indicating that they require
> further specification during the deployment process.
The protocol has a bunch of parameters to configure for the scratch deployment. The default configuration is stored in
files `deployed-<deploy env>-defaults.json`, where `<deploy env>` is the target environment. Currently, there is a
single default configuration, `deployed-testnet-defaults.json`, suitable for testnet deployments. Compared to the
mainnet configuration, it has lower vote durations, more frequent oracle report cycles, etc. Part of the parameters
require further specification -- they are marked with `null` values.
During the deployment, the "default" configuration is copied to `deployed-<network name>.json`, where `<network name>`
is the name of a network configuration defined in `hardhat.config.js`. The file `deployed-<network name>.json` gets
populated with the contract addresses and transaction hashes during the deployment process.
The deployment script performs the following steps regarding configuration:

These are the deployment setups, supported currently:
1. Copies the appropriate default configuration file (e.g., `deployed-testnet-defaults.json`) to a new file named
`deployed-<network name>.json`, where `<network name>` corresponds to a network configuration defined in
`hardhat.config.js`.

- local (basically any node at http://127.0.0.1:8545);
- Holešky testnet.
2. Populates the `deployed-<network name>.json` file with specific contract addresses and transaction hashes as the
deployment progresses.

Each is described in detail in the sections below.
Detailed information for each setup is provided in the sections below.

> NB: Aragon UI for Lido DAO is to be deprecated and replaced by a custom solution, thus not included in the deployment
> [!NOTE]
> Aragon UI for Lido DAO is to be deprecated and replaced by a custom solution, thus not included in the deployment
> script, see https://research.lido.fi/t/discontinuation-of-aragon-ui-use/7992.
### Deploy steps
### Deployment Steps

A brief description of what's going on under the hood in the deploy script.
A detailed overview of the deployment script's process:

- Prepare `deployed-<network name>.json` file
- It is copied from `deployed-testnet-defaults.json`
- and expended by env variables values, e. g. `DEPLOYER`.
- It gets filled with the deployed contracts info from step to step.
- (optional) Deploy DepositContract.
- The step is skipped if the DepositContract address is specified
- Copied from `deployed-testnet-defaults.json`
- Enhanced with environment variable values, e.g., `DEPLOYER`
- Progressively updated with deployed contract information
- (optional) Deploy DepositContract
- Skipped if DepositContract address is pre-specified
- (optional) Deploy ENS
- The step is skipped if the ENS Registry address is specified
- Skipped if ENS Registry address is pre-specified
- Deploy Aragon framework environment
- Deploy standard Aragon apps contracts (like `Agent`, `Voting`)
- Deploy standard Aragon apps contracts (e.g., `Agent`, `Voting`)
- Deploy `LidoTemplate` contract
- This is an auxiliary deploy contract which performs DAO configuration
- Deploy Lido custom Aragon apps implementations (aka bases), namely for `Lido`, `LegacyOracle`, `NodeOperatorsRegistry`
- Registry Lido APM name in ENS
- Auxiliary contract for DAO configuration
- Deploy Lido custom Aragon apps implementations (bases) for `Lido`, `LegacyOracle`, `NodeOperatorsRegistry`
- Register Lido APM name in ENS
- Deploy Aragon package manager contract `APMRegistry` (via `LidoTemplate`)
- Deploy Lido custom Aragon apps repo contracts (via `LidoTemplate`)
- Deploy Lido DAO (via `LidoTemplate`)
- Issue DAO tokens (via `LidoTemplate`)
- Deploy non-Aragon Lido contracts: `OracleDaemonConfig`, `LidoLocator`, `OracleReportSanityChecker`, `EIP712StETH`,
`WstETH`, `WithdrawalQueueERC721`, `WithdrawalVault`, `LidoExecutionLayerRewardsVault`, `StakingRouter`,
`DepositSecurityModule`, `AccountingOracle`, `HashConsensus` for AccountingOracle, `ValidatorsExitBusOracle`,
`HashConsensus` for ValidatorsExitBusOracle, `Burner`.
- Finalize Lido DAO deployment: issue unvested LDO tokens, set Aragon permissions, register Lido DAO name in Aragon ID (
via `LidoTemplate`)
`HashConsensus` for ValidatorsExitBusOracle, `Burner`
- Finalize Lido DAO deployment: issue unvested LDO tokens, set Aragon permissions, register Lido DAO name in Aragon ID
(via `LidoTemplate`)
- Initialize non-Aragon Lido contracts
- Set parameters of `OracleDaemonConfig`
- Setup non-Aragon permissions
- Plug NodeOperatorsRegistry as Curated staking module
- Transfer all admin roles from deployer to `Agent`
- OZ admin roles: `Burner`, `HashConsensus` for `AccountingOracle`, `HashConsensus` for `ValidatorsExitBusOracle`,
- OpenZeppelin admin roles: `Burner`, `HashConsensus` for `AccountingOracle`, `HashConsensus` for
`ValidatorsExitBusOracle`,
`StakingRouter`, `AccountingOracle`, `ValidatorsExitBusOracle`, `WithdrawalQueueERC721`, `OracleDaemonConfig`
- OssifiableProxy admins: : `LidoLocator`, `StakingRouter`, `AccountingOracle`, `ValidatorsExitBusOracle`,
- OssifiableProxy admin roles: `LidoLocator`, `StakingRouter`, `AccountingOracle`, `ValidatorsExitBusOracle`,
`WithdrawalQueueERC721`
- `DepositSecurityModule` owner

## Local deployment
## Deployment Environments

Deploys the DAO to local (http://127.0.0.1:8555) dev node (anvil, hardhat, ganache).
The deployment is done from the default test account `0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266` derived from the
default mnemonic.
Thus the node must be configured with the default test accounts derived from the mnemonic
`test test test test test test test test test test test junk`.
### Local Deployment

This section describes how to deploy the DAO to a local development node (such as Anvil, Hardhat, or Ganache) running
at http://127.0.0.1:8555.

The deployment process utilizes the default test account `0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266`, which is derived
from the standard mnemonic phrase: `test test test test test test test test test test test junk`

To ensure a successful deployment, configure your local node with the default test accounts associated with this
mnemonic.

Follow these steps for local deployment:

1. Run `yarn install` (get sure repo dependencies are installed)
2. Run the node on port 8555 (for the commands, see subsections below)
3. Run the deploy script `bash scripts/dao-local-deploy.sh` from root repo directory
4. Check out the deploy artifacts in `deployed-local.json`

### Anvil
#### Supported Local Nodes

Run the node with the command:
##### Anvil

```shell
anvil -p 8555 --mnemonic "test test test test test test test test test test test junk"
anvil -p 8555 --mnemonic "test test test test test test test test test test test junk" --base-fee 0 --gas-price 0
```

### Hardhat node

> NB: Hardhat node configuration is set in `hardhat.config.js` under `hardhat: { `.
To run hardhat node execute:
##### Hardhat Node

```shell
yarn hardhat node
```

## Holešky deployment
### Holešky Testnet Deployment

To do Holešky deployment, the following parameters must be set up via env variables:

Expand Down Expand Up @@ -146,15 +149,15 @@ bash scripts/scratch/dao-holesky-deploy.sh

Deploy artifacts information will be stored in `deployed-holesky.json`.

## Publishing sources to Etherscan
## Post-Deployment Tasks

After the deployment run
### Publishing Sources to Etherscan

```shell
NETWORK=<PUT-YOUR-VALUE> RPC_URL=<PUT-YOUR-VALUE> bash ./scripts/scratch/verify-contracts-code.sh
NETWORK=<PUT-YOUR-VALUE> RPC_URL=<PUT-YOUR-VALUE> bash ./scripts/verify-contracts-code.sh
```

### Issues with verification of part of the contracts deployed from factories
#### Issues with verification of part of the contracts deployed from factories

There are some contracts deployed from other contracts for which automatic hardhat etherscan verification fails:

Expand All @@ -175,9 +178,7 @@ NB, that some contracts require additional auxiliary contract to be deployed. Na
`Kernel` contract, which must return the implementation by call `kernel().getApp(KERNEL_APP_BASES_NAMESPACE, _appId)`.
See `@aragon/os/contracts/apps/AppProxyBase.sol` for the details.

## Post deploy initialization

### Initialization up to the fully operational state
### Initialization to Fully Operational State

In order to make the protocol fully operational, the additional steps are required:

Expand All @@ -192,8 +193,9 @@ In order to make the protocol fully operational, the additional steps are requir
- add validator keys to the Node Operators: `NodeOperatorsRegistry.addSigningKeys`;
- set staking limits for the Node Operators: `NodeOperatorsRegistry.setNodeOperatorStakingLimit`.

NB, that part of the actions require prior granting of the required roles, e.g. `STAKING_MODULE_MANAGE_ROLE` for
`StakingRouter.addStakingModule`:
> [!NOTE]
> That part of the actions require prior granting of the required roles, e.g. `STAKING_MODULE_MANAGE_ROLE` for
> `StakingRouter.addStakingModule`:
```js
await stakingRouter.grantRole(STAKING_MODULE_MANAGE_ROLE, agent.address, { from: agent.address });
Expand All @@ -208,7 +210,7 @@ await stakingRouter.addStakingModule(
await stakingRouter.renounceRole(STAKING_MODULE_MANAGE_ROLE, agent.address, { from: agent.address });
```

## Protocol parameters
## Protocol Parameters

This section describes part of the parameters and their values used at the deployment. The values are specified in
`deployed-testnet-defaults.json`.
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"engines": {
"node": ">=20"
},
"packageManager": "yarn@4.4.1",
"packageManager": "yarn@4.5.0",
"scripts": {
"compile": "hardhat compile",
"lint:sol": "solhint 'contracts/**/*.sol'",
Expand Down Expand Up @@ -46,30 +46,30 @@
]
},
"devDependencies": {
"@commitlint/cli": "^19.4.1",
"@commitlint/config-conventional": "^19.4.1",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/compat": "^1.1.1",
"@eslint/js": "^9.9.1",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.7",
"@eslint/js": "^9.11.1",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.8",
"@nomicfoundation/hardhat-ethers": "^3.0.8",
"@nomicfoundation/hardhat-ignition": "^0.15.5",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.5",
"@nomicfoundation/hardhat-network-helpers": "^1.0.11",
"@nomicfoundation/hardhat-network-helpers": "^1.0.12",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.10",
"@nomicfoundation/hardhat-verify": "^2.0.11",
"@nomicfoundation/ignition-core": "^0.15.5",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.3.19",
"@types/eslint": "^9.6.1",
"@types/eslint__js": "^8.42.3",
"@types/mocha": "10.0.7",
"@types/node": "20.16.3",
"@types/mocha": "10.0.8",
"@types/node": "20.16.6",
"bigint-conversion": "^2.4.3",
"chai": "^4.5.0",
"chalk": "^4.1.2",
"dotenv": "^16.4.5",
"eslint": "^9.9.1",
"eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-no-only-tests": "^3.3.0",
"eslint-plugin-prettier": "^5.2.1",
Expand All @@ -78,13 +78,13 @@
"ethers": "^6.13.2",
"glob": "^11.0.0",
"globals": "^15.9.0",
"hardhat": "^2.22.9",
"hardhat": "^2.22.12",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-gas-reporter": "^1.0.10",
"hardhat-ignore-warnings": "^0.2.11",
"hardhat-tracer": "3.1.0",
"hardhat-watcher": "2.5.0",
"husky": "^9.1.5",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.4.1",
Expand All @@ -94,8 +94,8 @@
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typechain": "^8.3.2",
"typescript": "^5.5.4",
"typescript-eslint": "^8.3.0"
"typescript": "^5.6.2",
"typescript-eslint": "^8.7.0"
},
"dependencies": {
"@aragon/apps-agent": "2.1.0",
Expand Down
Loading

0 comments on commit 9fb4503

Please sign in to comment.