Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Limit code size (EIP170). #3410

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 3 additions & 1 deletion libethereum/Executive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ bool Executive::go(OnOpFunc const& _onOp)
m_res->gasForDeposit = m_gas;
m_res->depositSize = out.size();
}
if (out.size() * m_ext->evmSchedule().createDataGas <= m_gas)
if (out.size() > m_ext->evmSchedule().maxCodeSize)
BOOST_THROW_EXCEPTION(OutOfGas());
else if (out.size() * m_ext->evmSchedule().createDataGas <= m_gas)
{
if (m_res)
m_res->codeDeposit = CodeDeposit::Success;
Expand Down
2 changes: 2 additions & 0 deletions libevmcore/EVMSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct EVMSchedule
unsigned extcodecopyGas = 20;
unsigned balanceGas = 20;
unsigned suicideGas = 0;
unsigned maxCodeSize = unsigned(-1);

bool staticCallDepthLimit() const { return !eip150Mode; }
bool suicideChargesNewAccountGas() const { return eip150Mode; }
Expand All @@ -89,6 +90,7 @@ static const EVMSchedule EIP150Schedule = []
schedule.sloadGas = 200;
schedule.callGas = 700;
schedule.suicideGas = 5000;
schedule.maxCodeSize = 0x6000;
return schedule;
}();

Expand Down