-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Coming to agreement with geth on RIPEMD touch revert #5652
Conversation
|
Codecov Report
@@ Coverage Diff @@
## master #5652 +/- ##
==========================================
- Coverage 62.83% 62.81% -0.02%
==========================================
Files 349 348 -1
Lines 29722 29709 -13
Branches 3346 3347 +1
==========================================
- Hits 18675 18662 -13
Misses 9837 9837
Partials 1210 1210 |
Note that I don't see any difference in test results, if I change our original hack (the one covering failed This suggests that tests might not cover the cases of |
// https://github.com/ethereum/go-ethereum/pull/3341/files#diff-2433aa143ee4772026454b8abd76b9dd | ||
// https://github.com/ethereum/EIPs/issues/716 | ||
// https://github.com/ethereum/aleth/pull/5652 | ||
if (change.address != c_RipemdPrecompiledAddress) |
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.
Uff, this check is actually placed in some hot part of the code...
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.
Maybe we could try to introduce some new kind of touch, that is un-revertable and set only for precompiles...
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.
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.
Actually now I have a third idea, to keep the list of unrevertably touched accounts in State
, instead of putting the flag in each Account
.
Third PR is coming...
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.
added more tests around touch on precompiled addresses and OOG / NO OOG within the same call, not within the same transaction have aleth argue with geth on Byzantium no OOG touch to 0x0000....008 empty account |
This branch and |
no
good. merging the tests then |
Closing in favor of #5664 |
This is the old issue, originated that time when both Geth and Parity had incorrect revert behavior, and then it was decided to introduce a hack into consensus rules instead of doing huge chain reorg.
The buggy behavior that is now a rule is basically: when precompiled contract with address
0x03
(RIPEMD160) is touched, then exception happens and state changes are reverted, this address should be still considered touched in the end, so that "remove empty touched accounts" rule (EIP-158) deletes it from the state at the end of transaction.There are several related tests created after this incident:
GeneralStateTests/stSpecialTest/tx_xcf416c53
- emulates the transaction where this special behavior took place on the main net. Here the gas given toCALL
to RIPEMD is not enough, so theCALL
itself fails, but then transaction proceeds further till success. RIPEMD stays touched and then is deleted. All clients pass this test (otherwise they wouldn't be able to do full sync)GeneralStateTests/stRevertTest/RevertPrecompiledTouch
andGeneralStateTests/stRevertTest/RevertPrecompiledTouch_storage
- hereCALL
to RIPEMD succeeds, but later execution runs out of gas. Changes to the state are reverted, but RIPEMD stays touched and then is deleted. In these tests we have different results than geth.Dimitriy now has regenerated these latter tests via geth, and now aleth doesn't pass them.
In geth all of these cases look to be handled by just one hack https://github.com/ethereum/go-ethereum/blob/7527215a68eaac8a880be83f3f1ded0ed82f6650/core/state/state_object.go#L145-L149
Our current hack covers only the first
tx_xcf416c53
case, because for us failingCALL
to precompile is a special case, that doesn't invoke any rollbackaleth/libethereum/Executive.cpp
Lines 313 to 318 in 007d89a
Now for us to cover the case of OOG in caller's frame, it looks like we unfortunately have to add another similar hack in revert logic.
From the point of view of our code it feels like an unnecessary hack, not related to original problem, but I guess from geth's perspective to replicate our behavior they would need to do some "unnecessary" hacks in their code. Oh well.
More references:
cc @holiman @winsvega