Skip to content

Commit

Permalink
Merge pull request #368 from lidofinance/aragon-dev
Browse files Browse the repository at this point in the history
Aragon Frontops and fix scratch deploy
  • Loading branch information
arwer13 authored Jan 29, 2022
2 parents b7cc8a2 + e7fce46 commit 3e41635
Show file tree
Hide file tree
Showing 193 changed files with 11,699 additions and 4,855 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- name: Cache yarn cache
id: cache-yarn-cache
Expand All @@ -42,8 +42,8 @@ jobs:
steps.cache-node-modules.outputs.cache-hit != 'true'
- name: Run Solidity tests
run: yarn test:unit
run: yarn test:unit

- name: Run Solidity linters
run: yarn lint:sol:solhint

Expand All @@ -62,7 +62,7 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand Down
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ tmp/
/coverage.json
.coverage_*/

/aragon-apps
aragon-apps/
aragon-client/
cli/vendor

**/data/
*.log

# Yarn stuff
.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions

.pnp.*

# Optional npm cache directory
Expand Down
55 changes: 55 additions & 0 deletions .yarn/releases/yarn-2.4.3.cjs

Large diffs are not rendered by default.

55 changes: 0 additions & 55 deletions .yarn/releases/yarn-berry.cjs

This file was deleted.

5 changes: 3 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
yarnPath: ".yarn/releases/yarn-berry.cjs"
nodeLinker: "node-modules"
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-2.4.3.cjs
127 changes: 4 additions & 123 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,133 +241,14 @@ so full branch coverage will never be reported until

## Deploying

Networks are defined in `buidler.config.js` file. To select the target network for deployment,
set `NETWORK_NAME` environment variable to a network name defined in that file. All examples
below assume `localhost` target network.

#### Network state file

Deployment scripts read their config from and store their results to a file called `deployed.json`,
located in the repo root. This file has the following structure and should always be committed:

```js
{
"networks": {
"1337": { // network id
"networkName": "devnet", // serves as a comment
// ...deployment results
}
}
}
```

When a script sees that some contract address is already defined in the network state file, it won't
re-deploy the same contract. This means that all deployment scripts are idempotent, you can call the
same script twice and the second call will be a nop.

You may want to specify some of the configuration options in `networks.<netId>` prior to running
deployment to avoid those values being set to default values:

* `owner` The address that everything will be deployed from.
* `ensAddress` The address of a ENS instance.
* `depositContractAddress` The address of the Beacon chain deposit contract (it will deployed otherwise).
* `daoInitialSettings` Initial settings of the DAO; see below.

You may specify any number additional keys inside any network state, they will be left intact by
deployment scripts.

#### DAO initial settings

Initial DAO settings can be specified pripr to deployment for the specific network in
`networks.<netId>.daoInitialSettings` field inside `deployed.json` file.

* `holders` Addresses of initial DAO token holders.
* `stakes` Initial DAO token balances of the holders.
* `tokenName` Name of the DAO token.
* `tokenSymbol` Symbol of the DAO token.
* `voteDuration` See [Voting app documentation].
* `votingSupportRequired` See [Voting app documentation].
* `votingMinAcceptanceQuorum` See [Voting app documentation].
* `depositIterationLimit` See [protocol levers documentation].

[Voting app documentation]: https://wiki.aragon.org/archive/dev/apps/voting
[protocol levers documentation]: /protocol-levers.md

An example of `deployed.json` file prepared for a testnet deployment:

```js
{
"networks": {
"5": {
"networkName": "goerli",
"depositContractAddress": "0x07b39f4fde4a38bace212b546dac87c58dfe3fdc",
"owner": "0x3463dD800410965fdBeC2958085b1467CBd4aA31",
"daoInitialSettings": {
"holders": [
"0x9be0D8ef365A7217c2313c3f33a71D5CeBea2686",
"0x7B1F4c068b3E89Cc586c2f3656Bd95f56CA5B10A",
"0x6244D856606c874DEAC61a61bd07698d47a6F6F2"
],
"stakes": [
"100000000000000000000",
"100000000000000000000",
"100000000000000000000"
],
"tokenName": "Lido DAO Testnet Token",
"tokenSymbol": "LDO",
"voteDuration": 86400,
"votingSupportRequired": "500000000000000000",
"votingMinAcceptanceQuorum": "300000000000000000",
"beaconSpec": {
"epochsPerFrame": 225,
"slotsPerEpoch": 32,
"secondsPerSlot": 12,
"genesisTime": 1605700807
}
}
}
}
}
```

#### Step 1: сompile the code

