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
8a885c26
Commit
8a885c26
authored
Jun 17, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed GT and LT
parent
ca79360f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
13 deletions
+26
-13
asm.go
ethchain/asm.go
+1
-1
types.go
ethchain/types.go
+1
-1
vm.go
ethchain/vm.go
+24
-11
No files found.
ethchain/asm.go
View file @
8a885c26
...
@@ -28,7 +28,7 @@ func Disassemble(script []byte) (asm []string) {
...
@@ -28,7 +28,7 @@ func Disassemble(script []byte) (asm []string) {
if
len
(
data
)
==
0
{
if
len
(
data
)
==
0
{
data
=
[]
byte
{
0
}
data
=
[]
byte
{
0
}
}
}
asm
=
append
(
asm
,
fmt
.
Sprintf
(
"
%#
x"
,
data
))
asm
=
append
(
asm
,
fmt
.
Sprintf
(
"
0x%
x"
,
data
))
pc
.
Add
(
pc
,
big
.
NewInt
(
a
-
1
))
pc
.
Add
(
pc
,
big
.
NewInt
(
a
-
1
))
}
}
...
...
ethchain/types.go
View file @
8a885c26
...
@@ -226,7 +226,7 @@ var opCodeToString = map[OpCode]string{
...
@@ -226,7 +226,7 @@ var opCodeToString = map[OpCode]string{
func
(
o
OpCode
)
String
()
string
{
func
(
o
OpCode
)
String
()
string
{
str
:=
opCodeToString
[
o
]
str
:=
opCodeToString
[
o
]
if
len
(
str
)
==
0
{
if
len
(
str
)
==
0
{
return
fmt
.
Sprintf
(
"Missing opcode
%#
x"
,
int
(
o
))
return
fmt
.
Sprintf
(
"Missing opcode
0x%
x"
,
int
(
o
))
}
}
return
str
return
str
...
...
ethchain/vm.go
View file @
8a885c26
...
@@ -97,7 +97,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -97,7 +97,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
}
}
}()
}()
ethutil
.
Config
.
Log
.
Debugf
(
"[VM] Running
closure
%x
\n
"
,
closure
.
object
.
Address
())
ethutil
.
Config
.
Log
.
Debugf
(
"[VM] Running %x
\n
"
,
closure
.
object
.
Address
())
// Memory for the current closure
// Memory for the current closure
mem
:=
&
Memory
{}
mem
:=
&
Memory
{}
...
@@ -301,7 +301,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -301,7 +301,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
stack
.
Push
(
base
)
stack
.
Push
(
base
)
case
LT
:
case
LT
:
require
(
2
)
require
(
2
)
x
,
y
:=
stack
.
Popn
()
y
,
x
:=
stack
.
Popn
()
// x < y
// x < y
if
x
.
Cmp
(
y
)
<
0
{
if
x
.
Cmp
(
y
)
<
0
{
stack
.
Push
(
ethutil
.
BigTrue
)
stack
.
Push
(
ethutil
.
BigTrue
)
...
@@ -310,7 +310,9 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -310,7 +310,9 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
}
}
case
GT
:
case
GT
:
require
(
2
)
require
(
2
)
x
,
y
:=
stack
.
Popn
()
y
,
x
:=
stack
.
Popn
()
vm
.
Printf
(
" %v > %v"
,
x
,
y
)
// x > y
// x > y
if
x
.
Cmp
(
y
)
>
0
{
if
x
.
Cmp
(
y
)
>
0
{
stack
.
Push
(
ethutil
.
BigTrue
)
stack
.
Push
(
ethutil
.
BigTrue
)
...
@@ -382,7 +384,10 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -382,7 +384,10 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case
ORIGIN
:
case
ORIGIN
:
stack
.
Push
(
ethutil
.
BigD
(
vm
.
vars
.
Origin
))
stack
.
Push
(
ethutil
.
BigD
(
vm
.
vars
.
Origin
))
case
CALLER
:
case
CALLER
:
stack
.
Push
(
ethutil
.
BigD
(
closure
.
caller
.
Address
()))
caller
:=
closure
.
caller
.
Address
()
stack
.
Push
(
ethutil
.
BigD
(
caller
))
vm
.
Printf
(
" => %x"
,
caller
)
case
CALLVALUE
:
case
CALLVALUE
:
stack
.
Push
(
vm
.
vars
.
Value
)
stack
.
Push
(
vm
.
vars
.
Value
)
case
CALLDATALOAD
:
case
CALLDATALOAD
:
...
@@ -397,10 +402,14 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -397,10 +402,14 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
data
=
[]
byte
{
0
}
data
=
[]
byte
{
0
}
}
}
fmt
.
Println
(
"CALLDATALOAD"
,
string
(
data
),
len
(
data
),
"=="
,
len
(
closure
.
Args
))
vm
.
Printf
(
" => 0x%x"
,
data
)
stack
.
Push
(
ethutil
.
BigD
(
data
))
stack
.
Push
(
ethutil
.
BigD
(
data
))
case
CALLDATASIZE
:
case
CALLDATASIZE
:
stack
.
Push
(
big
.
NewInt
(
int64
(
len
(
closure
.
Args
))))
l
:=
int64
(
len
(
closure
.
Args
))
stack
.
Push
(
big
.
NewInt
(
l
))
vm
.
Printf
(
" => %d"
,
l
)
case
CALLDATACOPY
:
case
CALLDATACOPY
:
case
CODESIZE
:
case
CODESIZE
:
case
CODECOPY
:
case
CODECOPY
:
...
@@ -451,7 +460,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -451,7 +460,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
step
+=
int
(
op
)
-
int
(
PUSH1
)
+
1
step
+=
int
(
op
)
-
int
(
PUSH1
)
+
1
vm
.
Printf
(
" =>
%#
x"
,
data
.
Bytes
())
vm
.
Printf
(
" =>
0x%
x"
,
data
.
Bytes
())
case
POP
:
case
POP
:
require
(
1
)
require
(
1
)
stack
.
Pop
()
stack
.
Pop
()
...
@@ -473,19 +482,21 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -473,19 +482,21 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
val
,
mStart
:=
stack
.
Popn
()
val
,
mStart
:=
stack
.
Popn
()
mem
.
Set
(
mStart
.
Int64
(),
32
,
ethutil
.
BigToBytes
(
val
,
256
))
mem
.
Set
(
mStart
.
Int64
(),
32
,
ethutil
.
BigToBytes
(
val
,
256
))
vm
.
Printf
(
" =>
%#
x"
,
val
)
vm
.
Printf
(
" =>
0x%
x"
,
val
)
case
MSTORE8
:
case
MSTORE8
:
require
(
2
)
require
(
2
)
val
,
mStart
:=
stack
.
Popn
()
val
,
mStart
:=
stack
.
Popn
()
base
.
And
(
val
,
new
(
big
.
Int
)
.
SetInt64
(
0xff
))
base
.
And
(
val
,
new
(
big
.
Int
)
.
SetInt64
(
0xff
))
mem
.
Set
(
mStart
.
Int64
(),
32
,
ethutil
.
BigToBytes
(
base
,
256
))
mem
.
Set
(
mStart
.
Int64
(),
32
,
ethutil
.
BigToBytes
(
base
,
256
))
vm
.
Printf
(
" =>
%#
x"
,
val
)
vm
.
Printf
(
" =>
0x%
x"
,
val
)
case
SLOAD
:
case
SLOAD
:
require
(
1
)
require
(
1
)
loc
:=
stack
.
Pop
()
loc
:=
stack
.
Pop
()
val
:=
closure
.
GetMem
(
loc
)
val
:=
closure
.
GetMem
(
loc
)
stack
.
Push
(
val
.
BigInt
())
stack
.
Push
(
val
.
BigInt
())
vm
.
Printf
(
" {} 0x%x"
,
val
)
case
SSTORE
:
case
SSTORE
:
require
(
2
)
require
(
2
)
val
,
loc
:=
stack
.
Popn
()
val
,
loc
:=
stack
.
Popn
()
...
@@ -495,7 +506,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -495,7 +506,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
// Add the change to manifest
// Add the change to manifest
vm
.
state
.
manifest
.
AddStorageChange
(
closure
.
Object
(),
loc
.
Bytes
(),
val
)
vm
.
state
.
manifest
.
AddStorageChange
(
closure
.
Object
(),
loc
.
Bytes
(),
val
)
vm
.
Printf
(
" =>
%#
x"
,
val
)
vm
.
Printf
(
" =>
0x%
x"
,
val
)
case
JUMP
:
case
JUMP
:
require
(
1
)
require
(
1
)
pc
=
stack
.
Pop
()
pc
=
stack
.
Pop
()
...
@@ -509,9 +520,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -509,9 +520,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
if
cond
.
Cmp
(
ethutil
.
BigTrue
)
>=
0
{
if
cond
.
Cmp
(
ethutil
.
BigTrue
)
>=
0
{
pc
=
pos
pc
=
pos
vm
.
Printf
(
" ~> %v"
,
pc
)
.
Endl
()
vm
.
Printf
(
"
(t)
~> %v"
,
pc
)
.
Endl
()
continue
continue
}
else
{
vm
.
Printf
(
" (f)"
)
}
}
case
PC
:
case
PC
:
stack
.
Push
(
pc
)
stack
.
Push
(
pc
)
...
...
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