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
cf45b939
Commit
cf45b939
authored
Mar 19, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed tests
parent
d7ab716e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
20 deletions
+16
-20
trie.go
trie/trie.go
+7
-2
common.go
vm/common.go
+4
-4
context.go
vm/context.go
+1
-1
vm.go
vm/vm.go
+4
-13
No files found.
trie/trie.go
View file @
cf45b939
...
@@ -302,12 +302,17 @@ func (self *Trie) mknode(value *common.Value) Node {
...
@@ -302,12 +302,17 @@ func (self *Trie) mknode(value *common.Value) Node {
case
2
:
case
2
:
// A value node may consists of 2 bytes.
// A value node may consists of 2 bytes.
if
value
.
Get
(
0
)
.
Len
()
!=
0
{
if
value
.
Get
(
0
)
.
Len
()
!=
0
{
return
NewShortNode
(
self
,
CompactDecode
(
string
(
value
.
Get
(
0
)
.
Bytes
())),
self
.
mknode
(
value
.
Get
(
1
)))
key
:=
CompactDecode
(
string
(
value
.
Get
(
0
)
.
Bytes
()))
if
key
[
len
(
key
)
-
1
]
==
16
{
return
NewShortNode
(
self
,
key
,
&
ValueNode
{
self
,
value
.
Get
(
1
)
.
Bytes
()})
}
else
{
return
NewShortNode
(
self
,
key
,
self
.
mknode
(
value
.
Get
(
1
)))
}
}
}
case
17
:
case
17
:
if
len
(
value
.
Bytes
())
!=
17
{
if
len
(
value
.
Bytes
())
!=
17
{
fnode
:=
NewFullNode
(
self
)
fnode
:=
NewFullNode
(
self
)
for
i
:=
0
;
i
<
l
;
i
++
{
for
i
:=
0
;
i
<
16
;
i
++
{
fnode
.
set
(
byte
(
i
),
self
.
mknode
(
value
.
Get
(
i
)))
fnode
.
set
(
byte
(
i
),
self
.
mknode
(
value
.
Get
(
i
)))
}
}
return
fnode
return
fnode
...
...
vm/common.go
View file @
cf45b939
...
@@ -119,9 +119,9 @@ func toValue(val *big.Int) interface{} {
...
@@ -119,9 +119,9 @@ func toValue(val *big.Int) interface{} {
return
val
return
val
}
}
func
get
Code
(
code
[]
byte
,
start
,
size
uint64
)
[]
byte
{
func
get
Data
(
data
[]
byte
,
start
,
size
uint64
)
[]
byte
{
x
:=
uint64
(
math
.
Min
(
float64
(
start
),
float64
(
len
(
code
))))
x
:=
uint64
(
math
.
Min
(
float64
(
start
),
float64
(
len
(
data
))))
y
:=
uint64
(
math
.
Min
(
float64
(
x
+
size
),
float64
(
len
(
code
))))
y
:=
uint64
(
math
.
Min
(
float64
(
x
+
size
),
float64
(
len
(
data
))))
return
common
.
RightPadBytes
(
code
[
x
:
y
],
int
(
size
))
return
common
.
RightPadBytes
(
data
[
x
:
y
],
int
(
size
))
}
}
vm/context.go
View file @
cf45b939
...
@@ -65,7 +65,7 @@ func (c *Context) GetRangeValue(x, size uint64) []byte {
...
@@ -65,7 +65,7 @@ func (c *Context) GetRangeValue(x, size uint64) []byte {
}
}
func
(
c
*
Context
)
GetCode
(
x
,
size
uint64
)
[]
byte
{
func
(
c
*
Context
)
GetCode
(
x
,
size
uint64
)
[]
byte
{
return
get
Code
(
c
.
Code
,
x
,
size
)
return
get
Data
(
c
.
Code
,
x
,
size
)
}
}
func
(
c
*
Context
)
Return
(
ret
[]
byte
)
[]
byte
{
func
(
c
*
Context
)
Return
(
ret
[]
byte
)
[]
byte
{
...
...
vm/vm.go
View file @
cf45b939
...
@@ -443,24 +443,15 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
...
@@ -443,24 +443,15 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
self
.
Printf
(
" => %d"
,
l
)
self
.
Printf
(
" => %d"
,
l
)
case
CALLDATACOPY
:
case
CALLDATACOPY
:
var
(
var
(
size
=
uint64
(
len
(
callData
))
mOff
=
stack
.
pop
()
.
Uint64
()
mOff
=
stack
.
pop
()
.
Uint64
()
cOff
=
stack
.
pop
()
.
Uint64
()
cOff
=
stack
.
pop
()
.
Uint64
()
l
=
stack
.
pop
()
.
Uint64
()
l
=
stack
.
pop
()
.
Uint64
()
)
)
data
:=
getData
(
callData
,
cOff
,
l
)
if
cOff
>
size
{
mem
.
Set
(
mOff
,
l
,
data
)
cOff
=
0
l
=
0
}
else
if
cOff
+
l
>
size
{
l
=
0
}
code
:=
callData
[
cOff
:
cOff
+
l
]
mem
.
Set
(
mOff
,
l
,
code
)
self
.
Printf
(
" => [%v, %v, %v] %x"
,
mOff
,
cOff
,
l
,
callData
[
cOff
:
cOff
+
l
]
)
self
.
Printf
(
" => [%v, %v, %v] %x"
,
mOff
,
cOff
,
l
,
data
)
case
CODESIZE
,
EXTCODESIZE
:
case
CODESIZE
,
EXTCODESIZE
:
var
code
[]
byte
var
code
[]
byte
if
op
==
EXTCODESIZE
{
if
op
==
EXTCODESIZE
{
...
@@ -487,7 +478,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
...
@@ -487,7 +478,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
cOff
=
stack
.
pop
()
.
Uint64
()
cOff
=
stack
.
pop
()
.
Uint64
()
l
=
stack
.
pop
()
.
Uint64
()
l
=
stack
.
pop
()
.
Uint64
()
)
)
codeCopy
:=
get
Code
(
code
,
cOff
,
l
)
codeCopy
:=
get
Data
(
code
,
cOff
,
l
)
mem
.
Set
(
mOff
,
l
,
codeCopy
)
mem
.
Set
(
mOff
,
l
,
codeCopy
)
...
...
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