Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: a bunch of generator fixes #1

Merged
merged 18 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: PR Comment

on:
workflow_run:
workflows: [Test]
types:
- completed

jobs:
test:
uses: bgd-labs/github-workflows/.github/workflows/comment.yml@main
secrets: inherit
57 changes: 57 additions & 0 deletions .github/workflows/ipfs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Ipfs uploader
# Uploads all changed md files to ipfs once merged to main
# Comments the pr

concurrency:
group: ${{ github.workflow }}
# cancel-in-progress: true

on:
pull_request:
push:
branches:
- main

jobs:
ipfs-upload:
runs-on: ubuntu-latest
name: Ipfs uploader
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
cache: "yarn"

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Get all changed *.md file(s)
id: changed-files
uses: tj-actions/changed-files@f569b77fb1d9ad9f1a125757d7e9e07b1f320199
with:
json: true
write_output_files: true
files: |
src/**/*.md

- name: Run step if any *.md file(s) change
if: steps.changed-files.outputs.any_changed == 'true'
run: |
cat .github/outputs/all_changed_files.json

- name: Upload
if: steps.changed-files.outputs.any_changed == 'true'
env:
PINATA_KEY: ${{ secrets.PINATA_KEY }}
PINATA_SECRET: ${{ secrets.PINATA_SECRET }}
run: |
json_array=($(jq -r '.[]' ".github/outputs/all_changed_files.json"))
for i in "${json_array[@]}"
do
npx aave-cli ipfs $i -u ${{ github.event_name != 'pull_request'}}
done
12 changes: 0 additions & 12 deletions .github/workflows/main.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .github/workflows/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## AIP checklist

- [ ] payload contains header comment linking discussion & snapshot
- [ ] a test covering the changes is included
- [ ] scripts are included
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
pull_request:
push:
branches:
- main

jobs:
test:
uses: bgd-labs/github-workflows/.github/workflows/foundry-test.yml@main
secrets: inherit
with:
mode: "CHANGED"
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/aave-helpers"]
path = lib/aave-helpers
url = https://github.com/bgd-labs/aave-helpers
97 changes: 72 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
# BGD forge template
# Aave proposals v3

Basic template with prettier and rest configuration
This repository contains various proposals targeting the Aave governance.
In addition to the actual proposals this repository also contains tooling to standardize certain protocol tasks.
The tooling documentation is co-located with the relevant smart contracts.

To create a new project using this template run
## Tooling

```shell
$ forge init --template bgd-labs/bgd-forge-template my_new_project
```

## Recommended modules

[bgd-labs/solidity-utils](https://github.com/bgd-labs/solidity-utils) - common contracts we use everywhere, ie transparent proxy and around

[bgd-labs/aave-address-book](https://github.com/bgd-labs/aave-address-book) - the best and only source about all deployed Aave ecosystem related contracts across all the chains

[bgd-labs/aave-helpers](https://github.com/bgd-labs/aave-helpers) - useful utils for integration, and not only testing related to Aave ecosystem contracts
### Config engine

[Rari-Capital/solmate](https://github.com/Rari-Capital/solmate) - one of the best sources of base contracts for ERC20, ERC21, which will work with transparent proxy pattern out of the box
The AaveV3ConfigEngine ([Docs](https://github.com/bgd-labs/aave-helpers/tree/master/src/v3-config-engine#how-to-use-the-engine)) is a helper smart contract to abstract good practices when doing "admin" interactions with the Aave v3 protocol, but built on top, without touching the core contracts.

[OpenZeppelin/openzeppelin-contracts](https://github.com/OpenZeppelin/openzeppelin-contracts) - another very reputable and well organized source of base contracts for tokens, access control and many others
A less comprehensive version of the engine also exists for [protocol v2](https://github.com/bgd-labs/aave-helpers/tree/master/src/v2-config-engine).

## Development

Expand All @@ -30,27 +22,82 @@ The template ships with sensible default so you can use default `foundry` comman
```sh
cp .env.example .env
forge install
yarn
```

### Create an aip

This repository includes a generator to help you bootstrap the required files for an `AIP`.
To generate a proposal you need to run: `yarn generate`

To get a full list of available commands run `yarn generate --help`

```sh
yarn generate --help
yarn run v1.22.19
$ tsx generator/cli --help
Usage: proposal-generator [options]

CLI to generate aave proposals

Options:
-V, --version output the version number
-f, --force force creation (might overwrite existing files)
-p, --pools <pools...> (choices: "AaveV2Ethereum", "AaveV2EthereumAMM", "AaveV2Polygon", "AaveV2Avalanche",
"AaveV3Ethereum", "AaveV3Polygon", "AaveV3Avalanche", "AaveV3Optimism",
"AaveV3Arbitrum", "AaveV3Metis", "AaveV3Base")
-t, --title <string> aip title
-a, --author <string> author
-d, --discussion <string> forum link
-s, --snapshot <string> snapshot link
-c, --configFile <string> path to config file
-h, --help display help for command
```

If you have any feedback regarding the generator (bugs, improvements, features), don't hesitate to create an issue. We'd `<3` to see contributions.

### Test

```sh
# You can use vanilla forge to customize your test
# https://book.getfoundry.sh/reference/forge/forge-test
forge test
# We also provide a script with sensible defaults to just test a single contract matching a filter
make test-contract filter=ENS
```

## Advanced features
### Deploy

The makefile contains some generic templates for proposal deployments.
To deploy a contract you can run `make deploy-ledger contract=pathToContract:Contract chain=chainAlias`.
The generator will inline exact instructions on the generated scripts.

## Proposal creation

To create a proposal you have to do three things:

1. deploy the payload & register it on the payloadsController
2. create an aip
3. create the mainnet proposal

While the first two steps can be performed in parallel, the final proposal creation relies on (1) and (2).
Every step can in theory be performed by a different entity.

The address creating the mainnet proposal(3) requires 80k AAVE of proposition power.

### Diffing
### 1. Deploy payload

For contracts upgrading implementations it's quite important to diff the implementation code to spot potential issues and ensure only the intended changes are included.
Therefore the `Makefile` includes some commands to streamline the diffing process.
The payload is always deployed on the chain it affects.
Therefore you need to adjust the relevant script accordingly.
The generated scripts include exact instrauctions on what to execute.

#### Download
### 2. Create an aip

You can `download` the current contract code of a deployed contract via `make download chain=polygon address=0x00`. This will download the contract source for specified address to `src/etherscan/chain_address`. This command works for all chains with a etherscan compatible block explorer.
The aip can be co-located with the proposal code as a markdown file.
This repository will manage the upload to ipfs automatically once a pr is merged to `main`.

#### Git diff
### 3. Create proposal

You can `git-diff` a downloaded contract against your src via `make git-diff before=./etherscan/chain_address after=./src out=filename`. This command will diff the two folders via git patience algorithm and write the output to `diffs/filename.md`.
The proposal requires at least one `payload` and the `encodedHash`.

**Caveat**: If the onchain implementation was verified using flatten, for generating the diff you need to flatten the new contract via `forge flatten` and supply the flattened file instead fo the whole `./src` folder.
:tada:
5 changes: 0 additions & 5 deletions deploy.sh

This file was deleted.

Loading