core, core/state: fixed consensus issue added touch revert

Implemented proper touch revert journal entries and copied a Parity
consensus bug in order to remain in sync with the current longest chain.
This commit is contained in:
Jeffrey Wilcke
2016-11-24 16:24:04 +01:00
parent c04c8f10f0
commit 12d654a6fc
8 changed files with 172 additions and 31 deletions

View File

@ -67,10 +67,13 @@ type (
addLogChange struct {
txhash common.Hash
}
touchChange struct {
account *common.Address
prev bool
}
)
func (ch createObjectChange) undo(s *StateDB) {
s.GetStateObject(*ch.account).deleted = true
delete(s.stateObjects, *ch.account)
delete(s.stateObjectsDirty, *ch.account)
}
@ -87,6 +90,15 @@ func (ch suicideChange) undo(s *StateDB) {
}
}
var ripemd = common.HexToAddress("0000000000000000000000000000000000000003")
func (ch touchChange) undo(s *StateDB) {
if !ch.prev && *ch.account != ripemd {
delete(s.stateObjects, *ch.account)
delete(s.stateObjectsDirty, *ch.account)
}
}
func (ch balanceChange) undo(s *StateDB) {
s.GetStateObject(*ch.account).setBalance(ch.prev)
}