Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
This contains the changes from Geth 1.4.12: Shanghai with love
Browse files Browse the repository at this point in the history
  • Loading branch information
elaineo committed Sep 20, 2016
1 parent 2adf2de commit 8b508b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ func (self *StateObject) Copy() *StateObject {
stateObject.codeHash = common.CopyBytes(self.codeHash)
stateObject.nonce = self.nonce
stateObject.trie = self.trie
stateObject.code = common.CopyBytes(self.code)
// Modified to use bytecode instead of a copy of the bytecode
stateObject.code = self.code
stateObject.initCode = common.CopyBytes(self.initCode)
stateObject.storage = self.storage.Copy()
stateObject.remove = self.remove
Expand Down
6 changes: 4 additions & 2 deletions core/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,11 @@ func TestSnapshot2(t *testing.T) {
so0.balance = big.NewInt(42)
so0.nonce = 43
so0.SetCode([]byte{'c', 'a', 'f', 'e'})
so0.remove = true
so0.remove = false
so0.deleted = false
so0.dirty = false
so0.dirty = true
state.SetStateObject(so0)
state.Commit()

// and one with deleted == true
so1 := state.GetStateObject(stateobjaddr1)
Expand All @@ -173,6 +174,7 @@ func TestSnapshot2(t *testing.T) {
state.Set(snapshot)

so0Restored := state.GetStateObject(stateobjaddr0)
so0Restored.GetState(storageaddr)
so1Restored := state.GetStateObject(stateobjaddr1)
// non-deleted is equal (restored)
compareStateObjects(so0Restored, so0, t)
Expand Down
5 changes: 3 additions & 2 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ func (self *StateDB) Copy() *StateDB {
state, _ := New(common.Hash{}, self.db)
state.trie = self.trie
for k, stateObject := range self.stateObjects {
state.stateObjects[k] = stateObject.Copy()
if stateObject.dirty {
state.stateObjects[k] = stateObject.Copy()
}
}

state.refund.Set(self.refund)
Expand Down Expand Up @@ -364,7 +366,6 @@ func (s *StateDB) IntermediateRoot() common.Hash {
stateObject.Update()
s.UpdateStateObject(stateObject)
}
stateObject.dirty = false
}
}
return s.trie.Hash()
Expand Down

0 comments on commit 8b508b3

Please sign in to comment.