[Feat] - Foundry config, supports London EVM_VERSION for L2 Linea contracts (#361)

* forge build working

* poc done

* commit

* did lint command

* remove caret from hardhat-foundry

* add foundry installation to run-smc-tests.yml

* update run-smc-tests.yml
This commit is contained in:
kyzooghost
2024-11-30 02:09:07 +11:00
committed by GitHub
parent da5b7df89b
commit 8a20b27f3d
11 changed files with 70 additions and 7 deletions

View File

@@ -48,6 +48,10 @@ jobs:
- name: Check JS formatting
run: pnpm -F contracts run lint:ts
# Required for hardhat commands due to @nomicfoundation/hardhat-foundry package
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Compile kzg.node
run: npx node-gyp --directory=contracts/node_modules/c-kzg rebuild # explicitly running rebuild to get the .node file

3
.gitignore vendored
View File

@@ -53,4 +53,5 @@ coverage
tsconfig.build.tsbuildinfo
ts-libs/**/lib/**/*.so
ts-libs/**/lib/**/*.dylib
contracts/lib/forge-std/
contracts/lib/forge-std/
cache_forge

3
.gitmodules vendored
View File

@@ -4,3 +4,6 @@
[submodule "corset"]
path = corset
url = git@github.com:consensys/corset.git
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std

View File

@@ -4,3 +4,4 @@ cache
coverage*
gasReporterOutput.json
typechain-types
lib

View File

@@ -1,2 +1,4 @@
node_modules
contracts/test-contracts
lib/forge-std
contracts/test-contracts
test/foundry

22
contracts/foundry.toml Normal file
View File

@@ -0,0 +1,22 @@
[profile.default]
src = 'contracts'
out = 'out'
libs = ['node_modules', 'lib']
cache_path = 'cache_forge'
# Test settings
match-path = 'test/foundry/*'
# Default solc compiler settings
evm_version = "cancun"
optimizer = true
optimizer_runs = 10_000
# Compiler overrides
additional_compiler_profiles = [ { name = "london", evm_version = "london" } ]
# Specify EVM_VERSION restrictions for contract compilation
compilation_restrictions = [
{ paths = "./**/L2MessageService.sol", evm_version = "london" },
{ paths = "./**/TokenBridge.sol", evm_version = "london" },
]

View File

@@ -1,4 +1,5 @@
import "@nomicfoundation/hardhat-toolbox";
import "@nomicfoundation/hardhat-foundry";
import "@openzeppelin/hardhat-upgrades";
import * as dotenv from "dotenv";
import "hardhat-deploy";

View File

@@ -24,6 +24,7 @@
"devDependencies": {
"@ethereumjs/util": "9.0.3",
"@nomicfoundation/hardhat-ethers": "3.0.5",
"@nomicfoundation/hardhat-foundry": "1.1.3",
"@nomicfoundation/hardhat-network-helpers": "1.0.10",
"@nomicfoundation/hardhat-toolbox": "4.0.0",
"@nomicfoundation/hardhat-verify": "1.1.1",

View File

@@ -0,0 +1,12 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.26;
import "forge-std/Test.sol";
contract ExampleFoundryTest is Test {
function setUp() public {}
function testSample() public {
// Write test
}
}

25
pnpm-lock.yaml generated
View File

@@ -178,6 +178,9 @@ importers:
'@nomicfoundation/hardhat-ethers':
specifier: 3.0.5
version: 3.0.5(ethers@6.12.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))(hardhat@2.22.11(bufferutil@4.0.8)(c-kzg@2.1.2)(ts-node@10.9.2(@types/node@20.12.7)(typescript@5.4.5))(typescript@5.4.5)(utf-8-validate@5.0.10))
'@nomicfoundation/hardhat-foundry':
specifier: 1.1.3
version: 1.1.3(hardhat@2.22.11(bufferutil@4.0.8)(c-kzg@2.1.2)(ts-node@10.9.2(@types/node@20.12.7)(typescript@5.4.5))(typescript@5.4.5)(utf-8-validate@5.0.10))
'@nomicfoundation/hardhat-network-helpers':
specifier: 1.0.10
version: 1.0.10(hardhat@2.22.11(bufferutil@4.0.8)(c-kzg@2.1.2)(ts-node@10.9.2(@types/node@20.12.7)(typescript@5.4.5))(typescript@5.4.5)(utf-8-validate@5.0.10))
@@ -2215,6 +2218,11 @@ packages:
ethers: ^6.1.0
hardhat: ^2.0.0
'@nomicfoundation/hardhat-foundry@1.1.3':
resolution: {integrity: sha512-30Ezc3hlZ4pC5Z/9W9euW5uoPKKQQKaecLETHJH8BPpd30zYOooy6HfjmcTY1/taOQjlwirOdNO7tHlje8Qcgw==}
peerDependencies:
hardhat: ^2.17.2
'@nomicfoundation/hardhat-network-helpers@1.0.10':
resolution: {integrity: sha512-R35/BMBlx7tWN5V6d/8/19QCwEmIdbnA4ZrsuXgvs8i2qFx5i7h6mH5pBS4Pwi4WigLH+upl6faYusrNPuzMrQ==}
peerDependencies:
@@ -2670,6 +2678,7 @@ packages:
'@safe-global/safe-core-sdk-types@4.0.2':
resolution: {integrity: sha512-3I60xV/BLPiBtc3nGp2itgiDL+YbMI9OwaANvnJL2AwSS1kc2kH3/SsCwAW3s4Usr3b0lE08aO7I9ropyxFHhA==}
deprecated: 'WARNING: This project has been renamed to @safe-global/types-kit. Please, migrate from @safe-global/safe-core-sdk-types@5.1.0 to @safe-global/types-kit@1.0.0.'
'@safe-global/safe-deployments@1.37.10':
resolution: {integrity: sha512-lcxX9CV+xdcLs4dF6Cx18zDww5JyqaX6RdcvU0o/34IgJ4Wjo3J/RNzJAoMhurCAfTGr+0vyJ9V13Qo50AR6JA==}
@@ -5012,6 +5021,7 @@ packages:
eslint@8.57.0:
resolution: {integrity: sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options.
hasBin: true
esniff@2.0.1:
@@ -9824,7 +9834,7 @@ snapshots:
'@babel/core': 7.25.7
'@babel/helper-module-imports': 7.25.7
'@babel/helper-simple-access': 7.25.7
'@babel/helper-validator-identifier': 7.25.7
'@babel/helper-validator-identifier': 7.25.9
'@babel/traverse': 7.25.7
transitivePeerDependencies:
- supports-color
@@ -10261,7 +10271,7 @@ snapshots:
'@babel/core': 7.25.7
'@babel/helper-module-transforms': 7.25.7(@babel/core@7.25.7)
'@babel/helper-plugin-utils': 7.25.7
'@babel/helper-validator-identifier': 7.25.7
'@babel/helper-validator-identifier': 7.25.9
'@babel/traverse': 7.25.7
transitivePeerDependencies:
- supports-color
@@ -11910,6 +11920,11 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@nomicfoundation/hardhat-foundry@1.1.3(hardhat@2.22.11(bufferutil@4.0.8)(c-kzg@2.1.2)(ts-node@10.9.2(@types/node@20.12.7)(typescript@5.4.5))(typescript@5.4.5)(utf-8-validate@5.0.10))':
dependencies:
hardhat: 2.22.11(bufferutil@4.0.8)(c-kzg@2.1.2)(ts-node@10.9.2(@types/node@20.12.7)(typescript@5.4.5))(typescript@5.4.5)(utf-8-validate@5.0.10)
picocolors: 1.1.0
'@nomicfoundation/hardhat-network-helpers@1.0.10(hardhat@2.22.11(bufferutil@4.0.8)(c-kzg@2.1.2)(ts-node@10.9.2(@types/node@20.12.7)(typescript@5.4.5))(typescript@5.4.5)(utf-8-validate@5.0.10))':
dependencies:
ethereumjs-util: 7.1.5
@@ -15844,7 +15859,7 @@ snapshots:
debug: 4.3.7(supports-color@8.1.1)
enhanced-resolve: 5.17.1
eslint: 8.57.0
eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.0))(eslint@8.57.0)
eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.0)
fast-glob: 3.3.2
get-tsconfig: 4.8.1
is-bun-module: 1.2.1
@@ -15857,7 +15872,7 @@ snapshots:
- eslint-import-resolver-webpack
- supports-color
eslint-module-utils@2.12.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.0))(eslint@8.57.0):
eslint-module-utils@2.12.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.0):
dependencies:
debug: 3.2.7
optionalDependencies:
@@ -15879,7 +15894,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.0))(eslint@8.57.0)
eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.4.5))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.0)
hasown: 2.0.2
is-core-module: 2.15.1
is-glob: 4.0.3