Skip to content

Commit

Permalink
Issue warning if codesize exceeds EIP-170 limits
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Dec 19, 2019
1 parent 2b3a9d7 commit 2a1615d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
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
14 changes: 14 additions & 0 deletions libsolidity/interface/CompilerStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,20 @@ void CompilerStack::compileContract(
solAssert(false, "Assembly exception for deployed bytecode");
}

// Throw an error if EIP-170 limits are exceeded:
// Of 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(
"Contract code size exceeds 24576 bytes (a limit introduced in Spurious Dragon). "
"This contract may not be deployable on mainnet. "
"Consider enabling the optimzer (with a low \"runs\" value!), "
"turning off revert strings, or using libraries."
);

_otherCompilers[compiledContract.contract] = compiler;
}

Expand Down
Loading

0 comments on commit 2a1615d

Please sign in to comment.