From c3ac297b2b0fb59dd93274cb48fa05de9c5c6418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 19 May 2017 14:31:52 +0200 Subject: [PATCH] Fix some issues around STATICCALL implementation --- libethereum/Executive.cpp | 2 +- libevm/VM.cpp | 16 ++++++++-------- libevm/VMCalls.cpp | 5 +++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libethereum/Executive.cpp b/libethereum/Executive.cpp index 38cf0c93f2e..25f31847322 100644 --- a/libethereum/Executive.cpp +++ b/libethereum/Executive.cpp @@ -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); } diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 857b0a27c5a..ede4a0dedbe 100755 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -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; @@ -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); @@ -348,7 +348,7 @@ void VM::interpretCases() CASE(LOG0) { - if (m_schedule->haveStaticCall && m_ext->staticCall) + if (m_ext->staticCall) throwDisallowedStateChange(); logGasMem(); @@ -361,7 +361,7 @@ void VM::interpretCases() CASE(LOG1) { - if (m_schedule->haveStaticCall && m_ext->staticCall) + if (m_ext->staticCall) throwDisallowedStateChange(); logGasMem(); @@ -374,7 +374,7 @@ void VM::interpretCases() CASE(LOG2) { - if (m_schedule->haveStaticCall && m_ext->staticCall) + if (m_ext->staticCall) throwDisallowedStateChange(); logGasMem(); @@ -387,7 +387,7 @@ void VM::interpretCases() CASE(LOG3) { - if (m_schedule->haveStaticCall && m_ext->staticCall) + if (m_ext->staticCall) throwDisallowedStateChange(); logGasMem(); @@ -400,7 +400,7 @@ void VM::interpretCases() CASE(LOG4) { - if (m_schedule->haveStaticCall && m_ext->staticCall) + if (m_ext->staticCall) throwDisallowedStateChange(); logGasMem(); @@ -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]) diff --git a/libevm/VMCalls.cpp b/libevm/VMCalls.cpp index 2c593fe5a74..056d83b5574 100755 --- a/libevm/VMCalls.cpp +++ b/libevm/VMCalls.cpp @@ -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); @@ -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)