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
19efebe9
Commit
19efebe9
authored
Mar 09, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated tests and fixed suicide
parent
93cdffca
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
1 deletion
+23
-1
state_object.go
state/state_object.go
+1
-1
statedb.go
state/statedb.go
+9
-0
gh_test.go
tests/vm/gh_test.go
+8
-0
vm.go
vm/vm.go
+5
-0
No files found.
state/state_object.go
View file @
19efebe9
...
...
@@ -111,7 +111,7 @@ func NewStateObjectFromBytes(address, data []byte, db ethutil.Database) *StateOb
func
(
self
*
StateObject
)
MarkForDeletion
()
{
self
.
remove
=
true
self
.
dirty
=
true
statelogger
.
Debug
Detailf
(
"%x: #%d %v (deletion)
\n
"
,
self
.
Address
(),
self
.
nonce
,
self
.
balance
)
statelogger
.
Debug
f
(
"%x: #%d %v X
\n
"
,
self
.
Address
(),
self
.
nonce
,
self
.
balance
)
}
func
(
c
*
StateObject
)
getAddr
(
addr
[]
byte
)
*
ethutil
.
Value
{
...
...
state/statedb.go
View file @
19efebe9
...
...
@@ -121,6 +121,7 @@ func (self *StateDB) Delete(addr []byte) bool {
stateObject
:=
self
.
GetOrNewStateObject
(
addr
)
if
stateObject
!=
nil
{
stateObject
.
MarkForDeletion
()
stateObject
.
balance
=
new
(
big
.
Int
)
return
true
}
...
...
@@ -128,6 +129,14 @@ func (self *StateDB) Delete(addr []byte) bool {
return
false
}
func
(
self
*
StateDB
)
IsDeleted
(
addr
[]
byte
)
bool
{
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
return
stateObject
.
remove
}
return
false
}
//
// Setting, updating & deleting state object methods
//
...
...
tests/vm/gh_test.go
View file @
19efebe9
...
...
@@ -75,10 +75,18 @@ type VmTest struct {
}
func
RunVmTest
(
p
string
,
t
*
testing
.
T
)
{
tests
:=
make
(
map
[
string
]
VmTest
)
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
for
name
,
test
:=
range
tests
{
/*
vm.Debug = true
helper.Logger.SetLogLevel(4)
if name != "refund_CallToSuicideTwice" {
continue
}
*/
db
,
_
:=
ethdb
.
NewMemDatabase
()
statedb
:=
state
.
New
(
nil
,
db
)
for
addr
,
account
:=
range
test
.
Pre
{
...
...
vm/vm.go
View file @
19efebe9
...
...
@@ -736,6 +736,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
self
.
Printf
(
" => (%x) %v"
,
receiver
.
Address
()[
:
4
],
balance
)
receiver
.
AddBalance
(
balance
)
statedb
.
Delete
(
context
.
Address
())
fallthrough
...
...
@@ -905,6 +906,10 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
g
=
GasStorageMod
}
gas
.
Set
(
g
)
case
SUICIDE
:
if
!
statedb
.
IsDeleted
(
context
.
Address
())
{
statedb
.
Refund
(
self
.
env
.
Origin
(),
RefundSuicide
)
}
case
MLOAD
:
newMemSize
=
calcMemSize
(
stack
.
Peek
(),
u256
(
32
))
case
MSTORE8
:
...
...
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