Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
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 libevm/VM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void VM::interpretCases()

// After EIP150 hard fork charge additional cost of sending
// ethers to non-existing account.
if (!m_schedule->staticCallDepthLimit && !m_ext->exists(dest))
if (m_schedule->suicideChargesNewAccountGas() && !m_ext->exists(dest))
m_runGas += m_schedule->callNewAccountGas;
Copy link
Member

Choose a reason for hiding this comment

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

was this change spec'd in the yellow paper? i don't remember seeing it implemented in geth


onOperation();
Expand Down
11 changes: 5 additions & 6 deletions libevm/VMCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ void VM::caseCreate()
uint64_t initOff = (uint64_t)*m_sp--;
uint64_t initSize = (uint64_t)*m_sp--;

bool depthOk = m_schedule->staticCallDepthLimit ? m_ext->depth < 1024 : true;
bool depthOk = m_schedule->staticCallDepthLimit() ? m_ext->depth < 1024 : true;
if (m_ext->balance(m_ext->myAddress) >= endowment && depthOk)
{
u256 createGas = *m_io_gas;
if (!m_schedule->staticCallDepthLimit)
if (!m_schedule->staticCallDepthLimit())
createGas -= createGas / 64;
u256 gas = createGas;
*++m_sp = (u160)m_ext->create(endowment, gas, bytesConstRef(m_mem.data() + initOff, initSize), *m_onOp);
Expand Down Expand Up @@ -155,9 +155,8 @@ bool VM::caseCallSetup(CallParameters *callParams)
// "Static" costs already applied. Calculate call gas.
u256 requestedCallGas = *m_sp;
u256 maxAllowedCallGas = *m_io_gas - *m_io_gas / 64;
u256 callGas = m_schedule->staticCallDepthLimit
? requestedCallGas
: std::min(requestedCallGas, maxAllowedCallGas);
u256 callGas = m_schedule->staticCallDepthLimit() ? requestedCallGas :
std::min(requestedCallGas, maxAllowedCallGas);
m_runGas = toUint64(callGas);
onOperation();
updateIOGas();
Expand Down Expand Up @@ -186,7 +185,7 @@ bool VM::caseCallSetup(CallParameters *callParams)
uint64_t outOff = (uint64_t)*m_sp--;
uint64_t outSize = (uint64_t)*m_sp--;

bool depthOk = m_schedule->staticCallDepthLimit ? m_ext->depth < 1024 : true;
bool depthOk = m_schedule->staticCallDepthLimit() ? m_ext->depth < 1024 : true;
if (m_ext->balance(m_ext->myAddress) >= callParams->valueTransfer && depthOk)
{
callParams->onOp = *m_onOp;
Expand Down
7 changes: 5 additions & 2 deletions libevmcore/EVMSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct EVMSchedule
EVMSchedule(bool _efcd, bool _hdc, unsigned const& _txCreateGas): exceptionalFailedCodeDeposit(_efcd), haveDelegateCall(_hdc), tierStepGas(std::array<unsigned, 8>{{0, 2, 3, 5, 8, 10, 20, 0}}), txCreateGas(_txCreateGas) {}
bool exceptionalFailedCodeDeposit = true;
bool haveDelegateCall = true;
bool staticCallDepthLimit = true;
bool eip150Mode = false;
unsigned stackLimit = 1024;
std::array<unsigned, 8> tierStepGas;
unsigned expGas = 10;
Expand Down Expand Up @@ -70,6 +70,9 @@ struct EVMSchedule
unsigned extcodecopyGas = 20;
unsigned balanceGas = 20;
unsigned suicideGas = 0;

bool staticCallDepthLimit() const { return !eip150Mode; }
bool suicideChargesNewAccountGas() const { return eip150Mode; }
};

static const EVMSchedule DefaultSchedule = EVMSchedule();
Expand All @@ -80,7 +83,7 @@ static EVMSchedule EVMScheduleEIP150()
{
//EIP150
EVMSchedule schedule = HomesteadSchedule;
schedule.staticCallDepthLimit = false;
schedule.eip150Mode = true;
schedule.extcodesizeGas = 700;
schedule.extcodecopyGas = 700;
schedule.balanceGas = 400;
Expand Down