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

EIP150 version1-1c gasPrice change proposal #3345

Merged
merged 2 commits into from
Oct 19, 2016
Merged

EIP150 version1-1c gasPrice change proposal #3345

merged 2 commits into from
Oct 19, 2016

Conversation

winsvega
Copy link
Contributor

@winsvega winsvega commented Oct 11, 2016

Implements http://github.com/ethereum/EIPs/issues/150
connects to #3343

  • squash commits and rebase on top of develop
  • fix scripts/test.sh and test.bat back to develop branch
  • changes in gas costs
  • define transition block for the main network
  • the 63/64 rule for limiting the call stack
  • test for the gas cost changes
  • test for 63/64 call gas rules
  • If SUICIDE or CALLCODE hits a newly created account, it triggers an additional gas cost of 25000 (similar to CALLs)

moved from #3344

if (_envInfo.number() >= chainParams().u256Param("frontierCompatibilityModeLimit"))
return HomesteadSchedule;
if (_envInfo.number() >= chainParams().u256Param("EIP150forkBlock"))
return DevconSchedule;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make a consistent change for EIP150, that is its proper name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why git does not update this comment?
code has been updated to use EIP150Schedule

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 an issue with the new GitHub review interface. On this page it shows old comments even the code has been already changed. It is better to see all changes in https://github.com/ethereum/cpp-ethereum/pull/3345/files.

