From e44b2dc8817c3f9ff4bfcc03d73ec7890dd36fcf Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Mon, 19 Sep 2016 07:56:23 +0800 Subject: [PATCH 1/2] [release 1.4.12] core/state: Fix memory expansion bug by not copying clean objects (cherry picked from commit 581b320b9dfb42c0c4842e0bc5aeb507267a8eba) --- core/state/state_object.go | 2 +- core/state/state_test.go | 6 ++++-- core/state/statedb.go | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/state/state_object.go b/core/state/state_object.go index 769c63d42d..20da1006fc 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -187,7 +187,7 @@ 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) + stateObject.code = self.code stateObject.initCode = common.CopyBytes(self.initCode) stateObject.storage = self.storage.Copy() stateObject.remove = self.remove diff --git a/core/state/state_test.go b/core/state/state_test.go index ce86a5b768..5a6cb0b501 100644 --- a/core/state/state_test.go +++ b/core/state/state_test.go @@ -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) @@ -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) diff --git a/core/state/statedb.go b/core/state/statedb.go index 3e25e0c160..8ba81613d6 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -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) @@ -364,7 +366,6 @@ func (s *StateDB) IntermediateRoot() common.Hash { stateObject.Update() s.UpdateStateObject(stateObject) } - stateObject.dirty = false } } return s.trie.Hash() From dfc63c49c7462014e6ab87db41c308aebb7b176a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 19 Sep 2016 04:22:44 +0300 Subject: [PATCH 2/2] [release/1.4.12] VERSION, cmd/geth: bumped version 1.4.12 --- VERSION | 2 +- cmd/geth/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 079d7f692f..f86e029880 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.11 +1.4.12 diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 176202302a..e0e440e5b4 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -50,7 +50,7 @@ const ( clientIdentifier = "Geth" // Client identifier to advertise over the network versionMajor = 1 // Major version component of the current release versionMinor = 4 // Minor version component of the current release - versionPatch = 11 // Patch version component of the current release + versionPatch = 12 // Patch version component of the current release versionMeta = "stable" // Version metadata to append to the version string versionOracle = "0xfa7b9770ca4cb04296cac84f37736d4041251cdf" // Ethereum address of the Geth release oracle