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

Feature/rd 1193 add openzeppelin foundry upgrades to the repo #51

109 changes: 90 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,111 @@
name: CI
name: Tests

on:
push:
branches:
- 'main'
- 'develop'
- 'deploy/**'
pull_request:
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
test-upgrades:
strategy:
fail-fast: true
name: Test upgrades
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: oven-sh/setup-bun@v2

- name: foundry-toolchain
uses: foundry-rs/[email protected]

name: Foundry project
- name: Show Forge version
run: forge --version

- name: Build
run: bun run build-all

- name: Run tests
run: bun run test-upgrades
test-fork:
strategy:
fail-fast: true
name: Test fork
runs-on: ubuntu-latest
env:
NETWORK: "sepolia"
FORK_TEST_MODE: "new-factory"
DEPLOY_AS_PRODUCTION: false
TOKEN_TEST_WHALE: "0x"
FACTORY_ADDRESS: "0x"
MULTISIG_MEMBERS_JSON_FILE_NAME: "/script/multisig-members.json"
MIN_APPROVALS: 1
MULTISIG_PROPOSAL_EXPIRATION_PERIOD: "864000"
MINT_TEST_TOKENS: true
TOKEN1_ADDRESS: "0x0000000000000000000000000000000000000000"
VE_TOKEN1_NAME: "Voting Escrow Token 1"
VE_TOKEN1_SYMBOL: "veTK1"
TOKEN2_ADDRESS: "0x0000000000000000000000000000000000000000"
VE_TOKEN2_NAME: "Voting Escrow Token 2"
VE_TOKEN2_SYMBOL: "veTK2"
FEE_PERCENT: "0" # 10_000 = 100%
WARMUP_PERIOD: "259200" # 3 days
COOLDOWN_PERIOD: "259200" # 3 days
MIN_LOCK_DURATION: "1"
VOTING_PAUSED: true
MIN_DEPOSIT: "10000000000000000" # 0.01 ETH
MULTISIG_PLUGIN_REPO_ADDRESS: "0x9e7956C8758470dE159481e5DD0d08F8B59217A2"
MULTISIG_PLUGIN_RELEASE: "1"
MULTISIG_PLUGIN_BUILD: "2"
SIMPLE_GAUGE_VOTER_REPO_ENS_SUBDOMAIN: "gauge-voter-${{ vars.GITHUB_RUN_ID }}"
DAO_FACTORY: "0x7a62da7B56fB3bfCdF70E900787010Bc4c9Ca42e"
PLUGIN_SETUP_PROCESSOR: "0xC24188a73dc09aA7C721f96Ad8857B469C01dC9f"
PLUGIN_REPO_FACTORY: "0x07f49c49Ce2A99CF7C28F66673d406386BDD8Ff4"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
submodules: true
- uses: oven-sh/setup-bun@v2

- name: foundry-toolchain
uses: foundry-rs/[email protected]

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Show Forge version
run: forge --version

- name: Build
run: bun run build

- name: Run tests
run: bun run test-fork
test-unit:
strategy:
fail-fast: true
name: Test unit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
version: nightly
submodules: true
- uses: oven-sh/setup-bun@v2

- name: foundry-toolchain
uses: foundry-rs/[email protected]

- name: Show Forge version
run: |
forge --version

- name: Run Forge build
run: |
forge build --sizes
id: build

- name: Run Forge tests
run: |
forge test --no-match-path "test/fork/**/*.sol" -vvv
id: test
run: forge --version

- name: Build
run: bun run build

- name: Run tests
run: bun run test-unit

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Foundry
cache/
out/
ref_builds/
broadcast/

# JS
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ branch = v4.9.2
[submodule "lib/ens-contracts"]
path = lib/ens-contracts
url = https://github.com/ensdomains/ens-contracts
[submodule "lib/openzeppelin-foundry-upgrades"]
path = lib/openzeppelin-foundry-upgrades
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
[submodule "lib/ve-governance/v101"]
path = lib/ve-governance/v101
url = https://github.com/aragon/ve-governance
5 changes: 5 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ test = "test"
verbosity = 3
evm_version = "shanghai"

ffi = true
ast = true
build_info = true
extra_output = ["storageLayout"]

[profile.ci]
fuzz = { runs = 10_000 }
verbosity = 4
Expand Down
1 change: 1 addition & 0 deletions lib/openzeppelin-foundry-upgrades
1 change: 1 addition & 0 deletions lib/ve-governance/v101
Submodule v101 added at 76a0ab
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
"name": "ve-governance",
"version": "1.0.0",
"devDependencies": {
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.4.1"
},
"scripts": {
"build": "forge build",
"build-clean": "forge build --force",
"build-refs": "bash script/build-reference-builds.sh",
"build-all": "bun run build-refs && bun run build-clean",
"test-unit": "forge test --no-match-path \"{test/fork/*.sol,test/upgrades/*.sol}\" -vvv",
"test-fork": "forge test --match-path \"test/fork/**/*.sol\" --rpc-url https://sepolia.drpc.org -vvv",
"test-upgrades": "forge test --build-info --match-path \"test/upgrades/**/*.sol\" -vvv",
"test": "forge test -vvv"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be added to the makefile or we replace the makefile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100%, better all together. And make is easier to use in CI

}
}
2 changes: 2 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ utils/=test/utils/
@aragon/osx/=lib/osx/packages/contracts/src/
@aragon/admin/=lib/osx/packages/contracts/src/plugins/governance/admin/
@aragon/multisig/=lib/osx/packages/contracts/src/plugins/governance/multisig/
@aragon/ve-governance-v101=lib/ve-governance/v101/src/

