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

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
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 3aecc2
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"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"
}
}
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-v100=lib/ve-governance/v100/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
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
21 changes: 21 additions & 0 deletions test/upgrades/TestUpgrades.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;

import {Upgrades} from "openzeppelin-foundry-upgrades/LegacyUpgrades.sol";
import {Test} from "forge-std/Test.sol";
//import {Clock} from '@aragon/ve-governance-v101/clock/Clock.sol';
//import {Clock as ClockV2} from '@clock/Clock.sol';

import { Options } from "openzeppelin-foundry-upgrades/Options.sol";

contract AragonTest is Test {
function testUpgrades() public {
//Clock clock = new Clock();

Options memory options;
options.referenceBuildInfoDir = "ref_builds/build-info-v101";
options.referenceContract = "build-info-v101:Clock";

Upgrades.validateUpgrade("Clock.sol", options);
}
}
Loading