From 7205366c9f85bbfcf86ac78efcd005bb10dfc5fe Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 11 Apr 2018 15:03:49 +0200 Subject: [PATCH] core/state: fix ripemd-cornercase in Copy --- core/state/statedb.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 97c6e4a01..3ae6843d8 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -471,8 +471,14 @@ func (self *StateDB) Copy() *StateDB { } // Copy the dirty states, logs, and preimages for addr := range self.journal.dirties { - state.stateObjects[addr] = self.stateObjects[addr].deepCopy(state) - state.stateObjectsDirty[addr] = struct{}{} + // 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{}{} + } } // 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.