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

Issue warning if codesize exceeds EIP-170 limits #8008

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Language Features:


Compiler Features:

* General: Raise warning if runtime bytecode exceeds 24576 bytes (a limit introduced in Spurious Dragon).

Bugfixes:

Expand Down
15 changes: 15 additions & 0 deletions libsolidity/interface/CompilerStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,21 @@ void CompilerStack::compileContract(
solAssert(false, "Assembly exception for deployed bytecode");
}

// Throw a warning if EIP-170 limits are exceeded:
// If contract creation initialization returns data with length of more than 0x6000 (214 + 213) bytes,
// contract creation fails with an out of gas error.
if (
m_evmVersion >= langutil::EVMVersion::spuriousDragon() &&
compiledContract.runtimeObject.bytecode.size() > 0x6000
)
m_errorReporter.warning(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we turn this into an error? If yes, what kind?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen people using Ganache with allowUnlimitedContractSize during development, and enabling optimizations when their contracts are ready. While this workflow seems risky to me, it apparently works. Making this an error would prevent them from using this workflow, so I think a warning is the right choice here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the reason to turn this into an error. We actually don't know which chain we are compiling for.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well EVM Version supposed to specify this, isn't it? At least in the past there was correlation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do not go all the way to code generation, you will not see an error. Then, if you request the bytecode, suddenly an errors appears. This could be weird.

_contract.location(),
"Contract code size exceeds 24576 bytes (a limit introduced in Spurious Dragon). "
"This contract may not be deployable on mainnet. "
"Consider enabling the optimizer (with a low \"runs\" value!), "
ekpyron marked this conversation as resolved.
Show resolved Hide resolved
"turning off revert strings, or using libraries."
);

_otherCompilers[compiledContract.contract] = compiler;
}

Expand Down
Loading