-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4057 +/- ##
==========================================
- Coverage 65.87% 65.7% -0.18%
==========================================
Files 308 308
Lines 22913 22808 -105
==========================================
- Hits 15095 14986 -109
- Misses 7818 7822 +4
|
libevm/VM.cpp
Outdated
@@ -214,19 +214,25 @@ void VM::interpretCases() | |||
|
|||
CASE(CREATE) | |||
{ | |||
if (m_schedule->haveStaticCall && m_ext->staticCall) | |||
throwBadInstruction(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be throwDisallowedStateChange()
.
libevm/VM.cpp
Outdated
CASE(CALL) | ||
CASE(CALLCODE) | ||
{ | ||
// Pre-homestead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment. It does not provided any information any more, as we are so used to hard-forks.
clang has showed an important issue. We missed something... |
libethereum/ExtVM.h
Outdated
@@ -94,6 +94,7 @@ class ExtVM: public ExtVMFace | |||
private: | |||
State& m_s; ///< A reference to the base state. | |||
SealEngineFace const& m_sealEngine; | |||
bool m_staticCall; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed.
libevm/ExtVMFace.h
Outdated
@@ -201,6 +201,7 @@ struct CallParameters | |||
u256 apparentValue; | |||
u256 gas; | |||
bytesConstRef data; | |||
bool staticCall; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize it here too: bool staticCall = false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. @winsvega can you generate tests for this PR to check them before merging this.
libevm/VM.cpp
Outdated
@@ -214,19 +214,24 @@ void VM::interpretCases() | |||
|
|||
CASE(CREATE) | |||
{ | |||
if (m_schedule->haveStaticCall && m_ext->staticCall) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need a check for m_schedule->haveStaticCall
here and in other places?
I think it's redundant, it can't be a static call if don't have it 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Keep only m_ext->staticCall
check.
You can add before if
: assert(!staticCall || haveStaticCall)
which checks implication staticCall => haveStaticCall
.
CALLDATA for staticcall is not transfered to the subcall |
Do you want me to help with rebase and cleaning up the history? |
libethereum/Executive.cpp
Outdated
@@ -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, {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be unnecessary change.
libevm/VM.cpp
Outdated
@@ -214,19 +214,24 @@ void VM::interpretCases() | |||
|
|||
CASE(CREATE) | |||
{ | |||
if (m_schedule->haveStaticCall && m_ext->staticCall) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Keep only m_ext->staticCall
check.
You can add before if
: assert(!staticCall || haveStaticCall)
which checks implication staticCall => haveStaticCall
.
libevm/VM.cpp
Outdated
@@ -265,6 +270,9 @@ void VM::interpretCases() | |||
|
|||
CASE(SUICIDE) | |||
{ | |||
if (m_schedule->haveStaticCall && m_ext->staticCall) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
libevm/VM.cpp
Outdated
@@ -340,6 +348,9 @@ void VM::interpretCases() | |||
|
|||
CASE(LOG0) | |||
{ | |||
if (m_schedule->haveStaticCall && m_ext->staticCall) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
libevm/VMCalls.cpp
Outdated
if (m_OP == Instruction::CALL && !m_ext->exists(asAddress(m_SP[1]))) | ||
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]))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
STATICCALL does not have a value argument, so this check does not apply to it.
cc @pirapira.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right.
@@ -178,6 +178,7 @@ BOOST_AUTO_TEST_CASE(stRevertTest){} | |||
|
|||
//Metropolis Tests | |||
BOOST_AUTO_TEST_CASE(stStackTests){} | |||
BOOST_AUTO_TEST_CASE(stStaticCall){} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@winsvega you forgot to update jsontests.
if (m_SP[2] > 0 || m_schedule->zeroValueTransferChargesNewAccountGas()) | ||
m_runGas += toInt63(m_schedule->callNewAccountGas); | ||
|
||
if (m_OP != Instruction::DELEGATECALL && m_SP[2] > 0) | ||
if ((m_OP == Instruction::CALL || m_OP == Instruction::CALLCODE) && m_SP[2] > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope this won't get us into trouble: We change for value transfer for callcode, although we do not consider it state changing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the test case for this???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CALLCODE with positive value transfer... probably we already have it... but worth trying during STATICCALL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test case in the Metropolis testing table https://docs.google.com/spreadsheets/d/1xat7UI8GtB4ZGVdlK5_XQSHJZaMThi4SrlcL8XMZb5Q/edit#gid=1412823514&range=C21
Does it make sense to add a check somewhere which verifies that the state root is unchanged after a staticcall? Is that possible from an architectural standpoint? |
@chriseth, it might be hard because we don't update the state root until the end of a transaction. |
we could check that state root is not changed in tests. |
Resolves #3616.
ethereum/EIPs#214