@interfaces/=src/interfaces/
@mocks/=test/mocks/
Expand All @@ -25,5 +26,6 @@ ens-contracts/=lib/ens-contracts/contracts/
openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/
openzeppelin-contracts/=lib/openzeppelin-contracts/
erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/
openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src

@solmate/=lib/solmate/src/
16 changes: 16 additions & 0 deletions script/build-reference-builds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -euo pipefail

rm -rf ref_builds
mkdir -p ref_builds

for file in lib/ve-governance/*;
do
echo "Processing $file"
filename=$(echo $file | sed 's/\//-/g')
filename=$(echo $filename | sed 's/lib-ve-governance-//g')
mkdir -p ref_builds/build-info-$filename
forge build --force --root=$file
mv $file/out/build-info/*.json ref_builds/build-info-$filename
done
1 change: 1 addition & 0 deletions src/clock/Clock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ contract Clock is IClock, DaoAuthorizable, UUPSUpgradeable {
Initialization
//////////////////////////////////////////////////////////////*/

/// @custom:oz-upgrades-unsafe-allow constructor
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This annotation is needed in all the contracts with a constructor (also in the old ones)

constructor() {
_disableInitializers();
}
Expand Down
3 changes: 0 additions & 3 deletions test/fork/e2eV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -987,9 +987,6 @@ contract TestE2EV2 is AragonTest, IWithdrawalQueueErrors, IGaugeVote, IEscrowCur
// alice tries to exit
vm.startPrank(alice);
{
vm.expectRevert(VotingInactive.selector);
escrow.resetVotesAndBeginWithdrawal(1);

vm.expectRevert(CannotExit.selector);
escrow.beginWithdrawal(1);
}
Expand Down
17 changes: 9 additions & 8 deletions test/integration/GaugesDaoFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.17;

import "forge-std/Test.sol";
import {MockERC20} from "@solmate/test/utils/mocks/MockERC20.sol";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using the solmate erc20?:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forge-std deprecated the ERC20Mock

import {GaugesDaoFactory, Deployment, DeploymentParameters, TokenParameters} from "../../src/factory/GaugesDaoFactory.sol";
import {MockPluginSetupProcessor} from "@mocks/osx/MockPSP.sol";
import {MockPluginSetupProcessorMulti} from "@mocks/osx/MockPSPMulti.sol";
Expand Down Expand Up @@ -382,12 +383,12 @@ contract GaugesDaoFactoryTest is Test {

TokenParameters[] memory tokenParameters = new TokenParameters[](2);
tokenParameters[0] = TokenParameters({
token: address(deployMockERC20("T1", "T1", 18)),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deployMockERC20 was deprecated on the new version of forge-std

token: address(new MockERC20("T1", "T1", 18)),
veTokenName: "Name 1",
veTokenSymbol: "TK1"
});
tokenParameters[1] = TokenParameters({
token: address(deployMockERC20("T2", "T2", 18)),
token: address(new MockERC20("T2", "T2", 18)),
veTokenName: "Name 2",
veTokenSymbol: "TK2"
});
Expand Down Expand Up @@ -767,17 +768,17 @@ contract GaugesDaoFactoryTest is Test {

TokenParameters[] memory tokenParameters = new TokenParameters[](3);
tokenParameters[0] = TokenParameters({
token: address(deployMockERC20("T3", "T3", 18)),
token: address(new MockERC20("T3", "T3", 18)),
veTokenName: "Name 3",
veTokenSymbol: "TK3"
});
tokenParameters[1] = TokenParameters({
token: address(deployMockERC20("T4", "T4", 18)),
token: address(new MockERC20("T4", "T4", 18)),
veTokenName: "Name 4",
veTokenSymbol: "TK4"
});
tokenParameters[2] = TokenParameters({
token: address(deployMockERC20("T5", "T5", 18)),
token: address(new MockERC20("T5", "T5", 18)),
veTokenName: "Name 5",
veTokenSymbol: "TK5"
});
Expand Down Expand Up @@ -1261,17 +1262,17 @@ contract GaugesDaoFactoryTest is Test {

TokenParameters[] memory tokenParameters = new TokenParameters[](3);
tokenParameters[0] = TokenParameters({
token: address(deployMockERC20("T3", "T3", 18)),
token: address(new MockERC20("T3", "T3", 18)),
veTokenName: "Name 3",
veTokenSymbol: "TK3"
});
tokenParameters[1] = TokenParameters({
token: address(deployMockERC20("T4", "T4", 18)),
token: address(new MockERC20("T4", "T4", 18)),
veTokenName: "Name 4",
veTokenSymbol: "TK4"
});
tokenParameters[2] = TokenParameters({
token: address(deployMockERC20("T5", "T5", 18)),
token: address(new MockERC20("T5", "T5", 18)),
veTokenName: "Name 5",
veTokenSymbol: "TK5"
});
Expand Down
Loading
Loading