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

EIP649 reward reduction and difficulty bomb delay #4338

Merged
merged 8 commits into from Aug 23, 2017
Merged

EIP649 reward reduction and difficulty bomb delay #4338

merged 8 commits into from Aug 23, 2017

Conversation

pirapira
Copy link
Member

@pirapira pirapira commented Aug 15, 2017

The reward-reduction and difficulty bomb delay have been both implemented.

Tests are updated so that testeth with no options passes.

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

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

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")

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you.

Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll try.

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

u256 ChainOperationParams::blockReward(bool isByzantiumOrLater) const
{
if (isByzantiumOrLater)
return u256(3 * (bigint(10) ^ 18)); // 3 ETH
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wondered these too.

Copy link
Contributor

@winsvega winsvega left a 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

@pirapira pirapira changed the title [WIP] EIP649 difficulty bomb delay and reward reduction [WIP] EIP649 reward reduction part. Aug 17, 2017
@pirapira pirapira changed the title [WIP] EIP649 reward reduction part. [WIP] EIP649 reward reduction and difficulty bomb delay Aug 17, 2017
@pirapira
Copy link
Member Author

@winsvega shall these cases appear in the test case spreadsheet?

@winsvega
Copy link
Contributor

I mean we could add the tests with this PR. that was the idea of a submodule.
to cover the PR changes with relevant tests

@pirapira
Copy link
Member Author

@winsvega I prefer a separate PR for adding new tests. We should deliver the fixed tests earlier, even without the new tests.

@winsvega
Copy link
Contributor

if we have the tests at least we know the change on this PR is covered. that what is the point

@pirapira
Copy link
Member Author

Let me see if I need to fix any fillers. If yes, we have the changes covered somehow.

@pirapira pirapira force-pushed the eip649 branch 9 times, most recently from 86e1441 to 6d07823 Compare August 22, 2017 13:58
@pirapira pirapira changed the title [WIP] EIP649 reward reduction and difficulty bomb delay EIP649 reward reduction and difficulty bomb delay Aug 22, 2017
@pirapira
Copy link
Member Author

pirapira commented Aug 23, 2017

I had an ethereum/tests commit on my local machine, pushed that and used that as the submodule.

@chfast
Copy link
Collaborator

chfast commented Aug 23, 2017

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?

@pirapira
Copy link
Member Author

@chfast I believe we should do

_bc.chainParams().EIP158ForkBlock()

instead of

_bc.chainParams().u256Param("EIP158ForkBlock")

And, remove u256Param from the public interface of ChainParams.

I want to do it in a separate PR. Do you want it before this one?

@chfast
Copy link
Collaborator

chfast commented Aug 23, 2017

After.

I'd like to review the chain config design later on...
For EVM-C single enum is enough. Also we can consider configs for chains + separated config for chain switches (hard forks).

Copy link
Collaborator

@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.

Only 2 small nits. The rest is good.

@@ -71,6 +72,8 @@ struct EVMSchedule
unsigned blockhashGas = 20;
unsigned maxCodeSize = unsigned(-1);

boost::optional<u256> blockRewardOverwrite{};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Explicit initialization not needed.

@@ -73,7 +73,11 @@ struct ChainOperationParams
std::string sealEngineName = "NoProof";

/// General chain params.
u256 blockReward = 0;
private:
u256 m_blockReward = 0;
Copy link
Collaborator

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

codecov-io commented Aug 23, 2017

Codecov Report

Merging #4338 into develop will decrease coverage by <.01%.
The diff coverage is 96.55%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
libethcore/SealEngine.h 75% <ø> (ø) ⬆️
libethcore/ChainOperationParams.h 100% <ø> (ø) ⬆️
libethcore/ChainOperationParams.cpp 100% <100%> (ø) ⬆️
libethereum/Block.cpp 87.79% <100%> (+0.06%) ⬆️
libethcore/EVMSchedule.h 100% <100%> (ø) ⬆️
test/tools/jsontests/BlockChainTests.cpp 30.6% <100%> (ø) ⬆️
libethcore/SealEngine.cpp 86.84% <100%> (+1.12%) ⬆️
libethereum/ChainParams.cpp 95.76% <100%> (ø) ⬆️
libethashseal/Ethash.cpp 85.16% <80%> (-0.27%) ⬇️
libp2p/NodeTable.cpp 39.52% <0%> (-0.6%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e21ee1...b6617fe. Read the comment docs.

@pirapira
Copy link
Member Author

@chfast removed the unnecessary initializations.

@pirapira pirapira merged commit 55865c8 into develop Aug 23, 2017
@pirapira pirapira deleted the eip649 branch August 23, 2017 12:20
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.

None yet

5 participants