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

testeth touch coinbase in state tests #5024

Merged
merged 3 commits into from
May 23, 2018
Merged

testeth touch coinbase in state tests #5024

merged 3 commits into from
May 23, 2018

Conversation

winsvega
Copy link
Contributor

fix testeth to pass state tests as retesteth ethereum/tests#437

@winsvega winsvega requested a review from pirapira May 15, 2018 14:47
@@ -266,6 +266,10 @@ std::tuple<eth::State, ImportTest::ExecOutput, eth::ChangeLog> ImportTest::execu
try
{
unique_ptr<SealEngineFace> se(ChainParams(genesisInfo(_sealEngineNetwork)).createSealEngine());
bool removeEmptyAccounts = m_envInfo->number() >= se->chainParams().EIP158ForkBlock;
if (!removeEmptyAccounts)
initialState.addBalance(_env.author(), 0); // touch coinbase no matter what
Copy link
Member

Choose a reason for hiding this comment

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

Why should the coinbase be touched both before and after the transaction?

{
// Touch here bacuse coinbase might be suicided above
initialState.addBalance(_env.author(), 0); // touch coinbase no matter what
initialState.commit(removeEmptyAccounts ? State::CommitBehaviour::RemoveEmptyAccounts :
Copy link
Member

Choose a reason for hiding this comment

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

What if we move this out of the if body? Maybe we can skip the first initialState.commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no. the first commit apply suicide instruction to coinbase. making it dissappear from the post state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thus simulating touch and commiting the state again.

@@ -292,7 +291,7 @@ std::tuple<eth::State, ImportTest::ExecOutput, eth::ChangeLog> ImportTest::execu
if (!removeEmptyAccounts)
{
// Touch here bacuse coinbase might be suicided above
initialState.addBalance(_env.author(), 0); // touch coinbase no matter what
initialState.addBalance(_env.author(), 0); // imitate mining reward
Copy link
Member

Choose a reason for hiding this comment

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

Why is this done again? Before, this is a line

initialState.addBalance(_env.author(), 0);  // imitate mining reward

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because suicide coibase will delete coinbase account from the state. we need to touch it again after suicide.

@codecov-io
Copy link

codecov-io commented May 18, 2018

Codecov Report

Merging #5024 into develop will decrease coverage by 0.17%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5024      +/-   ##
===========================================
- Coverage    60.74%   60.56%   -0.18%     
===========================================
  Files          351      351              
  Lines        28375    28397      +22     
  Branches      2873     2867       -6     
===========================================
- Hits         17235    17200      -35     
- Misses       10202    10243      +41     
- Partials       938      954      +16

{
// Touch here bacuse coinbase might be suicided above
initialState.addBalance(_env.author(), 0); // imitate mining reward
initialState.commit(removeEmptyAccounts ? State::CommitBehaviour::RemoveEmptyAccounts :
Copy link
Member

Choose a reason for hiding this comment

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

What happens if you move this line down out of the if body?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, yes it could be simplified. nothing really changes. I just thought that it is not neccessary to perform this step after EIP158

Copy link
Member

@pirapira pirapira 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 to me.

@pirapira pirapira merged commit 975fe5c into develop May 23, 2018
@pirapira pirapira deleted the testeth branch May 23, 2018 16:07
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.

3 participants