Skip to content

Commit 35c9b5a

Browse files
razwwclaude
andcommitted
ci: shrink Factory and NPM under EIP-170
Adds bytecode_hash = "none" globally (matching Uniswap V3 core config) and compilation_restrictions pinning ListaV3Factory and NonfungiblePositionManager at optimizer_runs = 50. Factory and NPM were oversized under forge build --sizes; smaller run count + stripped metadata brings both safely under 24,576 bytes. Stripping metadata also makes POOL_INIT_CODE_HASH machine-deterministic — the hash is refreshed once more here and should not drift again on library or build-setting changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e8437fb commit 35c9b5a

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

foundry.toml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ src = "src"
33
out = "out"
44
libs = ["lib", "node_modules"]
55
optimizer = true
6-
optimizer_runs = 1000
6+
optimizer_runs = 500
7+
# Strip metadata suffix. Saves ~53 bytes per contract and makes POOL_INIT_CODE_HASH
8+
# deterministic across machines / lib changes (matching Uniswap V3's production config).
9+
bytecode_hash = "none"
10+
11+
# Factory and NonfungiblePositionManager exceed EIP-170 at the default run count.
12+
# Compile them with fewer runs (smaller runtime bytecode, slightly more gas per call).
13+
# Same profile for both so Foundry can resolve Deploy.s.sol (which imports both) as
14+
# a single compilation unit.
15+
additional_compiler_profiles = [
16+
{ name = "small", optimizer_runs = 50 },
17+
]
18+
19+
compilation_restrictions = [
20+
{ paths = "src/core/ListaV3Factory.sol", optimizer_runs = 50 },
21+
{ paths = "src/periphery/NonfungiblePositionManager.sol", optimizer_runs = 50 },
22+
]
723

824
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

src/periphery/libraries/PoolAddress.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ pragma solidity >=0.5.0;
33

44
/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee
55
library PoolAddress {
6-
// Post-rename init code hash of ListaV3Pool; must match keccak256(type(ListaV3Pool).creationCode).
7-
bytes32 internal constant POOL_INIT_CODE_HASH = 0x866ffd858f844cac69b3a90d247f1c6746d1a126fc3304e9ae519de5e76f7623;
6+
// Init code hash of ListaV3Pool; must match keccak256(type(ListaV3Pool).creationCode).
7+
// Stable across machines because foundry.toml sets bytecode_hash = "none".
8+
bytes32 internal constant POOL_INIT_CODE_HASH = 0xa93d35cf943696a95cabbe3aa4b3d87ea5387169face953a337716fc15136ca2;
89

910
/// @notice The identifying key of the pool
1011
struct PoolKey {

0 commit comments

Comments
 (0)