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

Commit

Permalink
Limit code size (EIP170).
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth committed Nov 11, 2016
1 parent f577396 commit 6dc60bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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
4 changes: 4 additions & 0 deletions libevmcore/EVMSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include <libdevcore/Common.h>

#include <cstdint>

namespace dev
{
namespace eth
Expand Down Expand Up @@ -69,6 +71,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 +92,7 @@ static const EVMSchedule EIP150Schedule = []
schedule.sloadGas = 200;
schedule.callGas = 700;
schedule.suicideGas = 5000;
schedule.maxCodeSize = 23999;
return schedule;
}();

Expand Down

0 comments on commit 6dc60bd

Please sign in to comment.