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
750d70c2
Commit
750d70c2
authored
Jan 12, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated tests
parent
34689cb3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
14 deletions
+20
-14
common.go
ethutil/common.go
+1
-0
vm.go
tests/helper/vm.go
+10
-1
gh_test.go
tests/vm/gh_test.go
+0
-6
vm_debug.go
vm/vm_debug.go
+9
-7
No files found.
ethutil/common.go
View file @
750d70c2
...
@@ -84,4 +84,5 @@ var (
...
@@ -84,4 +84,5 @@ var (
BigFalse
=
Big0
BigFalse
=
Big0
Big32
=
big
.
NewInt
(
32
)
Big32
=
big
.
NewInt
(
32
)
Big256
=
big
.
NewInt
(
0xff
)
Big256
=
big
.
NewInt
(
0xff
)
Big257
=
big
.
NewInt
(
257
)
)
)
tests/helper/vm.go
View file @
750d70c2
...
@@ -15,6 +15,7 @@ type Env struct {
...
@@ -15,6 +15,7 @@ type Env struct {
depth
int
depth
int
state
*
state
.
StateDB
state
*
state
.
StateDB
skipTransfer
bool
skipTransfer
bool
initial
bool
Gas
*
big
.
Int
Gas
*
big
.
Int
origin
[]
byte
origin
[]
byte
...
@@ -68,9 +69,17 @@ func (self *Env) Depth() int { return self.depth }
...
@@ -68,9 +69,17 @@ func (self *Env) Depth() int { return self.depth }
func
(
self
*
Env
)
SetDepth
(
i
int
)
{
self
.
depth
=
i
}
func
(
self
*
Env
)
SetDepth
(
i
int
)
{
self
.
depth
=
i
}
func
(
self
*
Env
)
Transfer
(
from
,
to
vm
.
Account
,
amount
*
big
.
Int
)
error
{
func
(
self
*
Env
)
Transfer
(
from
,
to
vm
.
Account
,
amount
*
big
.
Int
)
error
{
if
self
.
skipTransfer
{
if
self
.
skipTransfer
{
// ugly hack
if
self
.
initial
{
self
.
initial
=
false
return
nil
}
if
from
.
Balance
()
.
Cmp
(
amount
)
<
0
{
if
from
.
Balance
()
.
Cmp
(
amount
)
<
0
{
return
errors
.
New
(
"Insufficient balance in account"
)
return
errors
.
New
(
"Insufficient balance in account"
)
}
}
return
nil
}
}
return
vm
.
Transfer
(
from
,
to
,
amount
)
return
vm
.
Transfer
(
from
,
to
,
amount
)
}
}
...
@@ -109,10 +118,10 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
...
@@ -109,10 +118,10 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
)
)
caller
:=
state
.
GetOrNewStateObject
(
from
)
caller
:=
state
.
GetOrNewStateObject
(
from
)
caller
.
SetBalance
(
ethutil
.
Big
(
"1000000000000000000"
))
vmenv
:=
NewEnvFromMap
(
state
,
env
,
exec
)
vmenv
:=
NewEnvFromMap
(
state
,
env
,
exec
)
vmenv
.
skipTransfer
=
true
vmenv
.
skipTransfer
=
true
vmenv
.
initial
=
true
ret
,
err
:=
vmenv
.
Call
(
caller
,
to
,
data
,
gas
,
price
,
value
)
ret
,
err
:=
vmenv
.
Call
(
caller
,
to
,
data
,
gas
,
price
,
value
)
return
ret
,
vmenv
.
logs
,
vmenv
.
Gas
,
err
return
ret
,
vmenv
.
logs
,
vmenv
.
Gas
,
err
...
...
tests/vm/gh_test.go
View file @
750d70c2
...
@@ -79,12 +79,6 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -79,12 +79,6 @@ func RunVmTest(p string, t *testing.T) {
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
for
name
,
test
:=
range
tests
{
for
name
,
test
:=
range
tests
{
/*
helper.Logger.SetLogLevel(5)
if name != "createNameRegistratorZeroMem" {
continue
}
*/
db
,
_
:=
ethdb
.
NewMemDatabase
()
db
,
_
:=
ethdb
.
NewMemDatabase
()
statedb
:=
state
.
New
(
nil
,
db
)
statedb
:=
state
.
New
(
nil
,
db
)
for
addr
,
account
:=
range
test
.
Pre
{
for
addr
,
account
:=
range
test
.
Pre
{
...
...
vm/vm_debug.go
View file @
750d70c2
...
@@ -50,10 +50,6 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price *
...
@@ -50,10 +50,6 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price *
vmlogger
.
Debugf
(
"(%d) (%x) %x (code=%d) gas: %v (d) %x
\n
"
,
self
.
env
.
Depth
(),
caller
.
Address
()[
:
4
],
context
.
Address
(),
len
(
code
),
context
.
Gas
,
callData
)
vmlogger
.
Debugf
(
"(%d) (%x) %x (code=%d) gas: %v (d) %x
\n
"
,
self
.
env
.
Depth
(),
caller
.
Address
()[
:
4
],
context
.
Address
(),
len
(
code
),
context
.
Gas
,
callData
)
if
p
:=
Precompiled
[
string
(
me
.
Address
())];
p
!=
nil
{
return
self
.
RunPrecompiled
(
p
,
callData
,
context
)
}
if
self
.
Recoverable
{
if
self
.
Recoverable
{
// Recover from any require exception
// Recover from any require exception
defer
func
()
{
defer
func
()
{
...
@@ -70,6 +66,10 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price *
...
@@ -70,6 +66,10 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price *
}()
}()
}
}
if
p
:=
Precompiled
[
string
(
me
.
Address
())];
p
!=
nil
{
return
self
.
RunPrecompiled
(
p
,
callData
,
context
)
}
var
(
var
(
op
OpCode
op
OpCode
...
@@ -513,10 +513,12 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price *
...
@@ -513,10 +513,12 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price *
// 0x40 range
// 0x40 range
case
BLOCKHASH
:
case
BLOCKHASH
:
num
:=
stack
.
Pop
()
num
:=
stack
.
Pop
()
if
num
.
Cmp
(
new
(
big
.
Int
)
.
Sub
(
self
.
env
.
BlockNumber
(),
ethutil
.
Big256
))
<
0
{
stack
.
Push
(
ethutil
.
Big0
)
n
:=
U256
(
new
(
big
.
Int
)
.
Sub
(
self
.
env
.
BlockNumber
(),
ethutil
.
Big257
)
)
}
else
{
if
num
.
Cmp
(
n
)
>
0
&&
num
.
Cmp
(
self
.
env
.
BlockNumber
())
<
0
{
stack
.
Push
(
ethutil
.
BigD
(
self
.
env
.
GetHash
(
num
.
Uint64
())))
stack
.
Push
(
ethutil
.
BigD
(
self
.
env
.
GetHash
(
num
.
Uint64
())))
}
else
{
stack
.
Push
(
ethutil
.
Big0
)
}
}
self
.
Printf
(
" => 0x%x"
,
stack
.
Peek
()
.
Bytes
())
self
.
Printf
(
" => 0x%x"
,
stack
.
Peek
()
.
Bytes
())
...
...
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