foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.31k stars 1.75k forks source link

Extra output `evm.legacyAssembly` is ignored #8977

Closed RaoulSchaffranek closed 1 month ago

RaoulSchaffranek commented 1 month ago

Component

Forge

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

What version of Foundry are you on?

forge 0.2.0 (9dbfb2f 2024-09-27T00:20:26.127318148Z)

What command(s) is the bug in?

forge build

Operating System

Linux

Describe the bug

Compiling with the extra output option evm.legacyAssembly has no effect. Unfortunately, this breaks the only reliable way to get the metadata hash of the contracts - which are needed for source code verification and source mapping (see: https://docs.sourcify.dev/blog/finding-auxdatas-in-bytecode/#workarounds for more details).

Reproduction steps:

forge init
FOUNDRY_EXTRA_OUTPUT = '["evm.legacyAssembly", "storageLayout"]' forge build --build-info

The storageLayout is not required and is only added as a sanity check here.

Open the build info file. Notice, that evm.legacyAssembly is missing in the output selection and the legacyAssembly-field is missing from output[source][contract].evm:

{
    "input": {
        "settings": {
            "ouptputSelection": {
                "lib/forge-std/src/Base.sol": {
                    "*": [
                        "abi",
                        "evm.bytecode",
                        "evm.deployedBytecode",
                        "evm.methodIdentifiers",
                        "metadata",
                        "storageLayout"
                        // "evm.legacyAssembly" is missing here
                    ]
                }
            }
        }
    },
    "output": {
        "contracts":
            "lib/forge-std/src/Base.sol": {
                "Script": {
                    "evm": {
                         // "legacyAssembly": { ... } is missing here
                    }
                }
            }
        }
    }       
}
grandizzy commented 1 month ago

Hey @RaoulSchaffranek I dont think that can be set with env var (see https://book.getfoundry.sh/reference/config/solidity-compiler#extra_output where env is N/A) could you try adding it in foundry.toml?

RaoulSchaffranek commented 1 month ago

The environment variable FOUNDRY_EXTRA_OUTPUT generally works; otherwise, the storageLayout would also be missing from the outputSelection. I just double-checked and tried setting extra_output = ["storageLayout", "evm.legacyAssembly"] in foundry.toml - the behavior is the same as with the env var: storageLayout yay, evm.legacyAssembly nay.