-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Conversation
libethereum/State.cpp
Outdated
@@ -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()) |
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.
Here I would go with account.setNewCode(std::move(change.oldCode));
all the time. Moving empty bytes is not more costly than reset.
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.
Fixed.
libethereum/State.cpp
Outdated
account.resetCode(); | ||
else | ||
account.setNewCode(std::move(change.oldCode)); | ||
account.setNewCode(std::move(change.oldCode)); |
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.
Hm... after these changes it looks we should also rename .setNewCode()
to just .setCode()
.
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.
That's true. I'll add a commit to 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.
Done.
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 Report
@@ 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
|
All green! |
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.