```bash
yarn compile
```

#### Step 2: deploy Aragon environment and core apps (optional)

This is required for test/dev networks that don't have Aragon environment deployed.

```bash
# ENS, APMRegistryFactory, DAOFactory, APMRegistry for aragonpm.eth, etc.
NETWORK_NAME=localhost yarn deploy:aragon-env
We have several ways to deploy lido smartcontracts and run DAO localy, you can find documents here:

# Core Aragon apps: voting, vault, etc.
NETWORK_NAME=localhost yarn deploy:aragon-std-apps
```

#### Step 3: deploy Lido APM registry and DAO template

```bash
NETWORK_NAME=localhost yarn deploy:apm-and-template
```
`lido-aragon` [documentation](/docs/lido-aragon.md)

#### Step 4: build and deploy Lido applications
For local development, please see [local documentation](/docs/dev-local.md)

```bash
NETWORK_NAME=localhost yarn deploy:apps
```

#### Step 5: deploy the DAO

```bash
NETWORK_NAME=localhost yarn deploy:dao
```
To develop/test on fork, please see [fork documentation](/docs/dev-fork.md)

This step deploys `DepositContract` as well, if `depositContractAddress` is not specified
in `deployed.json`.

# License

Expand Down
68 changes: 68 additions & 0 deletions SCRATH_DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Deploy Lido protocol from scratch

