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

Revert bug fix #4151

Merged
merged 6 commits into from
Jun 20, 2017
Merged

Revert bug fix #4151

merged 6 commits into from
Jun 20, 2017

Conversation

pirapira
Copy link
Member

This fixes #4130 .

Before Metropolis, when an address collision happens, an existing non-empty code could be overwritten. The journaling system didn't remember the old code, so it could not recover the old code. This PR fixes that problem.

@@ -512,7 +512,10 @@ void State::rollback(size_t _savepoint)
m_cache.erase(change.address);
break;
case Change::NewCode:
account.resetCode();
if (change.oldCode.empty())
Copy link
Member

Choose a reason for hiding this comment

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

Here I would go with account.setNewCode(std::move(change.oldCode)); all the time. Moving empty bytes is not more costly than reset.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

account.resetCode();
else
account.setNewCode(std::move(change.oldCode));
account.setNewCode(std::move(change.oldCode));
Copy link
Member

Choose a reason for hiding this comment

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

Hm... after these changes it looks we should also rename .setNewCode() to just .setCode().

Copy link
Member Author

Choose a reason for hiding this comment

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

That's true. I'll add a commit to this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@chfast
Copy link
Member

chfast commented Jun 20, 2017

The best!

This addresses #4130 together with the corresponding change in the test.
Rebased after the snark tests because the snark precompiles are already implemented on cpp-ethereum:develop
@codecov-io
Copy link

codecov-io commented Jun 20, 2017

Codecov Report

Merging #4151 into develop will decrease coverage by 0.09%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           develop    #4151     +/-   ##
==========================================
- Coverage    67.08%   66.99%   -0.1%     
==========================================
  Files          299      299             
  Lines        23141    23148      +7     
==========================================
- Hits         15525    15508     -17     
- Misses        7616     7640     +24
Impacted Files Coverage Δ
libethereum/Account.h 100% <ø> (ø) ⬆️
test/tools/libtesteth/FillJsonFunctions.cpp 20.56% <ø> (ø) ⬆️
libethereum/Account.cpp 83.33% <100%> (ø) ⬆️
libethereum/Block.cpp 84.4% <100%> (ø) ⬆️
test/unittests/libethereum/StateUnitTests.cpp 94.11% <100%> (ø) ⬆️
libethereum/Executive.cpp 60.33% <100%> (ø) ⬆️
libethereum/State.cpp 73.14% <100%> (+0.16%) ⬆️
libethereum/State.h 95.12% <100%> (+0.83%) ⬆️
libethash/internal.c 71.51% <0%> (-12.03%) ⬇️
libethashseal/EthashAux.cpp 70.68% <0%> (-2.59%) ⬇️
... and 5 more

@pirapira
Copy link
Member Author

All green!

@pirapira pirapira merged commit 28f59c5 into develop Jun 20, 2017
@pirapira pirapira deleted the revert-bug-fix branch June 20, 2017 16:14
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