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

EIP214: STATICCALL #4057

Merged
merged 6 commits into from
May 24, 2017
Merged

EIP214: STATICCALL #4057

merged 6 commits into from
May 24, 2017

Conversation

yann300
Copy link
Contributor

@yann300 yann300 commented Apr 24, 2017

@yann300 yann300 changed the title EIP214 - STATICCALL EIP214 - STATICCALL [WIP] Apr 24, 2017
@codecov-io
Copy link

codecov-io commented Apr 24, 2017

Codecov Report

Merging #4057 into develop will decrease coverage by 0.17%.
The diff coverage is 64.28%.

@@            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
Impacted Files Coverage Δ
libevmcore/Instruction.cpp 38.46% <ø> (-9.04%) ⬇️
libevm/VM.h 76.92% <ø> (ø) ⬆️
libevmcore/Instruction.h 100% <ø> (ø) ⬆️
libevm/VMFace.h 84.61% <0%> (-7.06%) ⬇️
libevmcore/EVMSchedule.h 100% <100%> (ø) ⬆️
libevm/ExtVMFace.h 80% <100%> (-0.31%) ⬇️
libethereum/Executive.cpp 57.43% <100%> (ø) ⬆️
libethereum/ExtVM.h 100% <100%> (ø) ⬆️
libevm/ExtVMFace.cpp 100% <100%> (ø) ⬆️
test/tools/jsontests/vm.cpp 65.51% <100%> (ø) ⬆️
... and 28 more

@chfast chfast changed the title EIP214 - STATICCALL [WIP] EIP214: STATICCALL Apr 24, 2017
@chfast chfast added this to the Metropolis milestone Apr 24, 2017
libevm/VM.cpp Outdated
@@ -214,19 +214,25 @@ void VM::interpretCases()

CASE(CREATE)
{
if (m_schedule->haveStaticCall && m_ext->staticCall)
throwBadInstruction();
Copy link
Member

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
Copy link
Member

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.

@chfast
Copy link
Member

chfast commented Apr 25, 2017

clang has showed an important issue. We missed something...

@@ -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;
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed.

@@ -201,6 +201,7 @@ struct CallParameters
u256 apparentValue;
u256 gas;
bytesConstRef data;
bool staticCall;
Copy link
Member

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.

chfast
chfast previously approved these changes Apr 25, 2017
Copy link
Member

@chfast chfast left a 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)
Copy link
Member

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 😄

Copy link
Member

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.

@winsvega
Copy link
Contributor

CALLDATA for staticcall is not transfered to the subcall
strange gasUsed count when using different values for memory arguments of STATICCALL

@chfast chfast dismissed their stale review May 19, 2017 11:24

Obsolate

@chfast
Copy link
Member

chfast commented May 19, 2017

Do you want me to help with rebase and cleaning up the history?

@@ -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, {});
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

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])))
Copy link
Member

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.

Copy link
Member

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){}
Copy link
Member

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)
Copy link
Contributor

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.

Copy link
Member

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???

Copy link
Member

@pirapira pirapira May 19, 2017

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.

Copy link
Member

Choose a reason for hiding this comment

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

@chriseth
Copy link
Contributor

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?

@chfast
Copy link
Member

chfast commented May 19, 2017

@chriseth, it might be hard because we don't update the state root until the end of a transaction.

@winsvega
Copy link
Contributor

winsvega commented May 19, 2017

we could check that state root is not changed in tests.
although in most tests I call staticcall after I've already changed something in state. otherwise it is not clear if the test has worked or not

@chfast chfast merged commit 49cdc48 into develop May 24, 2017
@chfast chfast deleted the staticcall branch May 24, 2017 11:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants