-
Notifications
You must be signed in to change notification settings - Fork 2.2k
EIP150 version1-1c gasPrice change proposal #3345
Conversation
5e4d2af
to
652cbd4
Compare
if (_envInfo.number() >= chainParams().u256Param("frontierCompatibilityModeLimit")) | ||
return HomesteadSchedule; | ||
if (_envInfo.number() >= chainParams().u256Param("EIP150forkBlock")) | ||
return DevconSchedule; |
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.
Please make a consistent change for EIP150
, that is its proper name.
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.
why git does not update this comment?
code has been updated to use EIP150Schedule
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 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")) |
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 break anything if we change this to homsteadForkBlock
? It would be a bit more consistent.
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.
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", |
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.
CamelCase would be EIP150ForkBlock
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.
done
{ | ||
auto createGas = *m_io_gas; | ||
if (m_schedule->isEIP150()) | ||
createGas -= createGas / 64; |
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.
There is no agreement on this yet, right?
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.
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.
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.
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; |
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.
Please don't use auto here.
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 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.
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.
done
auto createGas = *m_io_gas; | ||
if (m_schedule->isEIP150()) | ||
createGas -= createGas / 64; | ||
auto gas = createGas; |
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.
Please don't use auto here.
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.
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. |
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.
const
-> cost
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.
done
|
||
// "Static" const already applied. Calculate call gas. | ||
auto requestedCallGas = *m_sp; | ||
auto maxAllowedCallGas = *m_io_gas - *m_io_gas / 64; |
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.
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);
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.
done
unsigned balanceGas = 20; | ||
unsigned suicideGas = 0; | ||
|
||
bool isEIP150() const { return callGas == 700; } |
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.
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
.
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 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.
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.
yep, good suggestion
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.
changed to
bool staticCallDepthLimit() const { return !eip150Mode; }
bool suicideChargesNewAccountGas() const { return eip150Mode; }
} | ||
}, | ||
"pre" : { | ||
"d4fe7bc31cedb7bfb8a345f31e668033056b2728" : { "balance" : "1000000", "nonce" : "0", "code" : "", "storage": {} }, |
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.
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).
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 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)) |
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 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.
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.
done
u256 requestedCallGas = *m_sp; | ||
u256 maxAllowedCallGas = *m_io_gas - *m_io_gas / 64; | ||
u256 callGas = m_schedule->staticCallDepthLimit | ||
? requestedCallGas |
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.
Coding style: separators should go to the end of the line.
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.
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; |
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.
Indentation
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.
done
{ | ||
//EIP150 | ||
EVMSchedule schedule = HomesteadSchedule; | ||
schedule.staticCallDepthLimit = 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.
Indentation.
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.
done
(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; |
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.
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.
@winsvega we do have tests for "63/64 call gas rules", right? If yes, please update description. |
"63/64 call gas rules" |
@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) |
@winsvega please set the hard fork block to 2457000 and then I think this is ready to go. |
chriseth, rebase on top of the current develop branch is needed |
@winsvega some tests are failing, please investigate. |
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.
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")) |
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.
Please do not indent.
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.
why? last time you said the opposite
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 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")) |
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.
Didn't we agree that changing this would be too bad for other users?
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 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()); |
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 don't think we should drop the transaction here, especially not as part of the EIP150 change.
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.
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 |
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.
Please remove this comment, those are the pre-eip150 gas values.
|
||
BOOST_AUTO_TEST_CASE(bcSuicideIssueEIP150) | ||
{ | ||
//dev::test::TestBlockChain::s_sealEngineNetwork = eth::Network::EIP150Test; |
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.
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; |
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.
Please either uncomment, explain why commented or remove.
f049ff1
to
6c772b2
Compare
Implements http://github.com/ethereum/EIPs/issues/150
connects to #3343
or CALLCODEhits a newly created account, it triggers an additional gas cost of 25000 (similar to CALLs)moved from #3344