Video guide: [youtube](https://www.youtube.com/watch?v=dCMXcfglJv0)

## Requirements

* shell - bash or zsh
* docker
* node.js v14
* yarn

## Environment

You will need at least:

* Ethereum node
* IPFS node
* Aragon web client

In case of local deploy this environment is set up with docker.

> Note: Lido protocol is based on Aragon framework, so the entire Aragon framework environment is required for deployment.
## DAO configuration

Dao config is stored in `deployed-{NETWORK_NAME}.json` file, where `{NETWORK_NAME}` is network name of your choice.See the [`deployed-local-defaults.json`](deployed-local-defaults.json) for basic parameters. Please refer to [`deployed-mainnet.json`](deployed-mainnet.json) for currently deployed Mainnet version of DAO.

Copy `deployed-local-defaults.json` to `deployed-{NETWORK_NAME}.json` (e.g. `deployed-kintsugi.json`) and update it accordingly .

## Network configuration

Add to [`hardhat.config.js`](hardhat.config.js) your network connection parameter (inside the `getNetConfig` function, use `mainnet` or `local` as reference).

## Deploy process

> Note: all deploy process is depend of ENS contract. If the target network has one, you can use it. In this case, write it directly to the `deployed-{NETWORK_NAME}.json` file. Otherwise, own ENS contract will be deployed.
> Note: ETH2 Deposit contract is required. If the target network has one, you must use it. In this case, write it directly to the `deployed-{NETWORK_NAME}.json` file. Otherwise, own Deposit contract will be deployed.
Steps for deploy:

* [ ] run environment docker containers
* [ ] set up network config
* [ ] prepare DAO config file
* [ ] deploy Aragon framework environment (including ENS)
* [ ] build and deploy standard Aragon apps (contracts and frontend files)
* [ ] deploy Deposit contract (if necessary)
* [ ] deploy Lido DAO template contract
* [ ] deploy Lido Apps contract implementations
* [ ] register Lido APM name in ENS
* [ ] build Lido Apps frontend files and upload it to IPFS
* [ ] deploy Lido APM contract (via Lido Template)
* [ ] deploy Lido Apps repo contracts (via Lido Template)
* [ ] deploy Lido DAO contract (via Lido Template)
* [ ] issue DAO tokens (via Lido Template)
* [ ] finalize DAO setup (via Lido Template)
* [ ] make final deployed DAO check via script
* [ ] open and check Lido DAO web interface (via Aragon client)

All steps are automated via shell script [`dao-local-deploy.sh`](dao-local-deploy.sh) for local deploy process. The script be modified for any other network:

So, one-click local deploy from scratch command is:

```bash
./dao-local-deploy.sh
```

> Note: some steps require manually updating some transaction hashes in the `deployed-{NETWORK_NAME}.json` file. The script will pause the process in this case, please follow the script tips.
10 changes: 10 additions & 0 deletions accounts.sample.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"eth": {
"localhost": {
"mnemonic": "test test test test test test test test test test test junk",
"path": "m/44'/60'/0'/0",
"initialIndex": 0,
"count": 20
},
"dev": {
"mnemonic": "rich dune dash tag exercise veteran sword speed spike absorb disease brush bracket doll noodle",
"path": "m/44'/60'/0'/0",
Expand All @@ -18,5 +24,9 @@
},
"etherscan": {
"apiKey": "ETHERSCAN_API_KEY"
},
"infura_ipfs": {
"projectId": "",
"projectSecret": ""
}
}
3 changes: 2 additions & 1 deletion apps/lido/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"watch": "yarn watch:script",
"sync-assets": "copy-aragon-ui-assets ../dist && copyfiles -u 1 './public/**/*' ../dist",
"start": "yarn sync-assets && yarn watch:script & yarn serve",
"dev": "yarn sync-assets && yarn watch:script & yarn serve -- --port 3010"
"dev": "yarn sync-assets && yarn watch:script & yarn serve -- --port 3010",
"dev-fallback": "bash -c 'yarn sync-assets && yarn watch:script & yarn serve --port 3010'"
}
}
11 changes: 0 additions & 11 deletions apps/lido/app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,6 @@ export default function App() {
{isSyncing && <SyncIndicator />}
<Header
primary={appName.toUpperCase()}
secondary={
<Button
mode="strong"
onClick={openDbePanel}
css={`
background: ${theme.negative};
`}
>
DEPOSIT BUFFERED ETHER
</Button>
}
/>
<Split
primary={
Expand Down
11 changes: 11 additions & 0 deletions apps/lido/arapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
"name": "Set insurance fund address",
"id": "SET_INSURANCE_FUND",
"params": []
},
{
"name": "Deposit role",
"id": "DEPOSIT_ROLE",
"params": []
}
],
"environments": {
Expand All @@ -55,7 +60,13 @@
"mainnet": {
"appName": "lido.lidopm.eth",
"network": "mainnet"
},
"localhost": {
"appName": "lido.lidopm.eth",
"network": "development",
"registry": "0xa16E02E87b7454126E5E10d957A927A7F5B5d2be"
}
},
"appName": "lido.lidopm.eth",
"path": "../../contracts/0.4.24/Lido.sol"
}
4 changes: 2 additions & 2 deletions apps/lido/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module.exports = {
...baseConfig.aragon,
appServePort: 3010,
clientServePort: 3000,
appSrcPath: 'app/',
appBuildOutputPath: 'dist/',
appSrcPath: 'apps/lido/app/',
appBuildOutputPath: 'apps/lido/dist/',
appName: 'lido',
hooks // Path to script hooks
}
Expand Down
3 changes: 2 additions & 1 deletion apps/lidooracle/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"watch": "yarn watch:script",
"sync-assets": "copy-aragon-ui-assets ../dist && copyfiles -u 1 './public/**/*' ../dist",
"start": "yarn sync-assets && yarn watch:script & yarn serve",
"dev": "yarn sync-assets && yarn watch:script & yarn serve -- --port 3011"
"dev": "yarn sync-assets && yarn watch:script & yarn serve -- --port 3011",
"dev-fallback": "bash -c 'yarn sync-assets && yarn watch:script & yarn serve --port 3011'"
}
}
6 changes: 6 additions & 0 deletions apps/lidooracle/arapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
"mainnet": {
"appName": "oracle.lidopm.eth",
"network": "mainnet"
},
"localhost": {
"appName": "oracle.lidopm.eth",
"network": "development",
"registry": "0xa16E02E87b7454126E5E10d957A927A7F5B5d2be"
}
},
"appName": "oracle.lidopm.eth",
"path": "../../contracts/0.4.24/oracle/LidoOracle.sol"
}
4 changes: 2 additions & 2 deletions apps/lidooracle/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module.exports = {
...baseConfig.aragon,
appServePort: 3011,
clientServePort: 3000,
appSrcPath: 'app/',
appBuildOutputPath: 'dist/',
appSrcPath: 'apps/lidooracle/app/',
appBuildOutputPath: 'apps/lidooracle/dist/',
appName: 'lidooracle',
hooks // Path to script hooks
}
Expand Down
3 changes: 2 additions & 1 deletion apps/node-operators-registry/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"watch": "yarn watch:script",
"sync-assets": "copy-aragon-ui-assets ../dist && copyfiles -u 1 './public/**/*' ../dist",
"start": "yarn sync-assets && yarn watch:script & yarn serve",
"dev": "yarn sync-assets && yarn watch:script & yarn serve -- --port 3010"
"dev": "yarn sync-assets && yarn watch:script & yarn serve -- --port 3012",
"dev-fallback": "bash -c 'yarn sync-assets && yarn watch:script & yarn serve --port 3012'"
}
}
Loading

0 comments on commit 3e41635

Please sign in to comment.