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
186948da
Commit
186948da
authored
Dec 10, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed to unsigned integers
parent
4f1ef89c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
20 deletions
+32
-20
gh_test.go
tests/vm/gh_test.go
+19
-7
stack.go
vm/stack.go
+2
-2
vm_debug.go
vm/vm_debug.go
+11
-11
No files found.
tests/vm/gh_test.go
View file @
186948da
...
@@ -20,9 +20,21 @@ type Account struct {
...
@@ -20,9 +20,21 @@ type Account struct {
}
}
type
Log
struct
{
type
Log
struct
{
Address
string
AddressF
string
`json:"address"`
Data
string
DataF
string
`json:"data"`
Topics
[]
string
TopicsF
[]
string
`json:"topics"`
BloomF
string
`json:"bloom"`
}
func
(
self
Log
)
Address
()
[]
byte
{
return
ethutil
.
Hex2Bytes
(
self
.
AddressF
)
}
func
(
self
Log
)
Data
()
[]
byte
{
return
ethutil
.
Hex2Bytes
(
self
.
DataF
)
}
func
(
self
Log
)
RlpData
()
interface
{}
{
return
nil
}
func
(
self
Log
)
Topics
()
[][]
byte
{
t
:=
make
([][]
byte
,
len
(
self
.
TopicsF
))
for
i
,
topic
:=
range
self
.
TopicsF
{
t
[
i
]
=
ethutil
.
Hex2Bytes
(
topic
)
}
return
t
}
}
func
StateObjectFromAccount
(
addr
string
,
account
Account
)
*
state
.
StateObject
{
func
StateObjectFromAccount
(
addr
string
,
account
Account
)
*
state
.
StateObject
{
...
@@ -53,7 +65,7 @@ type VmTest struct {
...
@@ -53,7 +65,7 @@ type VmTest struct {
Env
Env
Env
Env
Exec
map
[
string
]
string
Exec
map
[
string
]
string
Transaction
map
[
string
]
string
Transaction
map
[
string
]
string
Logs
map
[
string
]
Log
Logs
[
]
Log
Gas
string
Gas
string
Out
string
Out
string
Post
map
[
string
]
Account
Post
map
[
string
]
Account
...
@@ -128,10 +140,10 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -128,10 +140,10 @@ func RunVmTest(p string, t *testing.T) {
}
}
if
len
(
test
.
Logs
)
>
0
{
if
len
(
test
.
Logs
)
>
0
{
genBloom
:=
ethutil
.
LeftPadBytes
(
types
.
LogsBloom
(
logs
)
.
Bytes
(),
64
)
// Logs within the test itself aren't correct, missing empty fields (32 0s)
// Logs within the test itself aren't correct, missing empty fields (32 0s)
for
bloom
/*logs*/
,
_
:=
range
test
.
Logs
{
for
i
,
log
:=
range
test
.
Logs
{
if
!
bytes
.
Equal
(
genBloom
,
ethutil
.
Hex2Bytes
(
bloom
))
{
genBloom
:=
ethutil
.
LeftPadBytes
(
types
.
LogsBloom
(
state
.
Logs
{
logs
[
i
]})
.
Bytes
(),
64
)
if
!
bytes
.
Equal
(
genBloom
,
ethutil
.
Hex2Bytes
(
log
.
BloomF
))
{
t
.
Errorf
(
"bloom mismatch"
)
t
.
Errorf
(
"bloom mismatch"
)
}
}
}
}
...
...
vm/stack.go
View file @
186948da
...
@@ -111,10 +111,10 @@ func NewMemory() *Memory {
...
@@ -111,10 +111,10 @@ func NewMemory() *Memory {
return
&
Memory
{
nil
}
return
&
Memory
{
nil
}
}
}
func
(
m
*
Memory
)
Set
(
offset
,
size
int64
,
value
[]
byte
)
{
func
(
m
*
Memory
)
Set
(
offset
,
size
u
int64
,
value
[]
byte
)
{
if
len
(
value
)
>
0
{
if
len
(
value
)
>
0
{
totSize
:=
offset
+
size
totSize
:=
offset
+
size
lenSize
:=
int64
(
len
(
m
.
store
)
-
1
)
lenSize
:=
u
int64
(
len
(
m
.
store
)
-
1
)
if
totSize
>
lenSize
{
if
totSize
>
lenSize
{
// Calculate the diff between the sizes
// Calculate the diff between the sizes
diff
:=
totSize
-
lenSize
diff
:=
totSize
-
lenSize
...
...
vm/vm_debug.go
View file @
186948da
...
@@ -98,7 +98,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
...
@@ -98,7 +98,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
}
else
{
}
else
{
nop
:=
OpCode
(
closure
.
GetOp
(
p
))
nop
:=
OpCode
(
closure
.
GetOp
(
p
))
if
!
(
nop
==
JUMPDEST
||
destinations
[
from
]
!=
nil
)
{
if
!
(
nop
==
JUMPDEST
||
destinations
[
from
]
!=
nil
)
{
panic
(
fmt
.
Sprintf
(
"
JUMP missed JUMPDEST
(%v) %v"
,
nop
,
p
))
panic
(
fmt
.
Sprintf
(
"
invalid jump destination
(%v) %v"
,
nop
,
p
))
}
else
if
nop
==
JUMP
||
nop
==
JUMPI
{
}
else
if
nop
==
JUMP
||
nop
==
JUMPI
{
panic
(
fmt
.
Sprintf
(
"not allowed to JUMP(I) in to JUMP"
))
panic
(
fmt
.
Sprintf
(
"not allowed to JUMP(I) in to JUMP"
))
}
}
...
@@ -611,10 +611,10 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
...
@@ -611,10 +611,10 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
self
.
Printf
(
" => %d"
,
l
)
self
.
Printf
(
" => %d"
,
l
)
case
CALLDATACOPY
:
case
CALLDATACOPY
:
var
(
var
(
size
=
int64
(
len
(
callData
))
size
=
u
int64
(
len
(
callData
))
mOff
=
stack
.
Pop
()
.
I
nt64
()
mOff
=
stack
.
Pop
()
.
Ui
nt64
()
cOff
=
stack
.
Pop
()
.
I
nt64
()
cOff
=
stack
.
Pop
()
.
Ui
nt64
()
l
=
stack
.
Pop
()
.
I
nt64
()
l
=
stack
.
Pop
()
.
Ui
nt64
()
)
)
if
cOff
>
size
{
if
cOff
>
size
{
...
@@ -654,10 +654,10 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
...
@@ -654,10 +654,10 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
}
}
var
(
var
(
size
=
int64
(
len
(
code
))
size
=
u
int64
(
len
(
code
))
mOff
=
stack
.
Pop
()
.
I
nt64
()
mOff
=
stack
.
Pop
()
.
Ui
nt64
()
cOff
=
stack
.
Pop
()
.
I
nt64
()
cOff
=
stack
.
Pop
()
.
Ui
nt64
()
l
=
stack
.
Pop
()
.
I
nt64
()
l
=
stack
.
Pop
()
.
Ui
nt64
()
)
)
if
cOff
>
size
{
if
cOff
>
size
{
...
@@ -760,7 +760,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
...
@@ -760,7 +760,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
case
MSTORE
:
// Store the value at stack top-1 in to memory at location stack top
case
MSTORE
:
// Store the value at stack top-1 in to memory at location stack top
// Pop value of the stack
// Pop value of the stack
val
,
mStart
:=
stack
.
Popn
()
val
,
mStart
:=
stack
.
Popn
()
mem
.
Set
(
mStart
.
I
nt64
(),
32
,
ethutil
.
BigToBytes
(
val
,
256
))
mem
.
Set
(
mStart
.
Ui
nt64
(),
32
,
ethutil
.
BigToBytes
(
val
,
256
))
self
.
Printf
(
" => 0x%x"
,
val
)
self
.
Printf
(
" => 0x%x"
,
val
)
case
MSTORE8
:
case
MSTORE8
:
...
@@ -883,7 +883,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
...
@@ -883,7 +883,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
stack
.
Push
(
ethutil
.
BigTrue
)
stack
.
Push
(
ethutil
.
BigTrue
)
msg
.
Output
=
ret
msg
.
Output
=
ret
mem
.
Set
(
retOffset
.
Int64
(),
retSize
.
I
nt64
(),
ret
)
mem
.
Set
(
retOffset
.
Uint64
(),
retSize
.
Ui
nt64
(),
ret
)
}
}
self
.
Printf
(
"resume %x"
,
closure
.
Address
())
self
.
Printf
(
"resume %x"
,
closure
.
Address
())
...
...
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