aboutsummaryrefslogtreecommitdiffstats
path: root/light
diff options
context:
space:
mode:
Diffstat (limited to 'light')
-rw-r--r--light/state.go4
-rw-r--r--light/state_object.go5
-rw-r--r--light/state_test.go6
3 files changed, 5 insertions, 10 deletions
diff --git a/light/state.go b/light/state.go
index e18f9cdc5..4f2177238 100644
--- a/light/state.go
+++ b/light/state.go
@@ -261,7 +261,9 @@ func (self *LightState) Copy() *LightState {
state := NewLightState(common.Hash{}, self.odr)
state.trie = self.trie
for k, stateObject := range self.stateObjects {
- state.stateObjects[k] = stateObject.Copy()
+ if stateObject.dirty {
+ state.stateObjects[k] = stateObject.Copy()
+ }
}
return state
diff --git a/light/state_object.go b/light/state_object.go
index 030653c77..1e9c7f4b1 100644
--- a/light/state_object.go
+++ b/light/state_object.go
@@ -79,8 +79,6 @@ type StateObject struct {
codeHash []byte
// The code for this account
code Code
- // Temporarily initialisation code
- initCode Code
// Cached storage (flushed when updated)
storage Storage
@@ -188,8 +186,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.initCode = common.CopyBytes(self.initCode)
+ stateObject.code = self.code
stateObject.storage = self.storage.Copy()
stateObject.remove = self.remove
stateObject.dirty = self.dirty
diff --git a/light/state_test.go b/light/state_test.go
index 2c2e6daea..d7014a2dc 100644
--- a/light/state_test.go
+++ b/light/state_test.go
@@ -42,7 +42,6 @@ func (odr *testOdr) Retrieve(ctx context.Context, req OdrRequest) error {
case *TrieRequest:
t, _ := trie.New(req.root, odr.sdb)
req.proof = t.Prove(req.key)
- trie.ClearGlobalCache()
case *NodeDataRequest:
req.data, _ = odr.sdb.Get(req.hash[:])
}
@@ -62,7 +61,7 @@ func makeTestState() (common.Hash, ethdb.Database) {
}
so.AddBalance(big.NewInt(int64(i)))
so.SetCode([]byte{i, i, i})
- so.Update()
+ so.UpdateRoot(sdb)
st.UpdateStateObject(so)
}
root, _ := st.Commit()
@@ -75,7 +74,6 @@ func TestLightStateOdr(t *testing.T) {
odr := &testOdr{sdb: sdb, ldb: ldb}
ls := NewLightState(root, odr)
ctx := context.Background()
- trie.ClearGlobalCache()
for i := byte(0); i < 100; i++ {
addr := common.Address{i}
@@ -160,7 +158,6 @@ func TestLightStateSetCopy(t *testing.T) {
odr := &testOdr{sdb: sdb, ldb: ldb}
ls := NewLightState(root, odr)
ctx := context.Background()
- trie.ClearGlobalCache()
for i := byte(0); i < 100; i++ {
addr := common.Address{i}
@@ -237,7 +234,6 @@ func TestLightStateDelete(t *testing.T) {
odr := &testOdr{sdb: sdb, ldb: ldb}
ls := NewLightState(root, odr)
ctx := context.Background()
- trie.ClearGlobalCache()
addr := common.Address{42}