else
return FrontierSchedule;
if (_envInfo.number() >= chainParams().u256Param("frontierCompatibilityModeLimit"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we break anything if we change this to homsteadForkBlock? It would be a bit more consistent.

Copy link
Contributor Author

@winsvega winsvega Oct 12, 2016

Choose a reason for hiding this comment

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

in eth when parsing json config this field is called frontierCompatibilityModeLimit
other then that its fine

@@ -119,6 +119,7 @@ R"E(
"accountStartNonce": "0x00",
"frontierCompatibilityModeLimit": "0xffffffffffffffff",
"daoHardforkBlock": "0xfffffffffffffff",
"EIP150forkBlock": "0xfffffffffffffff",
Copy link
Contributor

Choose a reason for hiding this comment

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

CamelCase would be EIP150ForkBlock

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

{
auto createGas = *m_io_gas;
if (m_schedule->isEIP150())
createGas -= createGas / 64;
Copy link
Contributor

@chriseth chriseth Oct 12, 2016

Choose a reason for hiding this comment

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

There is no agreement on this yet, right?

Copy link
Member

Choose a reason for hiding this comment

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

From 1b: "CREATE only provides 63/64 of the parent gas, rounded down, to the child call." It must be like that if we want to replace static call depth limit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Specification has changed to this in the meantime.

bool depthOk = m_schedule->isEIP150() ? true : m_ext->depth < 1024;
if (m_ext->balance(m_ext->myAddress) >= endowment && depthOk)
{
auto createGas = *m_io_gas;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use auto here.

Copy link
Member

Choose a reason for hiding this comment

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

I mostly agree. However, in case of u256 createGas = *m_io_gas if we change m_io_gas to int64_t later on we will not auto notice the implicit conversion here. auto guarantees not conversion.

I will switch to explicit types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

auto createGas = *m_io_gas;
if (m_schedule->isEIP150())
createGas -= createGas / 64;
auto gas = createGas;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use auto here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -142,10 +150,18 @@ bool VM::caseCallSetup(CallParameters *callParams)
memNeed(m_stack[(1 + m_sp - m_stack) - sizesOffset], m_stack[(1 + m_sp - m_stack) - sizesOffset - 1])
);
updateMem();
updateIOGas();

// "Static" const already applied. Calculate call gas.
Copy link
Contributor

Choose a reason for hiding this comment

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

const -> cost

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


// "Static" const already applied. Calculate call gas.
auto requestedCallGas = *m_sp;
auto maxAllowedCallGas = *m_io_gas - *m_io_gas / 64;
Copy link
Contributor

Choose a reason for hiding this comment

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

Again: Please don't use auto here. Note that m_runGas is a 64 bit variable and m_io_gas is a 256 bit variable. auto completely hides this fact and might introduce performance and correctness issues.

Also, perhaps less confusing:

auto maxAllowedCallGas = *m_io_gas - (m_schedule->isEIP150() ? *m_io_gas / 64 : 0);
auto callGas = std::min(requestedCallGas, maxAllowedCallGas);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

unsigned balanceGas = 20;
unsigned suicideGas = 0;

bool isEIP150() const { return callGas == 700; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously, we had booleans to trigger certain behaviour, so I think it would be better to replace this by
bool staticCallDepthLimit = true, set the value to false for the EVMScheduleEIP150 and replace all current calls to isEIP150() by !staticCallDepthLimit.

Copy link
Member

Choose a reason for hiding this comment

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

I would avoid having redundant data in the schedule struct. But you suggestion looks fine. I would be even better to have unsinged callDepthLimit equal 1024 or 0. Now we have this magic number in many places. But this should not go with this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

yep, good suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to

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

}
},
"pre" : {
"d4fe7bc31cedb7bfb8a345f31e668033056b2728" : { "balance" : "1000000", "nonce" : "0", "code" : "", "storage": {} },
Copy link
Contributor

Choose a reason for hiding this comment

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

Please explain why we need so many accounts. Furthermore, the name of the test suggests that it tests all aspects of EIP150 although I would say it only tests one particular thing (testing all aspects in one test is also not good testing practice).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is transition test. it includes daohardfork.
I think to implement more scenarious in StateTests
things are in rush now. we started with simple blockchain test that is now too complicated .


// After EIP150 hard fork charge additional cost of sending
// ethers to non-existing account.
if (!m_schedule->staticCallDepthLimit && !m_ext->exists(dest))
Copy link
Contributor

Choose a reason for hiding this comment

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

This requires a new bool, charging callNewAccountGas here is different from staticCallDepthLimit.
To get both readability and non-redundancy, I would suggest the following:

Add two inline functions to the schedule: staticCallDepthLimit and suicideChargesNewAccountGas and replace the staticCallDepthLimit by a bool member that is called eip150Mode and let the two inline function return the respective values depending on that member.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

u256 requestedCallGas = *m_sp;
u256 maxAllowedCallGas = *m_io_gas - *m_io_gas / 64;
u256 callGas = m_schedule->staticCallDepthLimit
? requestedCallGas
Copy link
Contributor

Choose a reason for hiding this comment

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

Coding style: separators should go to the end of the line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -35,6 +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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

{
//EIP150
EVMSchedule schedule = HomesteadSchedule;
schedule.staticCallDepthLimit = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@axic
Copy link
Member

axic commented Oct 12, 2016

(Why is it called EIP150 and not ERC150?)

RE: because of the ethereum/EIPs#150

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

Choose a reason for hiding this comment

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

As commented on an earlier version: I think it confusing to call this maxAllowedCallGas even if it is not an upper bound in all code paths.

@chriseth
Copy link
Contributor

@winsvega we do have tests for "63/64 call gas rules", right? If yes, please update description.

@winsvega
Copy link
Contributor Author

"63/64 call gas rules"
not yet. we need more tests for that

@axic
Copy link
Member

axic commented Oct 13, 2016

@winsvega yep, the repo is called EIP, but mostly those not accepted (= part of the repo and not the issues), were referred to as ERC (Ethereum Request for Comments)

RE: ethereum/EIPs#150

@chriseth
Copy link
Contributor

@winsvega please set the hard fork block to 2457000 and then I think this is ready to go.
Please focus on adding tests to the general test suite (not the cpp-specific one).

@winsvega winsvega changed the title EIP150 version1 gasPrice change proposal EIP150 version1-1c gasPrice change proposal Oct 17, 2016
@winsvega
Copy link
Contributor Author

chriseth, rebase on top of the current develop branch is needed

@chriseth
Copy link
Contributor

@winsvega some tests are failing, please investigate.

Copy link
Contributor

@chriseth chriseth left a comment

Choose a reason for hiding this comment

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

Please explain why we need such gigantic test files. Aren't the cases covered by tests in the tests repository?

else
return FrontierSchedule;
if (_envInfo.number() >= chainParams().u256Param("homsteadForkBlock"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not indent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why? last time you said the opposite

Copy link
Contributor

@chriseth chriseth Oct 18, 2016

Choose a reason for hiding this comment

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

I mean join that into else if

@@ -163,7 +166,7 @@ void Ethash::verify(Strictness _s, BlockHeader const& _bi, BlockHeader const& _p

void Ethash::verifyTransaction(ImportRequirements::value _ir, TransactionBase const& _t, BlockHeader const& _bi) const
{
if (_ir & ImportRequirements::TransactionSignatures && _bi.number() >= chainParams().u256Param("frontierCompatibilityModeLimit"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't we agree that changing this would be too bad for other users?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should be fine.

@@ -371,6 +371,7 @@ pair<TransactionReceipts, bool> Block::sync(BlockChain const& _bc, TransactionQu
else
{
clog(StateTrace) << t.sha3() << "Temporarily no gas left in current block (txs gas > block's gas limit)";
_tq.drop(t.sha3());
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should drop the transaction here, especially not as part of the EIP150 change.

Copy link
Contributor Author

@winsvega winsvega Oct 18, 2016

Choose a reason for hiding this comment

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

other clients are in consensus with that test.
eth cpp will hang otherwise

@@ -63,11 +64,34 @@ struct EVMSchedule
unsigned txDataZeroGas = 4;
unsigned txDataNonZeroGas = 68;
unsigned copyGas = 3;

//EIP150
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this comment, those are the pre-eip150 gas values.


BOOST_AUTO_TEST_CASE(bcSuicideIssueEIP150)
{
//dev::test::TestBlockChain::s_sealEngineNetwork = eth::Network::EIP150Test;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please either uncomment, explain why commented or remove.

@@ -780,6 +886,12 @@ BOOST_AUTO_TEST_CASE(bcForkStressTestHomestead)
dev::test::executeTests("bcForkStressTest", "/BlockchainTests/Homestead",dev::test::getFolder(__FILE__) + "/BlockchainTestsFiller/Homestead", dev::test::doBlockchainTests);
}

BOOST_AUTO_TEST_CASE(bcSuicideIssueHomestead)
{
//dev::test::TestBlockChain::s_sealEngineNetwork = eth::Network::HomesteadTest;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please either uncomment, explain why commented or remove.

@winsvega winsvega force-pushed the eip150 branch 2 times, most recently from f049ff1 to 6c772b2 Compare October 19, 2016 11:30
@chriseth chriseth merged commit a654380 into develop Oct 19, 2016
@axic axic deleted the eip150 branch November 14, 2016 13:12
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.

4 participants