Skip to content

Commit 00e4edc

Browse files
gretzkeMadeveda
andauthored
Rewrite initcode script, add filters for artifact jsons (#98)
* Rewrite initcode script, add filters for artifact jsons * Add additional compilation settings to deployers * add briefcase ci verification --------- Co-authored-by: Stephan Stürz <stuerz@protonmail.com>
1 parent 19afd01 commit 00e4edc

32 files changed

Lines changed: 686 additions & 143 deletions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Verify Briefcase
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
9+
jobs:
10+
verify-briefcase:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
20+
- name: Install Foundry
21+
uses: foundry-rs/foundry-toolchain@v1
22+
with:
23+
version: stable
24+
25+
- name: Compile Briefcase
26+
run: |
27+
forge --version
28+
forge install
29+
./script/util/create_briefcase.sh

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ library <ContractName>Deployer {
118118
*
119119
* @notice This initcode is generated from the following contract:
120120
* - Source Contract: src/pkgs/<package-name>/src/<contract-name>.sol
121+
* - solc: 0.X.X
122+
* - optimizer_runs: <optimizer_runs>
123+
* - via_ir: true/false
124+
* - evm_version: <evm_version>
121125
*/
122126
function initcode() internal pure returns (bytes memory) {
123127
return hex'';
@@ -127,7 +131,7 @@ library <ContractName>Deployer {
127131

128132
The deploy function can run arbitrary logic to deploy the contract, e.g., deploying via create, create2, using a factory, or a proxy. The deployer function should return the address and interface of the deployed contract so it can be called in subsequent steps.
129133

130-
After creating the deployer file, it's important to update the `Source Contract` path in the comment above the `initcode` function. This ensures that the correct contract is used for the initcode.
134+
After creating the deployer file, it's important to update the `Source Contract` path in the comment above the `initcode` function. This ensures that the correct contract is used for the initcode. Additionally, the `solc` version, `optimizer_runs`, `via_ir`, and `evm_version` should be specified. These additional fields are used as safeguards to ensure that the correct initcode is inserted into the deployer file.
131135

132136
Finally, run `./script/util/create_briefcase.sh` to generate the initcode for the deployer and populate the bytecode in the initcode function.
133137

ISSUES.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,3 @@
1515
- _Example_: [NonfungibleTokenPositionDescriptor](./src/briefcase/deployers/v3-periphery/NonfungibleTokenPositionDescriptorDeployer.sol)
1616
- **Expected behavior**: Foundry should be able to recognize that the placeholders in the bytecode have been replaced by the actual library address and match the bytecode correctly to the contract name.
1717
- **Workaround**: Generate the deployment logs manually after the deployment is complete using the `deploy-cli`.
18-
19-
## Solidity issues
20-
21-
- Compilation error when compiling the `PoolManager` contract
22-
- **Description**: When compiling with compilation restrictions enabled, the `PoolManager` contract fails to compile. The Solidity issue can be tracked [here](https://github.com/ethereum/solidity/issues/15582).
23-
- **Impact**: The `PoolManager` contract cannot be compiled.
24-
- **Expected behavior**: The `PoolManager` contract should be compiled successfully.
25-
- **Workaround**: v4-core is imported as a library and imported in a [helper file](./src/helper/PoolManagerImport.sol) in order to generate the required bytecode. As the code is not expected to change, this temporary workaround should not cause any disruptions.

foundry.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ additional_compiler_profiles = [
3636
{ name = "v3-periphery-default", optimizer_runs = 1000000, evm_version = "istanbul", via_ir = false },
3737
{ name = "permit2", optimizer_runs = 1000000, via_ir = true },
3838
{ name = "uniswapx", optimizer_runs = 1000000, via_ir = false },
39+
{ name = "util-contracts", optimizer_runs = 200, via_ir = false, evm_version = "paris" },
3940
]
4041

4142
compilation_restrictions = [
@@ -65,6 +66,8 @@ compilation_restrictions = [
6566
{ paths = "src/pkgs/swap-router-contracts/contracts/**", version = "0.7.6", via_ir = false, optimizer_runs = 1000000 },
6667
# X
6768
{ paths = "src/pkgs/uniswapx/src/base/BlockNumberish.sol", version = "0.8.24" },
69+
# util-contracts: util-contracts specifies shanghai fork, but it was only supported from 0.8.20 onwards, so paris is the correct evm version
70+
{ paths = "src/pkgs/util-contracts/src/**", version = "=0.8.19", optimizer_runs = 200, via_ir = false, evm_version = "paris" },
6871
# Briefcase
6972
{ paths = "src/briefcase/protocols/v2-periphery/libraries/UniswapV2Library.sol", version = "<0.8.0" },
7073
{ paths = "src/briefcase/protocols/lib-external/solidity-lib/**", version = "<0.8.0" },

script/util/create_briefcase.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ forge clean
5151
forge build
5252

5353
echo "Inserting current initcode into deployers"
54-
python3 script/util/insert_initcode.py "src/briefcase/deployers" "out"
54+
if ! python3 script/util/insert_initcode.py "src/briefcase/deployers" "out"; then
55+
rm -rf "$tmp_dir"
56+
forge fmt "src/briefcase"
57+
exit 1
58+
fi
5559

5660
rm -rf "$tmp_dir"
5761
forge fmt "src/briefcase"

0 commit comments

Comments
 (0)