Closed chriseth closed 4 years ago
We could introduce a new kind of exception instead of assert.
Also, this should depend on the target EVM version (#1117).
Just like #411, perhaps it is better to implement this in the Remix static analyzer. @yann300 @soad003 what do you think?
Duping https://github.com/ethereum/solidity/issues/7913
In addition to the warning, which would be easy to add, I also request a flag to ask the compiler to attempt to constrain code size.
It is also possible to workaround size limit via delegatecall by deploying part of the code to another contract during construction. The primary contract would delegatecall to a secondary contract as its fallback function. This can chain infinitely, leveraging the fact that calldata can be larger than max contract size.
For the current block gas limit, it would be possible to do 2 full-sized contracts in this way, but a larger block gas limit might empower more in the future.
I've seen many people hitting the EIP-170 contract size limit lately. Some examples of projects that come to my mind are Aragon Court, Synthetix, and Moloch v2.
I don't know if this is due to a change in Solidity, or because contracts are just getting larger, but this feature would be very helpful. Many users just see an OOG error and don't understand what's going on, so a warning when compiling would help.
I know this could be implemented in each tool (e.g. truffle, remix, embark, buidler, etc), but I think implementing it as a solc warning would be the simplest path to improve the situation for most users.
@alcuadrado please check #8008 and the warning it produces. I think that should be good enough.
Wow, that was fast! Thanks @axic
The reason why we did not implement this in the beginning is because the complier should not issue any warnings after the analysis phase. I'm ok with dropping this requirement, if this is what people want, though.
Contract bytecode cannot exceed
0x6000
bytes (introduced with EIP-170 in Spurious Dragon) and the compiler should warn about this. Unfortunately, this cannot be a "regular" error since those have to be generated before code-generation is started. This is similar to warning about a fallback function taking too much gas: https://github.com/ethereum/solidity/issues/411