Skip to content

bug(forge build): contract using setUp as function is tagged as is_dev_contract causing it to be filtered out in --sizes table #11126

@miohtama

Description

@miohtama

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge Version: 1.2.3-stable Commit SHA: a813a2c Build Timestamp: 2025-06-08T15:42:50.507050000Z (1749397370) Build Profile: maxperf

What version of Foundryup are you on?

foundryup --version foundryup: 1.3.0

What command(s) is the bug in?

forge build --force --sizes

Operating System

macOS (Apple Silicon)

Describe the bug

For some reason, forge build --sizes does not show the sizes of all contracts.

  • I have double checked that the contract is not abstract
  • I have double checked that the contract compiles

Here is a command I run

forge build --force --sizes -vvvvv src/TradingStrategyModuleV0.sol

Here is the output and you can see it compiles multiple contract mores than in --sizes output:

[⠊] Compiling...
[⠒] Files to compile:
- ../guard/src/GuardV0Base.sol
- /Users/moo/code/trade-executor/deps/web3-ethereum-defi/contracts/guard/src/IGuard.sol
- /Users/moo/code/trade-executor/deps/web3-ethereum-defi/contracts/guard/src/lib/BytesLib.sol
- /Users/moo/code/trade-executor/deps/web3-ethereum-defi/contracts/guard/src/lib/IERC20.sol
- /Users/moo/code/trade-executor/deps/web3-ethereum-defi/contracts/guard/src/lib/IERC4626.sol
- /Users/moo/code/trade-executor/deps/web3-ethereum-defi/contracts/guard/src/lib/Path.sol
- lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol
- lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol
- lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol
- lib/safe-contracts/contracts/common/Enum.sol
- lib/zodiac/contracts/core/Module.sol
- lib/zodiac/contracts/factory/FactoryFriendly.sol
- lib/zodiac/contracts/interfaces/IAvatar.sol
- src/TradingStrategyModuleV0.sol
[⠆] Compiling 14 files with Solc 0.8.26
[⠰] Solc 0.8.26 finished in 116.28ms
Compiler run successful!

╭----------+------------------+-------------------+--------------------+---------------------╮
| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) |
+============================================================================================+
| BytesLib | 85               | 160               | 24,491             | 48,992              |
|----------+------------------+-------------------+--------------------+---------------------|
| Enum     | 62               | 88                | 24,514             | 49,064              |
|----------+------------------+-------------------+--------------------+---------------------|
| Path     | 85               | 160               | 24,491             | 48,992              |
╰----------+------------------+-------------------+--------------------+---------------------╯

Specifically we can check TradingStrategyModuleV0 is not an abstract contract and should appear in the --sizes output:

cat out/TradingStrategyModuleV0.sol/TradingStrategyModuleV0.json| jq ".bytecode"
{
  "object": "0x608060405234801561000f575f80fd5b506040516178f43803806178f4833981810160405281019061003191906107eb565b5f8282604051602001610045929190610838565b60405160208183030381529060405290506100658161006d60201b60201c565b50505061095f565b5f61007c61024360201b60201c565b90505f815f0160089054906101000a900460ff161590505f825f015f9054906101000a900467ffffffffffffffff1690505f808267ffffffffffffffff161480156100c45750825b90505f60018367ffffffffffffffff161480156100f757505f3073ffffffffffffffffffffffffffffffffffffffff163b145b905081158015610105575080155b1561013c576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001855f015f6101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055508315610189576001855f0160086101000a81548160ff0219169083151502179055505b6101983361026a60201b60201c565b5f80878060200190518101906101ae919061089a565b915091506101c18161028a6...

If this is not a known issue, as I could not find this in issue search, I can set up a repo to reproduce.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions