Skip to content

Commit 7205366

Browse files
committed
core/state: fix ripemd-cornercase in Copy
1 parent 5a79aca commit 7205366

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

core/state/statedb.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,14 @@ func (self *StateDB) Copy() *StateDB {
471471
}
472472
// Copy the dirty states, logs, and preimages
473473
for addr := range self.journal.dirties {
474-
state.stateObjects[addr] = self.stateObjects[addr].deepCopy(state)
475-
state.stateObjectsDirty[addr] = struct{}{}
474+
// As documented [here](https://github.com/ethereum/go-ethereum/pull/16485#issuecomment-380438527),
475+
// and in the Finalise-method, there is a case where an object is in the journal but not
476+
// in the stateObjects: OOG after touch on ripeMD prior to Byzantium. Thus, we need to check for
477+
// nil
478+
if object, exist := self.stateObjects[addr]; exist {
479+
state.stateObjects[addr] = object.deepCopy(state)
480+
state.stateObjectsDirty[addr] = struct{}{}
481+
}
476482
}
477483
// Above, we don't copy the actual journal. This means that if the copy is copied, the
478484
// loop above will be a no-op, since the copy's journal is empty.

0 commit comments

Comments
 (0)