Component
Forge
Describe the feature you would like
Foundry's contract size reporting and script deployment warnings still assume Ethereum's size limits in places that are now shared by all network modes.
In current master, forge build --sizes uses hardcoded limits in crates/common/src/compile.rs:
- runtime code:
CONTRACT_RUNTIME_SIZE_LIMIT = 24576 (EIP-170)
- initcode:
CONTRACT_INITCODE_SIZE_LIMIT = 49152 (EIP-3860)
Those constants are used for:
- failure conditions in
SizeReport::exceeds_runtime_size_limit() and SizeReport::exceeds_initcode_size_limit()
- JSON size margins
- table margins and warning colors
- error messages
Separately, forge script deployment-size warnings fall back to CONTRACT_MAX_SIZE from foundry-common unless code_size_limit is explicitly set.
This is correct for Ethereum, but Foundry now has network-aware execution paths (NetworkConfigs, FoundryEvmNetwork, network-specific EVM factories). Some networks can have protocol code-size or initcode-size limits that differ from Ethereum. The execution layer can enforce those network-specific limits, but the compile/reporting layer cannot currently consume them.
Impact:
forge build --sizes can fail or report negative margins for contracts that are valid on a selected non-Ethereum network.
- JSON and table size output always reports Ethereum margins, even when another network's limits should apply.
- Network integrations have to either hardcode downstream changes, disable size reporting, or ask users to ignore warnings that should be computed from the selected network.
forge script has a manual --code-size-limit workaround for its deployment warning path, but this does not provide network defaults and does not help forge build --sizes.
--ignore-eip-3860 only bypasses the initcode failure and does not address runtime size limits, displayed margins, or network-specific defaults.
Expected behavior:
Foundry should have a generic contract-size limit model that defaults to Ethereum's current values, while allowing callers/network configuration to provide different runtime and initcode limits.
A possible shape:
- Add a small
ContractSizeLimits type with Ethereum defaults:
runtime = 24576
initcode = 49152
- Let
ProjectCompiler accept size limits, defaulting to Ethereum when unset.
- Make
SizeReport use the configured limits for failures, JSON output, table margins, and colors.
- Make script deployment-size warnings use the same configured/default runtime limit instead of directly falling back to
CONTRACT_MAX_SIZE.
This should preserve existing Ethereum behavior while giving network integrations a clean upstream extension point.
Component
Forge
Describe the feature you would like
Foundry's contract size reporting and script deployment warnings still assume Ethereum's size limits in places that are now shared by all network modes.
In current
master,forge build --sizesuses hardcoded limits incrates/common/src/compile.rs:CONTRACT_RUNTIME_SIZE_LIMIT = 24576(EIP-170)CONTRACT_INITCODE_SIZE_LIMIT = 49152(EIP-3860)Those constants are used for:
SizeReport::exceeds_runtime_size_limit()andSizeReport::exceeds_initcode_size_limit()Separately,
forge scriptdeployment-size warnings fall back toCONTRACT_MAX_SIZEfromfoundry-commonunlesscode_size_limitis explicitly set.This is correct for Ethereum, but Foundry now has network-aware execution paths (
NetworkConfigs,FoundryEvmNetwork, network-specific EVM factories). Some networks can have protocol code-size or initcode-size limits that differ from Ethereum. The execution layer can enforce those network-specific limits, but the compile/reporting layer cannot currently consume them.Impact:
forge build --sizescan fail or report negative margins for contracts that are valid on a selected non-Ethereum network.forge scripthas a manual--code-size-limitworkaround for its deployment warning path, but this does not provide network defaults and does not helpforge build --sizes.--ignore-eip-3860only bypasses the initcode failure and does not address runtime size limits, displayed margins, or network-specific defaults.Expected behavior:
Foundry should have a generic contract-size limit model that defaults to Ethereum's current values, while allowing callers/network configuration to provide different runtime and initcode limits.
A possible shape:
ContractSizeLimitstype with Ethereum defaults:runtime = 24576initcode = 49152ProjectCompileraccept size limits, defaulting to Ethereum when unset.SizeReportuse the configured limits for failures, JSON output, table margins, and colors.CONTRACT_MAX_SIZE.This should preserve existing Ethereum behavior while giving network integrations a clean upstream extension point.