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
df5901fd
Commit
df5901fd
authored
Mar 19, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed more casts
parent
013427bd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
24 deletions
+14
-24
main.go
cmd/ethtest/main.go
+1
-2
big.go
common/big.go
+2
-2
common.go
vm/common.go
+5
-4
context.go
vm/context.go
+0
-4
vm.go
vm/vm.go
+6
-12
No files found.
cmd/ethtest/main.go
View file @
df5901fd
...
...
@@ -24,7 +24,6 @@ package main
import
(
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
...
...
@@ -210,7 +209,7 @@ func RunVmTest(r io.Reader) (failed int) {
}
if
failed
==
1
{
fmt
.
Print
ln
(
string
(
statedb
.
Dump
()))
helper
.
Log
.
Info
ln
(
string
(
statedb
.
Dump
()))
}
logger
.
Flush
()
...
...
common/big.go
View file @
df5901fd
...
...
@@ -104,7 +104,7 @@ func BigCopy(src *big.Int) *big.Int {
//
// Returns the maximum size big integer
func
BigMax
(
x
,
y
*
big
.
Int
)
*
big
.
Int
{
if
x
.
Cmp
(
y
)
<
=
0
{
if
x
.
Cmp
(
y
)
<
0
{
return
y
}
...
...
@@ -115,7 +115,7 @@ func BigMax(x, y *big.Int) *big.Int {
//
// Returns the minimum size big integer
func
BigMin
(
x
,
y
*
big
.
Int
)
*
big
.
Int
{
if
x
.
Cmp
(
y
)
>
=
0
{
if
x
.
Cmp
(
y
)
>
0
{
return
y
}
...
...
vm/common.go
View file @
df5901fd
...
...
@@ -73,9 +73,10 @@ func toValue(val *big.Int) interface{} {
return
val
}
func
getData
(
data
[]
byte
,
start
,
size
uint64
)
[]
byte
{
x
:=
uint64
(
math
.
Min
(
float64
(
start
),
float64
(
len
(
data
))))
y
:=
uint64
(
math
.
Min
(
float64
(
x
+
size
),
float64
(
len
(
data
))))
func
getData
(
data
[]
byte
,
start
,
size
*
big
.
Int
)
[]
byte
{
dlen
:=
big
.
NewInt
(
int64
(
len
(
data
)))
return
common
.
RightPadBytes
(
data
[
x
:
y
],
int
(
size
))
s
:=
common
.
BigMin
(
start
,
dlen
)
e
:=
common
.
BigMin
(
new
(
big
.
Int
)
.
Add
(
s
,
size
),
dlen
)
return
common
.
RightPadBytes
(
data
[
s
.
Uint64
()
:
e
.
Uint64
()],
int
(
size
.
Uint64
()))
}
vm/context.go
View file @
df5901fd
...
...
@@ -64,10 +64,6 @@ func (c *Context) GetRangeValue(x, size uint64) []byte {
return
common
.
RightPadBytes
(
c
.
Code
[
x
:
y
],
int
(
size
))
}
func
(
c
*
Context
)
GetCode
(
x
,
size
uint64
)
[]
byte
{
return
getData
(
c
.
Code
,
x
,
size
)
}
func
(
c
*
Context
)
Return
(
ret
[]
byte
)
[]
byte
{
// Return the remaining gas to the caller
c
.
caller
.
ReturnGas
(
c
.
Gas
,
c
.
Price
)
...
...
vm/vm.go
View file @
df5901fd
...
...
@@ -445,14 +445,11 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
cOff
=
stack
.
pop
()
l
=
stack
.
pop
()
)
var
data
[]
byte
if
cOff
.
Cmp
(
big
.
NewInt
(
int64
(
len
(
callData
))))
<=
0
{
data
=
getData
(
callData
,
cOff
.
Uint64
(),
l
.
Uint64
())
}
data
:=
getData
(
callData
,
cOff
,
l
)
mem
.
Set
(
mOff
.
Uint64
(),
l
.
Uint64
(),
data
)
self
.
Printf
(
" => [%v, %v, %v]
%x"
,
mOff
,
cOff
,
l
,
data
)
self
.
Printf
(
" => [%v, %v, %v]
"
,
mOff
,
cOff
,
l
)
case
CODESIZE
,
EXTCODESIZE
:
var
code
[]
byte
if
op
==
EXTCODESIZE
{
...
...
@@ -482,10 +479,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
l
=
stack
.
pop
()
)
var
codeCopy
[]
byte
if
cOff
.
Cmp
(
big
.
NewInt
(
int64
(
len
(
code
))))
<=
0
{
codeCopy
=
getData
(
code
,
cOff
.
Uint64
(),
l
.
Uint64
())
}
codeCopy
:=
getData
(
code
,
cOff
,
l
)
mem
.
Set
(
mOff
.
Uint64
(),
l
.
Uint64
(),
codeCopy
)
...
...
@@ -585,11 +579,11 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
self
.
Printf
(
" => 0x%x"
,
val
)
case
MSTORE8
:
off
,
val
:=
stack
.
pop
()
,
stack
.
pop
()
off
,
val
:=
stack
.
pop
()
.
Int64
(),
stack
.
pop
()
.
Int64
()
mem
.
store
[
off
.
Int64
()]
=
byte
(
val
.
Int64
()
&
0xff
)
mem
.
store
[
off
]
=
byte
(
val
&
0xff
)
self
.
Printf
(
" => [%v] 0x%x"
,
off
,
val
)
self
.
Printf
(
" => [%v] 0x%x"
,
off
,
mem
.
store
[
off
]
)
case
SLOAD
:
loc
:=
common
.
BigToHash
(
stack
.
pop
())
val
:=
common
.
Bytes2Big
(
statedb
.
GetState
(
context
.
Address
(),
loc
))
...
...
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