From 4f3c72d5799372b4c1cca486a949214aebb7baaf Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 9 Nov 2023 13:45:26 +0100 Subject: [PATCH 1/7] Adding foundry for acre Acre project can take advantage of foundry framework to write tests in Solidity. Acre now will use a hybrid approach by having tests written in Solidity and deployment scripts written in TS using HH deployment plugin. --- .gitmodules | 3 +++ core/.gitignore | 3 +++ core/foundry.toml | 6 ++++++ core/hardhat.config.ts | 1 + core/package.json | 1 + core/yarn.lock | 7 +++++++ 6 files changed, 21 insertions(+) create mode 100644 .gitmodules create mode 100644 core/foundry.toml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..46c6a63b7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "core/lib/forge-std"] + path = core/lib/forge-std + url = https://github.com/foundry-rs/forge-std diff --git a/core/.gitignore b/core/.gitignore index a3a59115e..d589b7901 100644 --- a/core/.gitignore +++ b/core/.gitignore @@ -1,8 +1,11 @@ build/ cache/ +cache_forge/ export.json export/ +lib/ node_modules/ +out/ typechain/ yarn-debug.log* yarn-error.log* diff --git a/core/foundry.toml b/core/foundry.toml new file mode 100644 index 000000000..4f3bf9f3f --- /dev/null +++ b/core/foundry.toml @@ -0,0 +1,6 @@ +[profile.default] +src = 'contracts' +out = 'out' +libs = ['node_modules', 'lib'] +test = 'test' +cache_path = 'cache_forge' \ No newline at end of file diff --git a/core/hardhat.config.ts b/core/hardhat.config.ts index 64e14bce6..a4d0a421c 100644 --- a/core/hardhat.config.ts +++ b/core/hardhat.config.ts @@ -1,6 +1,7 @@ import { HardhatUserConfig } from "hardhat/config" import "@nomicfoundation/hardhat-toolbox" +import "@nomicfoundation/hardhat-foundry" import "hardhat-deploy" const config: HardhatUserConfig = { diff --git a/core/package.json b/core/package.json index 570eebfbf..b9b6b30b7 100644 --- a/core/package.json +++ b/core/package.json @@ -30,6 +30,7 @@ "devDependencies": { "@nomicfoundation/hardhat-chai-matchers": "^2.0.0", "@nomicfoundation/hardhat-ethers": "^3.0.0", + "@nomicfoundation/hardhat-foundry": "^1.1.1", "@nomicfoundation/hardhat-network-helpers": "^1.0.0", "@nomicfoundation/hardhat-toolbox": "^3.0.0", "@nomicfoundation/hardhat-verify": "^1.0.0", diff --git a/core/yarn.lock b/core/yarn.lock index cf702692a..5b17dd0c9 100644 --- a/core/yarn.lock +++ b/core/yarn.lock @@ -765,6 +765,13 @@ debug "^4.1.1" lodash.isequal "^4.5.0" +"@nomicfoundation/hardhat-foundry@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-foundry/-/hardhat-foundry-1.1.1.tgz#db72b1f33f9cfaecc27e67f69ad436f8710162d6" + integrity sha512-cXGCBHAiXas9Pg9MhMOpBVQCkWRYoRFG7GJJAph+sdQsfd22iRs5U5Vs9XmpGEQd1yEvYISQZMeE68Nxj65iUQ== + dependencies: + chalk "^2.4.2" + "@nomicfoundation/hardhat-network-helpers@^1.0.0": version "1.0.9" resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-network-helpers/-/hardhat-network-helpers-1.0.9.tgz#767449e8a2acda79306ac84626117583d95d25aa" From cc2fe5db1992203df3d6d32883f9302c288af6f4 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 21 Nov 2023 12:44:29 +0100 Subject: [PATCH 2/7] Adding erc4626 and forge-std submodules --- .gitmodules | 3 +++ core/lib/erc4626 | 1 + core/lib/forge-std | 1 + 3 files changed, 5 insertions(+) create mode 160000 core/lib/erc4626 create mode 160000 core/lib/forge-std diff --git a/.gitmodules b/.gitmodules index 46c6a63b7..a92a51b80 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "core/lib/forge-std"] path = core/lib/forge-std url = https://github.com/foundry-rs/forge-std +[submodule "core/lib/erc4626"] + path = core/lib/erc4626 + url = https://github.com/thesis/erc4626 diff --git a/core/lib/erc4626 b/core/lib/erc4626 new file mode 160000 index 000000000..643cd044f --- /dev/null +++ b/core/lib/erc4626 @@ -0,0 +1 @@ +Subproject commit 643cd044fac34bcbf64e1c3790a5126fec0dbec1 diff --git a/core/lib/forge-std b/core/lib/forge-std new file mode 160000 index 000000000..2f1126975 --- /dev/null +++ b/core/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 2f112697506eab12d433a65fdc31a639548fe365 From f4056e5317a69ce556d8ebcd0d44161ef8592804 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 21 Nov 2023 13:04:32 +0100 Subject: [PATCH 3/7] Adding forge remappings --- core/remappings.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 core/remappings.txt diff --git a/core/remappings.txt b/core/remappings.txt new file mode 100644 index 000000000..8db3cd901 --- /dev/null +++ b/core/remappings.txt @@ -0,0 +1,8 @@ +@openzeppelin/=node_modules/@openzeppelin/ +ERC4626-Contracts/=lib/ERC4626-Contracts/src/ +ds-test/=lib/ds-test/src/ +eth-gas-reporter/=node_modules/eth-gas-reporter/ +forge-std/=lib/forge-std/src/ +hardhat-deploy/=node_modules/hardhat-deploy/ +hardhat/=node_modules/hardhat/ +solmate/=lib/solmate/src/ From eee114839183d8cc79cde49068565a2380d902d6 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 21 Nov 2023 13:05:07 +0100 Subject: [PATCH 4/7] Unignoring /lib cause it will be used for submodules --- core/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/core/.gitignore b/core/.gitignore index d589b7901..42bf36d7a 100644 --- a/core/.gitignore +++ b/core/.gitignore @@ -3,7 +3,6 @@ cache/ cache_forge/ export.json export/ -lib/ node_modules/ out/ typechain/ From c3ce8e8f4e24121cdaee3227bbb778ed2b74a8c2 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 21 Nov 2023 13:29:48 +0100 Subject: [PATCH 5/7] Adding solmate submodule --- .gitmodules | 3 +++ core/lib/solmate | 1 + core/remappings.txt | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 160000 core/lib/solmate diff --git a/.gitmodules b/.gitmodules index a92a51b80..e375af1c1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "core/lib/erc4626"] path = core/lib/erc4626 url = https://github.com/thesis/erc4626 +[submodule "core/lib/solmate"] + path = core/lib/solmate + url = https://github.com/Rari-Capital/solmate diff --git a/core/lib/solmate b/core/lib/solmate new file mode 160000 index 000000000..e0e9ff05d --- /dev/null +++ b/core/lib/solmate @@ -0,0 +1 @@ +Subproject commit e0e9ff05d8aa5c7c48465511f85a6efdf5d5c30d diff --git a/core/remappings.txt b/core/remappings.txt index 8db3cd901..52a5fc070 100644 --- a/core/remappings.txt +++ b/core/remappings.txt @@ -1,5 +1,5 @@ @openzeppelin/=node_modules/@openzeppelin/ -ERC4626-Contracts/=lib/ERC4626-Contracts/src/ +erc4626/=lib/erc4626/src/ ds-test/=lib/ds-test/src/ eth-gas-reporter/=node_modules/eth-gas-reporter/ forge-std/=lib/forge-std/src/ From 1713f3120bc7e9fca8d5b69ad726ba53f2861f42 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 21 Nov 2023 13:51:08 +0100 Subject: [PATCH 6/7] Adding ds-test submodule --- .gitmodules | 3 +++ core/lib/ds-test | 1 + core/remappings.txt | 1 - 3 files changed, 4 insertions(+), 1 deletion(-) create mode 160000 core/lib/ds-test diff --git a/.gitmodules b/.gitmodules index e375af1c1..7048255c8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "core/lib/solmate"] path = core/lib/solmate url = https://github.com/Rari-Capital/solmate +[submodule "core/lib/ds-test"] + path = core/lib/ds-test + url = https://github.com/dapphub/ds-test diff --git a/core/lib/ds-test b/core/lib/ds-test new file mode 160000 index 000000000..e282159d5 --- /dev/null +++ b/core/lib/ds-test @@ -0,0 +1 @@ +Subproject commit e282159d5170298eb2455a6c05280ab5a73a4ef0 diff --git a/core/remappings.txt b/core/remappings.txt index 52a5fc070..c7489c190 100644 --- a/core/remappings.txt +++ b/core/remappings.txt @@ -1,6 +1,5 @@ @openzeppelin/=node_modules/@openzeppelin/ erc4626/=lib/erc4626/src/ -ds-test/=lib/ds-test/src/ eth-gas-reporter/=node_modules/eth-gas-reporter/ forge-std/=lib/forge-std/src/ hardhat-deploy/=node_modules/hardhat-deploy/ From e8172544f1eccb888e1edd278da9d93dacf43f00 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 21 Nov 2023 14:10:27 +0100 Subject: [PATCH 7/7] Installing Foundry for github CI --- .github/workflows/core.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/core.yaml b/.github/workflows/core.yaml index 7addece4a..aa4cb9048 100644 --- a/.github/workflows/core.yaml +++ b/.github/workflows/core.yaml @@ -35,6 +35,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + submodules: recursive - name: Set up Node uses: actions/setup-node@v4 @@ -46,6 +48,9 @@ jobs: - name: Install Dependencies run: yarn install --prefer-offline --frozen-lockfile + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + - name: Build run: yarn build @@ -74,6 +79,9 @@ jobs: - name: Install Dependencies run: yarn install --prefer-offline --frozen-lockfile + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + - name: Download Build Artifacts uses: actions/download-artifact@v3 with: @@ -83,6 +91,22 @@ jobs: - name: Test run: yarn test --no-compile + core-foundry-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + + - name: Run tests + run: forge test -vvv + + - name: Run snapshot + run: forge snapshot + core-deploy-dry-run: needs: [core-build] runs-on: ubuntu-latest @@ -99,6 +123,9 @@ jobs: - name: Install Dependencies run: yarn install --prefer-offline --frozen-lockfile + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + - name: Download Build Artifacts uses: actions/download-artifact@v3 with: