Skip to content

Commit

Permalink
Merge branch 'master' into squashed-rebased-scp
Browse files Browse the repository at this point in the history
* master: (269 commits)
  Do new aave linear deploy (#2055)
  Deploy entrypoint (#2062)
  (Re) deployment preparation: `AuthorizerAdaptorEntrypoint` (#2060)
  chore: update deployment readmes to point to artifact files rather than abis (#2061)
  Expose deployment artifacts from deployments package rather than ABI + bytecode (#2058)
  chore: add missing action-ids (#2025)
  Remove Protocol Fee Splitter task (#2054)
  Adaptor entrypoint events (#2051)
  Verify AaveLinearPool on deployment (#2040)
  Rename IPoolVersion --> IFactoryCreatedPoolVersion. (#2045)
  docs: remove deprecated networks from jsdoc (#2029)
  Add Version unit test. (#2038)
  Update linear build info (#2041)
  Make unnecessarily async functions sync (#2030)
  Do deployment (#2035)
  Aave linear pool versioning (#2032)
  Fix recovery readme (#2037)
  style: fix linter (#2036)
  Add tokens task (#2024)
  Create recovery helper deployment (#2033)
  ...
  • Loading branch information
TomAFrench committed Nov 25, 2022
2 parents 8239faf + d168f36 commit 67d3f1a
Show file tree
Hide file tree
Showing 946 changed files with 57,742 additions and 433,722 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,16 @@ jobs:
- name: Benchmark Merkle Claim
run: yarn workspace @balancer-labs/v2-benchmarks measure-merkle-claim

relayer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Benchmark Balancer Relayer - multicall
run: yarn workspace @balancer-labs/v2-benchmarks measure-relayer

env:
CI: true
94 changes: 78 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: CI

env:
CI: true
FOUNDRY_PROFILE: 'intense'

on:
push:
branches:
Expand Down Expand Up @@ -30,111 +34,172 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Test
run: yarn workspace @balancer-labs/v2-solidity-utils test
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge tests
run: yarn workspace @balancer-labs/v2-solidity-utils test-fuzz

test-standalone-utils:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Test
run: yarn workspace @balancer-labs/v2-standalone-utils test
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge tests
run: yarn workspace @balancer-labs/v2-standalone-utils test-fuzz

test-vault:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Test
run: yarn workspace @balancer-labs/v2-vault test
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge tests
run: yarn workspace @balancer-labs/v2-vault test-fuzz

test-pool-utils:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Test
run: yarn workspace @balancer-labs/v2-pool-utils test
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge tests
run: yarn workspace @balancer-labs/v2-pool-utils test-fuzz

test-pool-weighted:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Test
run: yarn workspace @balancer-labs/v2-pool-weighted test
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge tests
run: yarn workspace @balancer-labs/v2-pool-weighted test-fuzz

test-pool-stable:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Test
run: yarn workspace @balancer-labs/v2-pool-stable test
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge tests
run: yarn workspace @balancer-labs/v2-pool-stable test-fuzz

test-pool-linear:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Test
run: yarn workspace @balancer-labs/v2-pool-linear test

test-asset-managers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Test
run: yarn workspaces foreach --verbose --include @balancer-labs/v2-asset-manager-* run test
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge tests
run: yarn workspace @balancer-labs/v2-pool-linear test-fuzz

test-distributors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Test
run: yarn workspace @balancer-labs/v2-distributors test
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge tests
run: yarn workspace @balancer-labs/v2-distributors test-fuzz

test-liquidity-mining:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Compile
run: yarn build
- name: Test
run: yarn workspace @balancer-labs/v2-liquidity-mining test
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge tests
run: yarn workspace @balancer-labs/v2-liquidity-mining test-fuzz

test-governance-scripts:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -166,8 +231,8 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
- name: Build Balancer JS
run: yarn workspace @balancer-labs/balancer-js build
- name: Build v2-distributors
run: yarn workspace @balancer-labs/v2-distributors build
- name: Compile
run: yarn build # Ideally we wouldn't depend on the packages of other artifacts, but we use some of their mocks
- name: Forked Network Cache
# Hardhat caches node requests when working with forked networks (e.g. when querying contract code, storage,
# etc.) to save time in future runs. We cache this directory accross runs.
Expand All @@ -194,6 +259,3 @@ jobs:
OPTIMISM_RPC_ENDPOINT: ${{ secrets.ALCHEMY_OPTIMISM_ARCHIVE_ENDPOINT }}
- name: Test
run: yarn workspace @balancer-labs/v2-deployments test

env:
CI: true
4 changes: 4 additions & 0 deletions .github/workflows/deployment-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
POLYGON_RPC_ENDPOINT: ${{ secrets.POLYGON_INFURA_ENDPOINT }}
ARBITRUM_RPC_ENDPOINT: ${{ secrets.ARBITRUM_INFURA_ENDPOINT }}
OPTIMISM_RPC_ENDPOINT: ${{ secrets.OPTIMISM_INFURA_ENDPOINT }}
BINANCE_RPC_ENDPOINT: ${{ secrets.BINANCE_INFURA_ENDPOINT }}
GNOSIS_RPC_ENDPOINT: ${{ secrets.GNOSIS_INFURA_ENDPOINT }}
GOERLI_RPC_ENDPOINT: ${{ secrets.GOERLI_INFURA_ENDPOINT }}
- name: Check Deployment Addresses
run: yarn workspace @balancer-labs/v2-deployments check-deployments
Expand All @@ -55,6 +57,8 @@ jobs:
POLYGON_RPC_ENDPOINT: ${{ secrets.POLYGON_INFURA_ENDPOINT }}
ARBITRUM_RPC_ENDPOINT: ${{ secrets.ARBITRUM_INFURA_ENDPOINT }}
OPTIMISM_RPC_ENDPOINT: ${{ secrets.OPTIMISM_INFURA_ENDPOINT }}
BINANCE_RPC_ENDPOINT: ${{ secrets.BINANCE_INFURA_ENDPOINT }}
GNOSIS_RPC_ENDPOINT: ${{ secrets.GNOSIS_INFURA_ENDPOINT }}
GOERLI_RPC_ENDPOINT: ${{ secrets.GOERLI_INFURA_ENDPOINT }}
- name: Check Action IDs
run: yarn workspace @balancer-labs/v2-deployments check-action-ids
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ cache/
dist/
pkg/balancer-js/src/typechain/*

# Forge
forge-artifacts/
forge-cache/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "pvt/lib/forge-std"]
path = pvt/lib/forge-std
url = https://github.com/foundry-rs/forge-std
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ Active development occurs in this repository, which means some contracts in it m
- [`v2-liquidity-mining`](./pkg/liquidity-mining): contracts that compose the liquidity mining (veBAL) system.
- [`v2-governance-scripts`](./pkg/governance-scripts): contracts that execute complex governance actions.

## Pre-requisites

The build & test instructions below should work out of the box with Node ^14.18.0. (Please note that it needs Node 14 specifically, and will NOT work with Node 16 or higher. Minor version should be at least 18).

## Clone

This repository uses git submodules; use `--recurse-submodules` option when cloning. For example, using https:

```bash
$ git clone --recurse-submodules https://github.com/balancer-labs/balancer-v2-monorepo.git
```

## Build and Test

Before any tests can be run, the repository needs to be prepared:
Expand All @@ -55,11 +67,27 @@ $ yarn test

You can see a sample report of a test run [here](./audits/test-report.md).

### Foundry (Forge) tests

To run Forge tests, first [install Foundry](https://book.getfoundry.sh/getting-started/installation). The installation steps below apply to Linux or MacOS. Follow the link for additional options.

```bash
$ curl -L https://foundry.paradigm.xyz | bash
$ source ~/.bashrc # or open a new terminal
$ foundryup
```

Then, to run tests in a single package, run:
```bash
$ cd pkg/<package> # e.g. cd pkg/v2-vault
$ yarn test-fuzz
```

## Security

Multiple independent reviews and audits were performed by [Certora](https://www.certora.com/), [OpenZeppelin](https://openzeppelin.com/) and [Trail of Bits](https://www.trailofbits.com/). The latest reports from these engagements are located in the [`audits`](./audits) directory.

Bug bounties apply to most of the smart contracts hosted in this repository: head to [Balancer V2 Bug Bounties](https://docs.balancer.fi/core-concepts/security/bug-bounties) to learn more.
Bug bounties apply to most of the smart contracts hosted in this repository: head to [Balancer V2 Bug Bounties](https://docs.balancer.fi/core-concepts/security/bug-bounties) to learn more. Alternatively, send an email to [email protected].

All core smart contracts are immutable, and cannot be upgraded. See page 6 of the [Trail of Bits audit](https://github.com/balancer-labs/balancer-v2-monorepo/blob/master/audits/trail-of-bits/2021-04-05.pdf):

Expand Down
4 changes: 3 additions & 1 deletion audits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ This directory the reports of audits performed on Balancer smart contracts by di
| MultiRewards, Stable Pool | OpenZeppelin | [`2021-10-09`](./openzeppelin/2021-10-09.pdf) |
| Linear Pool, Stable Phantom Pool | Trail Of Bits | [`2021-12-22`](./trail-of-bits/2021-12-22.pdf) |
| Timelock Authorizer | ABDK | [`2022-04-15`](./abdk/2022-04-15.pdf) |
| Batch Relayer | Trail Of Bits | [`2022-05-23`](./trail-of-bits/2022-05-23.pdf) |
| Batch Relayer | Trail Of Bits | [`2022-06-22`](./trail-of-bits/2022-06-22.pdf) |
| Composable Stable Pool | Certora | [`2022-09-01`](./certora/2022-09-01.pdf) |
| Composable Stable Pool | Trail Of Bits | [`2022-09-22`](./trail-of-bits/2022-09-22.pdf) |
Binary file added audits/certora/2022-09-01.pdf
Binary file not shown.
38 changes: 0 additions & 38 deletions audits/test-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,44 +398,6 @@ codes instead of standard revert strings.
➤ [@balancer-labs/v2-solidity-utils]: ✓ returns false when removing keys not in the set
➤ [@balancer-labs/v2-solidity-utils]: ✓ adds and removes multiple keys (535ms)
➤ [@balancer-labs/v2-solidity-utils]:
➤ [@balancer-labs/v2-solidity-utils]: LogCompression
➤ [@balancer-labs/v2-solidity-utils]: small values
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 1 (307ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 2 (258ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 3 (309ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 4 (262ms)
➤ [@balancer-labs/v2-solidity-utils]: medium and large values
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 5 (273ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 6
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 7 (263ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 8 (414ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 9
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 10
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 11 (287ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 12
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 13
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 14
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 15
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 16 (258ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 17 (344ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 18 (269ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 19
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 20
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 21
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 22
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 23
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 24 (270ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 25
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 26
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 27
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 28
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 29 (255ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 30
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 31 (383ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 32 (281ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 33 (316ms)
➤ [@balancer-labs/v2-solidity-utils]: ✓ encodes and decodes powers of 34 (356ms)
➤ [@balancer-labs/v2-solidity-utils]:
➤ [@balancer-labs/v2-solidity-utils]: ExpLog
➤ [@balancer-labs/v2-solidity-utils]: exponent zero
➤ [@balancer-labs/v2-solidity-utils]: ✓ handles base zero
Expand Down
Binary file added audits/trail-of-bits/2022-09-22.pdf
Binary file not shown.
25 changes: 25 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[profile.default]
src = 'contracts'
out = 'forge-artifacts'
libs = ['node_modules', 'lib']
test = 'test/foundry'
cache_path = 'forge-cache'
allow_paths = ['../', '../../pvt/lib/forge-std']
remappings = [
'ds-test/=../../pvt/lib/forge-std/lib/ds-test/src/',
'forge-std/=../../pvt/lib/forge-std/src/',
'@balancer-labs/=../../node_modules/@balancer-labs/'
]
optimizer = true
optimizer_runs = 9999
solc_version = '0.7.1'
ignored_error_codes = [8261]

[fuzz]
runs = 10000
max_test_rejects = 60000

[profile.intense.fuzz]
verbosity = 3
runs = 100000
max_test_rejects = 600000
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"url": "https://github.com/balancer-labs/balancer-v2-monorepo/issues"
},
"engines": {
"node": ">=12.10"
"node": ">=14.18.0 <15"
},
"contributors": [
"Daniel Fernandez <[email protected]>",
Expand Down
Loading

0 comments on commit 67d3f1a

Please sign in to comment.