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
3bc57fe5
Commit
3bc57fe5
authored
Jun 18, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CALLDATALOAD return 32 byte at all times
parent
7f94bd09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
11 deletions
+31
-11
vm.go
ethchain/vm.go
+31
-11
No files found.
ethchain/vm.go
View file @
3bc57fe5
...
@@ -225,29 +225,41 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -225,29 +225,41 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case
ADD
:
case
ADD
:
require
(
2
)
require
(
2
)
x
,
y
:=
stack
.
Popn
()
x
,
y
:=
stack
.
Popn
()
// (x + y) % 2 ** 256
vm
.
Printf
(
" %v + %v"
,
y
,
x
)
base
.
Add
(
y
,
x
)
base
.
Add
(
y
,
x
)
vm
.
Printf
(
" = %v"
,
base
)
// Pop result back on the stack
// Pop result back on the stack
stack
.
Push
(
base
)
stack
.
Push
(
base
)
case
SUB
:
case
SUB
:
require
(
2
)
require
(
2
)
x
,
y
:=
stack
.
Popn
()
x
,
y
:=
stack
.
Popn
()
// (x - y) % 2 ** 256
vm
.
Printf
(
" %v - %v"
,
y
,
x
)
base
.
Sub
(
y
,
x
)
base
.
Sub
(
y
,
x
)
vm
.
Printf
(
" = %v"
,
base
)
// Pop result back on the stack
// Pop result back on the stack
stack
.
Push
(
base
)
stack
.
Push
(
base
)
case
MUL
:
case
MUL
:
require
(
2
)
require
(
2
)
x
,
y
:=
stack
.
Popn
()
x
,
y
:=
stack
.
Popn
()
// (x * y) % 2 ** 256
vm
.
Printf
(
" %v * %v"
,
y
,
x
)
base
.
Mul
(
y
,
x
)
base
.
Mul
(
y
,
x
)
vm
.
Printf
(
" = %v"
,
base
)
// Pop result back on the stack
// Pop result back on the stack
stack
.
Push
(
base
)
stack
.
Push
(
base
)
case
DIV
:
case
DIV
:
require
(
2
)
require
(
2
)
x
,
y
:=
stack
.
Popn
()
x
,
y
:=
stack
.
Popn
()
// floor(x / y)
vm
.
Printf
(
" %v / %v"
,
y
,
x
)
base
.
Div
(
y
,
x
)
base
.
Div
(
y
,
x
)
vm
.
Printf
(
" = %v"
,
base
)
// Pop result back on the stack
// Pop result back on the stack
stack
.
Push
(
base
)
stack
.
Push
(
base
)
case
SDIV
:
case
SDIV
:
...
@@ -270,7 +282,12 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -270,7 +282,12 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case
MOD
:
case
MOD
:
require
(
2
)
require
(
2
)
x
,
y
:=
stack
.
Popn
()
x
,
y
:=
stack
.
Popn
()
vm
.
Printf
(
" %v %% %v"
,
y
,
x
)
base
.
Mod
(
y
,
x
)
base
.
Mod
(
y
,
x
)
vm
.
Printf
(
" = %v"
,
base
)
stack
.
Push
(
base
)
stack
.
Push
(
base
)
case
SMOD
:
case
SMOD
:
require
(
2
)
require
(
2
)
...
@@ -292,8 +309,13 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -292,8 +309,13 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case
EXP
:
case
EXP
:
require
(
2
)
require
(
2
)
x
,
y
:=
stack
.
Popn
()
x
,
y
:=
stack
.
Popn
()
vm
.
Printf
(
" %v ** %v"
,
y
,
x
)
base
.
Exp
(
y
,
x
,
Pow256
)
base
.
Exp
(
y
,
x
,
Pow256
)
vm
.
Printf
(
" = %v"
,
base
)
stack
.
Push
(
base
)
stack
.
Push
(
base
)
case
NEG
:
case
NEG
:
require
(
1
)
require
(
1
)
...
@@ -393,12 +415,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -393,12 +415,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
require
(
1
)
require
(
1
)
offset
:=
stack
.
Pop
()
.
Int64
()
offset
:=
stack
.
Pop
()
.
Int64
()
var
data
[]
byte
data
:=
make
([]
byte
,
32
)
if
len
(
closure
.
Args
)
>=
int
(
offset
)
{
if
len
(
closure
.
Args
)
>=
int
(
offset
)
{
l
:=
int64
(
math
.
Min
(
float64
(
offset
+
32
),
float64
(
len
(
closure
.
Args
))))
l
:=
int64
(
math
.
Min
(
float64
(
offset
+
32
),
float64
(
len
(
closure
.
Args
))))
data
=
closure
.
Args
[
offset
:
offset
+
l
]
}
else
{
copy
(
data
,
closure
.
Args
[
offset
:
l
])
data
=
[]
byte
{
0
}
}
}
vm
.
Printf
(
" => 0x%x"
,
data
)
vm
.
Printf
(
" => 0x%x"
,
data
)
...
@@ -499,13 +520,12 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -499,13 +520,12 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case
SSTORE
:
case
SSTORE
:
require
(
2
)
require
(
2
)
val
,
loc
:=
stack
.
Popn
()
val
,
loc
:=
stack
.
Popn
()
fmt
.
Println
(
"storing"
,
string
(
val
.
Bytes
()),
"@"
,
string
(
loc
.
Bytes
()))
closure
.
SetStorage
(
loc
,
ethutil
.
NewValue
(
val
))
closure
.
SetStorage
(
loc
,
ethutil
.
NewValue
(
val
))
// 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
(
"
=> 0x%x"
,
val
)
vm
.
Printf
(
"
{0x%x} 0x%x"
,
loc
,
val
)
case
JUMP
:
case
JUMP
:
require
(
1
)
require
(
1
)
pc
=
stack
.
Pop
()
pc
=
stack
.
Pop
()
...
@@ -519,7 +539,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -519,7 +539,7 @@ 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
(
"
(t) ~> %v
"
,
pc
)
.
Endl
()
vm
.
Printf
(
"
~> %v (t)
"
,
pc
)
.
Endl
()
continue
continue
}
else
{
}
else
{
...
...
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