good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
8a885c26
Commit
8a885c26
authored
Jun 17, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Fixed GT and LT
parent
ca79360f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ethchain/asm.go
+1
-1
1 addition, 1 deletion
ethchain/asm.go
ethchain/types.go
+1
-1
1 addition, 1 deletion
ethchain/types.go
ethchain/vm.go
+24
-11
24 additions, 11 deletions
ethchain/vm.go
with
26 additions
and
13 deletions
ethchain/asm.go
+
1
−
1
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
))
}
}
...
...
This diff is collapsed.
Click to expand it.
ethchain/types.go
+
1
−
1
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
...
...
This diff is collapsed.
Click to expand it.
ethchain/vm.go
+
24
−
11
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment