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

Commit

Permalink
Fix some issues around STATICCALL implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed May 22, 2017
1 parent 2b5f678 commit c3ac297
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion libethereum/Executive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ bool Executive::execute()

bool Executive::call(Address _receiveAddress, Address _senderAddress, u256 _value, u256 _gasPrice, bytesConstRef _data, u256 _gas)
{
CallParameters params(_senderAddress, _receiveAddress, _receiveAddress, _value, _value, _gas, _data, {});
CallParameters params{_senderAddress, _receiveAddress, _receiveAddress, _value, _value, _gas, _data, {}};
return call(params, _gasPrice, _senderAddress);
}

Expand Down
16 changes: 8 additions & 8 deletions libevm/VM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void VM::interpretCases()

CASE(CREATE)
{
if (m_schedule->haveStaticCall && m_ext->staticCall)
if (m_ext->staticCall)
throwDisallowedStateChange();

m_bounce = &VM::caseCreate;
Expand Down Expand Up @@ -270,7 +270,7 @@ void VM::interpretCases()

CASE(SUICIDE)
{
if (m_schedule->haveStaticCall && m_ext->staticCall)
if (m_ext->staticCall)
throwDisallowedStateChange();

m_runGas = toInt63(m_schedule->suicideGas);
Expand Down Expand Up @@ -348,7 +348,7 @@ void VM::interpretCases()

CASE(LOG0)
{
if (m_schedule->haveStaticCall && m_ext->staticCall)
if (m_ext->staticCall)
throwDisallowedStateChange();

logGasMem();
Expand All @@ -361,7 +361,7 @@ void VM::interpretCases()

CASE(LOG1)
{
if (m_schedule->haveStaticCall && m_ext->staticCall)
if (m_ext->staticCall)
throwDisallowedStateChange();

logGasMem();
Expand All @@ -374,7 +374,7 @@ void VM::interpretCases()

CASE(LOG2)
{
if (m_schedule->haveStaticCall && m_ext->staticCall)
if (m_ext->staticCall)
throwDisallowedStateChange();

logGasMem();
Expand All @@ -387,7 +387,7 @@ void VM::interpretCases()

CASE(LOG3)
{
if (m_schedule->haveStaticCall && m_ext->staticCall)
if (m_ext->staticCall)
throwDisallowedStateChange();

logGasMem();
Expand All @@ -400,7 +400,7 @@ void VM::interpretCases()

CASE(LOG4)
{
if (m_schedule->haveStaticCall && m_ext->staticCall)
if (m_ext->staticCall)
throwDisallowedStateChange();

logGasMem();
Expand Down Expand Up @@ -1116,7 +1116,7 @@ void VM::interpretCases()

CASE(SSTORE)
{
if (m_schedule->haveStaticCall && m_ext->staticCall)
if (m_ext->staticCall)
throwDisallowedStateChange();

if (!m_ext->store(m_SP[0]) && m_SP[1])
Expand Down
5 changes: 3 additions & 2 deletions libevm/VMCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ bool VM::caseCallSetup(CallParameters *callParams, bytesRef& o_output)

callParams->staticCall = (m_OP == Instruction::STATICCALL || m_ext->staticCall);

if ((m_OP == Instruction::CALL || m_OP == Instruction::STATICCALL) && !m_ext->exists(asAddress(m_SP[1])))
Address destinationAddr = asAddress(m_SP[1]);
if (m_OP == Instruction::CALL && !m_ext->exists(destinationAddr))
if (m_SP[2] > 0 || m_schedule->zeroValueTransferChargesNewAccountGas())
m_runGas += toInt63(m_schedule->callNewAccountGas);

Expand Down Expand Up @@ -230,7 +231,7 @@ bool VM::caseCallSetup(CallParameters *callParams, bytesRef& o_output)
if (m_OP != Instruction::DELEGATECALL && m_SP[2] > 0)
callParams->gas += m_schedule->callStipend;

callParams->codeAddress = asAddress(m_SP[1]);
callParams->codeAddress = destinationAddr;

unsigned inOutOffset = 0;
if (m_OP == Instruction::DELEGATECALL || m_OP == Instruction::STATICCALL)
Expand Down

0 comments on commit c3ac297

Please sign in to comment.