core/state: fix ripemd-cornercase in Copy

This commit is contained in:
Martin Holst Swende 2018-04-11 15:03:49 +02:00
parent 5a79aca8b9
commit 7205366c9f
No known key found for this signature in database
GPG Key ID: 683B438C05A5DDF0

View File

@ -471,9 +471,15 @@ func (self *StateDB) Copy() *StateDB {
} }
// Copy the dirty states, logs, and preimages // Copy the dirty states, logs, and preimages
for addr := range self.journal.dirties { for addr := range self.journal.dirties {
state.stateObjects[addr] = self.stateObjects[addr].deepCopy(state) // As documented [here](https://github.com/ethereum/go-ethereum/pull/16485#issuecomment-380438527),
// and in the Finalise-method, there is a case where an object is in the journal but not
// in the stateObjects: OOG after touch on ripeMD prior to Byzantium. Thus, we need to check for
// nil
if object, exist := self.stateObjects[addr]; exist {
state.stateObjects[addr] = object.deepCopy(state)
state.stateObjectsDirty[addr] = struct{}{} state.stateObjectsDirty[addr] = struct{}{}
} }
}
// Above, we don't copy the actual journal. This means that if the copy is copied, the // Above, we don't copy the actual journal. This means that if the copy is copied, the
// loop above will be a no-op, since the copy's journal is empty. // loop above will be a no-op, since the copy's journal is empty.
// Thus, here we iterate over stateObjects, to enable copies of copies // Thus, here we iterate over stateObjects, to enable copies of copies