diff --git a/account/state/state.go b/account/state/state.go index 005d3082132303bbdb23db5cab678fe85528d077..d175f6e8e8742ea649814a3ee24cfa2152820311 100644 --- a/account/state/state.go +++ b/account/state/state.go @@ -33,7 +33,7 @@ type StorageGetter interface { } type StorageSetter interface { - // Store a 32-byte value at key for the account at address + // Store a 32-byte value at key for the account at address, setting to Zero256 removes the key SetStorage(address acm.Address, key, value binary.Word256) error } diff --git a/execution/state.go b/execution/state.go index af168650cb153cc64509b6e5016ed5a349f7015e..8c9b739e36da0fecdb7e2efa9be58987f982c47a 100644 --- a/execution/state.go +++ b/execution/state.go @@ -235,7 +235,11 @@ func (s *State) GetStorage(address acm.Address, key binary.Word256) (binary.Word func (s *State) SetStorage(address acm.Address, key, value binary.Word256) error { s.Lock() defer s.Unlock() - s.tree.Set(prefixedKey(storagePrefix, address.Bytes(), key.Bytes()), value.Bytes()) + if value == binary.Zero256 { + s.tree.Remove(key.Bytes()) + } else { + s.tree.Set(prefixedKey(storagePrefix, address.Bytes(), key.Bytes()), value.Bytes()) + } return nil }