Skip to content

Commit e636e4e

Browse files
authored
core/state: track slot reads for empty storage (ethereum#33743)
From the https://eips.ethereum.org/EIPS/eip-7928 > SELFDESTRUCT (in-transaction): Accounts destroyed within a transaction MUST be included in AccountChanges without nonce or code changes. However, if the account had a positive balance pre-transaction, the balance change to zero MUST be recorded. Storage keys within the self-destructed contracts that were modified or read MUST be included as a storage_reads entry. The storage read against the empty contract (zero storage) should also be recorded in the BAL's readlist.
1 parent cbf3d8f commit e636e4e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/state/state_object.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,19 @@ func (s *stateObject) GetCommittedState(key common.Hash) common.Hash {
195195
// have been handles via pendingStorage above.
196196
// 2) we don't have new values, and can deliver empty response back
197197
if _, destructed := s.db.stateObjectsDestruct[s.address]; destructed {
198+
// Invoke the reader regardless and discard the returned value.
199+
// The returned value may not be empty, as it could belong to a
200+
// self-destructed contract.
201+
//
202+
// The read operation is still essential for correctly building
203+
// the block-level access list.
204+
//
205+
// TODO(rjl493456442) the reader interface can be extended with
206+
// Touch, recording the read access without the actual disk load.
207+
_, err := s.db.reader.Storage(s.address, key)
208+
if err != nil {
209+
s.db.setError(err)
210+
}
198211
s.originStorage[key] = common.Hash{} // track the empty slot as origin value
199212
return common.Hash{}
200213
}

0 commit comments

Comments
 (0)