fix(core): revert pending storage updates if they revert to original #29661 (#2079)

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
This commit is contained in:
Daniel Liu 2026-03-06 13:46:03 +08:00 committed by GitHub
parent 3eb198b1a5
commit 275424c44f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -224,7 +224,15 @@ func (s *stateObject) setState(key common.Hash, value *common.Hash) {
// committed later. It is invoked at the end of every transaction.
func (s *stateObject) finalise() {
for key, value := range s.dirtyStorage {
s.pendingStorage[key] = value
// If the slot is different from its original value, move it into the
// pending area to be committed at the end of the block.
if value != s.originStorage[key] {
s.pendingStorage[key] = value
} else {
// Otherwise, the slot was reverted to its original value, remove it
// from the pending area to avoid thrashing the data structure.
delete(s.pendingStorage, key)
}
}
if len(s.dirtyStorage) > 0 {
s.dirtyStorage = make(Storage)