Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning or error if code is too large #2100

Closed
chriseth opened this issue Mar 30, 2017 · 9 comments · Fixed by #8008
Closed

Warning or error if code is too large #2100

chriseth opened this issue Mar 30, 2017 · 9 comments · Fixed by #8008
Assignees

Comments

@chriseth
Copy link
Contributor

chriseth commented Mar 30, 2017

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: #411

@axic
Copy link
Member

axic commented Mar 30, 2017

We could introduce a new kind of exception instead of assert.

Also, this should depend on the target EVM version (#1117).

@axic axic added the feature label Apr 17, 2018
@axic axic removed the accepted label Aug 1, 2018
@axic
Copy link
Member

axic commented Mar 21, 2019

Just like #411, perhaps it is better to implement this in the Remix static analyzer. @yann300 @soad003 what do you think?

@axic axic mentioned this issue Dec 6, 2019
@wjmelements
Copy link
Contributor

Duping #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.

@wjmelements
Copy link
Contributor

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.

@wjmelements
Copy link
Contributor

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.

@alcuadrado
Copy link
Member

alcuadrado commented Dec 13, 2019

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.

@axic
Copy link
Member

axic commented Dec 13, 2019

@alcuadrado please check #8008 and the warning it produces. I think that should be good enough.

@alcuadrado
Copy link
Member

Wow, that was fast! Thanks @axic

@chriseth
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants