Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
581b320b
Commit
581b320b
authored
Sep 18, 2016
by
Nick Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/state: Fix memory expansion bug by not copying clean objects
parent
f970610c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
5 deletions
+8
-5
state_object.go
core/state/state_object.go
+1
-1
state_test.go
core/state/state_test.go
+4
-2
statedb.go
core/state/statedb.go
+3
-2
No files found.
core/state/state_object.go
View file @
581b320b
...
...
@@ -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
...
...
core/state/state_test.go
View file @
581b320b
...
...
@@ -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
=
tru
e
so0
.
remove
=
fals
e
so0
.
deleted
=
false
so0
.
dirty
=
fals
e
so0
.
dirty
=
tru
e
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
)
...
...
core/state/statedb.go
View file @
581b320b
...
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment