-
Notifications
You must be signed in to change notification settings - Fork 21.5k
core/state: clear out cached state data when reset occurs #27376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -627,11 +627,36 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) | |
| if prev == nil { | ||
| s.journal.append(createObjectChange{account: &addr}) | ||
| } else { | ||
| // The original account should be marked as destructed and all cached | ||
| // account and storage data should be cleared as well. Note, it must | ||
| // be done here, otherwise the destruction event of original one will | ||
| // be lost. | ||
| _, prevdestruct := s.stateObjectsDestruct[prev.address] | ||
| if !prevdestruct { | ||
| s.stateObjectsDestruct[prev.address] = struct{}{} | ||
| } | ||
| s.journal.append(resetObjectChange{account: &addr, prev: prev, prevdestruct: prevdestruct}) | ||
| var ( | ||
| account []byte | ||
| storage map[common.Hash][]byte | ||
| ) | ||
| // There may be some cached account/storage data already since IntermediateRoot | ||
| // will be called for each transaction before byzantium fork which will always | ||
| // cache the latest account/storage data. | ||
| if s.snapAccounts != nil { | ||
| account = s.snapAccounts[prev.addrHash] | ||
| delete(s.snapAccounts, prev.addrHash) | ||
| } | ||
| if s.snapStorage != nil { | ||
| storage = s.snapStorage[prev.addrHash] | ||
| delete(s.snapStorage, prev.addrHash) | ||
| } | ||
|
||
| s.journal.append(resetObjectChange{ | ||
| account: &addr, | ||
| prev: prev, | ||
| prevdestruct: prevdestruct, | ||
| prevAccount: account, | ||
| prevStorage: storage, | ||
| }) | ||
| } | ||
| s.setStateObject(newobj) | ||
| if prev != nil && !prev.deleted { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.