Missing bytecode size warnings for EIP-3860 and in Yul/EVM asm mode
There are currently two limits on the bytecode size on mainnet:
- 24576 bytes for runtime code, introduced by EIP-170: Contract code size limit in
spuriousDragon. - 49152 bytes for initcode, introduced by EIP-3860: Limit and meter initcode in
shanghai.
The compiler emits warnings only when the first one is exceeded and then only when compiling Solidity (i.e. not Yul or imported EVM assembly). If the warning is useful, we should emit it in both cases and in all input modes.
This was discussed on the call yesterday. We decided we should add the warnings, though the priority is low. No one complained about missing them so far and I think frameworks already check these limits before deployment.
Hello @cameel , i was trying to get familiar with the codebase and the issue . Please let me know if i can work on this and am i on right track. https://github.com/ethereum/solidity/blob/a65229279d769a7b2936aef2aa802d77abbdc343/libsolidity/interface/CompilerStack.cpp#L1492 The warnings for EIP-170 (24576 bytes for runtime code) and EIP-3860 (49152 bytes for initcode) already exist in CompilerStack.cpp(lines mentioned above). These warnings are currently only emitted for Solidity code but not for Yul or EVM assembly.
https://github.com/furmak331/solidity/blob/a65229279d769a7b2936aef2aa802d77abbdc343/libyul/backends/evm/EVMObjectCompiler.cpp#L128
In EVMObjectCompiler.cpp, the run() function processes Yul objects and generates EVM bytecode via CodeTransform transform() . Since m_assembly holds the final bytecode, I’m trying to add the size warnings right after transform() completes.
Is that how we should proceed?