ethereum/solidity

Option to disable metadata

axic opened this issue · 6 comments

axic commented

Currently the compiler will always include the metadata at the end of runtime + initcode. The metadata consists of version, hash, and potentially the experimental flag.

In the pipeline the only flag we have is to disable the inclusion of the hash, but the version field is always included.

While I really like having this there, removing it from the runtime code becomes quite challenging, because one needs to dissect the initcode. Why would someone remove the metadata? To pass code purity checks.

How should it look like? There is already the function setMetadataFormat which lets you set one of WithReleaseVersionTag, WithPrereleaseVersionTag and NoMetadata. I think the cli / standard-json flag should just be a switch. Append metadata or not.

Should it be --no-append-metadata similar to --no-color or --no-optimize-yul?

Just as an alternative suggestion: An option to output the exact byte location so it can be ignored or further processed by other tools? Actually, don't have we have some kind of location map for that already?

axic commented

An option to output the exact byte location so it can be ignored or further processed by other tools? Actually, don't have we have some kind of location map for that already?

It can't work as the constructor/initcode has the offset/length embedded, and also immutables can influences sizes. It just can't be truncated without modifying the initcode.

How should it look like? There is already the function setMetadataFormat which lets you set one of WithReleaseVersionTag, WithPrereleaseVersionTag and NoMetadata. I think the cli / standard-json flag should just be a switch. Append metadata or not.

Should it be --no-append-metadata similar to --no-color or --no-optimize-yul?

What does NoMetadata currently do?

@leonardoalt actually removes the metadata. It seems to be only used in tests.

Ah so it's not exported? Yea --no-append-metadata sounds good.