Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet committed May 8, 2023
1 parent 16d9f1b commit d21aaf9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ func (s *stateObject) updateTrie(db Database) (Trie, error) {
}
s.originStorage[key] = value

var v []byte
// rlp-encoded value to be used by the snapshot
var snapshotVal []byte
if (value == common.Hash{}) {
if err := tr.DeleteStorage(s.address, key[:]); err != nil {
s.db.setError(err)
Expand All @@ -303,7 +304,7 @@ func (s *stateObject) updateTrie(db Database) (Trie, error) {
} else {
trimmedVal := common.TrimLeftZeroes(value[:])
// Encoding []byte cannot fail, ok to ignore the error.
v, _ = rlp.EncodeToBytes(trimmedVal)
snapshotVal, _ = rlp.EncodeToBytes(trimmedVal)
if err := tr.UpdateStorage(s.address, key[:], trimmedVal); err != nil {
s.db.setError(err)
return nil, err
Expand All @@ -319,7 +320,7 @@ func (s *stateObject) updateTrie(db Database) (Trie, error) {
s.db.snapStorage[s.addrHash] = storage
}
}
storage[crypto.HashData(hasher, key[:])] = v // v will be nil if it's deleted
storage[crypto.HashData(hasher, key[:])] = snapshotVal // will be nil if it's deleted
}
usedStorage = append(usedStorage, common.CopyBytes(key[:])) // Copy needed for closure
}
Expand Down

0 comments on commit d21aaf9

Please sign in to comment.