EIP649 reward reduction and difficulty bomb delay #4338
Conversation
@@ -531,8 +552,9 @@ void testBCTest(json_spirit::mObject& _o) | |||
//check the balance before and after the block according to mining rules | |||
if (blockFromFields.blockHeader().parentHash() == preHash) | |||
{ | |||
bool const isByzantiumOrLater = ChainBranch::networkIsByzantiumOrLater(blockChainName); |
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 what's the best way to know if it's already Byzantium here?
{ | ||
unique_ptr<SealEngineFace> se(ChainParams(genesisInfo(test::TestBlockChain::s_sealEngineNetwork)).createSealEngine()); | ||
bigint baseReward = se->chainParams().blockReward; | ||
bigint baseReward = se->chainParams().blockReward(isByzantium); |
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 should be done inside chain params. the thing is that blockReward in this case will depend on blockNumber and evm schedule like other fork dependent params.
isByzantium = number >= chainParams().u256Param("ByzantiumBlockNumber")
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.
Thank you.
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 it feels like isByzantium should be calculated inside chainParams.
Cause it knows the schedule from s_sealEngineNetwork. if should be able to return the reward if you give it the blocknumber
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'll try.
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.
No, ChainParams
does not know the schedule. It does not have access to a sealEngineNetwork
.
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.
ChainParams constructed from genesisInfo so it does know all the transition blocks.
Schedule variables are: EVMSchedule.h
Ah, and here there is a function
EVMSchedule const& SealEngineBase::evmSchedule(u256 const& _blockNumber) const
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.
OK. I'll file another PR first to fix this first.
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 so, the SealEngine knows when Byzantium starts. ChainParams should not know that.
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? chainParams initialized from genesisInfo. it should know that. cause seal engine knows that from chainParams.
chainParams().u256Param("byzantiumForkBlock")
indicates when Byzanium starts.
do you think we should look at this issue more carefully and perhaps do a refactoring PR for libethereum instead?
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.
No, I came up with one solution.
libethcore/ChainOperationParams.cpp
Outdated
u256 ChainOperationParams::blockReward(bool isByzantiumOrLater) const | ||
{ | ||
if (isByzantiumOrLater) | ||
return u256(3 * (bigint(10) ^ 18)); // 3 ETH |
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.
Is ^
implemented as exp or as xor?
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 think there should also be a global constant called ether
somewhere with the right value.
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 wondered these too.
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.
ok. we need a blockchain test that covers up this reward change and difficulty reduction.
a test in Transition tests (transition from EIP158TOByzantine) for difficulty bomb delay.
and change an expect section for Byzantine in already existing reward test
@winsvega shall these cases appear in the test case spreadsheet? |
I mean we could add the tests with this PR. that was the idea of a submodule. |
@winsvega I prefer a separate PR for adding new tests. We should deliver the fixed tests earlier, even without the new tests. |
if we have the tests at least we know the change on this PR is covered. that what is the point |
Let me see if I need to fix any fillers. If yes, we have the changes covered somehow. |
86e1441
to
6d07823
Compare
I had an |
At first look, I don't like how we manage chain configuration. Do we need to use JSON-like structure and constructs like "get u256 param" all the way to the bottom? |
@chfast I believe we should do
instead of
And, remove I want to do it in a separate PR. Do you want it before this one? |
After. I'd like to review the chain config design later on... |
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.
Only 2 small nits. The rest is good.
libethcore/EVMSchedule.h
Outdated
@@ -71,6 +72,8 @@ struct EVMSchedule | |||
unsigned blockhashGas = 20; | |||
unsigned maxCodeSize = unsigned(-1); | |||
|
|||
boost::optional<u256> blockRewardOverwrite{}; |
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.
Explicit initialization not needed.
libethcore/ChainOperationParams.h
Outdated
@@ -73,7 +73,11 @@ struct ChainOperationParams | |||
std::string sealEngineName = "NoProof"; | |||
|
|||
/// General chain params. | |||
u256 blockReward = 0; | |||
private: | |||
u256 m_blockReward = 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.
Explicit initialization not needed.
Codecov Report
@@ Coverage Diff @@
## develop #4338 +/- ##
===========================================
- Coverage 67.69% 67.69% -0.01%
===========================================
Files 307 307
Lines 23368 23386 +18
===========================================
+ Hits 15819 15831 +12
- Misses 7549 7555 +6
Continue to review full report at Codecov.
|
@chfast removed the unnecessary initializations. |
The reward-reduction and difficulty bomb delay have been both implemented.
Tests are updated so that
testeth
with no options passes.