Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
06aa74e7
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
06aa74e7
编写于
10月 23, 2014
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
All Stack requirements are now checked prior to reduring gas.
上级
29b8a0bc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
37 deletion
+19
-37
vm/vm_debug.go
vm/vm_debug.go
+19
-37
未找到文件。
vm/vm_debug.go
浏览文件 @
06aa74e7
...
...
@@ -138,13 +138,31 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
addStepGasUsage
(
GasStep
)
var
newMemSize
*
big
.
Int
=
ethutil
.
Big0
// Stack Check, memory resize & gas phase
switch
op
{
// Stack checks only
case
NOT
,
CALLDATALOAD
,
POP
,
JUMP
,
NEG
:
// 1
require
(
1
)
case
ADD
,
SUB
,
DIV
,
SDIV
,
MOD
,
SMOD
,
EXP
,
LT
,
GT
,
SLT
,
SGT
,
EQ
,
AND
,
OR
,
XOR
,
BYTE
:
// 2
require
(
2
)
case
ADDMOD
,
MULMOD
:
// 3
require
(
3
)
case
SWAP1
,
SWAP2
,
SWAP3
,
SWAP4
,
SWAP5
,
SWAP6
,
SWAP7
,
SWAP8
,
SWAP9
,
SWAP10
,
SWAP11
,
SWAP12
,
SWAP13
,
SWAP14
,
SWAP15
,
SWAP16
:
n
:=
int
(
op
-
SWAP1
+
2
)
require
(
n
)
case
DUP1
,
DUP2
,
DUP3
,
DUP4
,
DUP5
,
DUP6
,
DUP7
,
DUP8
,
DUP9
,
DUP10
,
DUP11
,
DUP12
,
DUP13
,
DUP14
,
DUP15
,
DUP16
:
n
:=
int
(
op
-
DUP1
+
1
)
require
(
n
)
// Gas only
case
STOP
:
gas
.
Set
(
ethutil
.
Big0
)
case
SUICIDE
:
require
(
1
)
gas
.
Set
(
ethutil
.
Big0
)
case
SLOAD
:
gas
.
Set
(
GasSLoad
)
// Memory resize & Gas
case
SSTORE
:
var
mult
*
big
.
Int
y
,
x
:=
stack
.
Peekn
()
...
...
@@ -158,6 +176,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
}
gas
=
new
(
big
.
Int
)
.
Mul
(
mult
,
GasSStore
)
case
BALANCE
:
require
(
1
)
gas
.
Set
(
GasBalance
)
case
MSTORE
:
require
(
2
)
...
...
@@ -239,7 +258,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
switch
op
{
// 0x20 range
case
ADD
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
self
.
Printf
(
" %v + %v"
,
y
,
x
)
...
...
@@ -251,7 +269,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
// Pop result back on the stack
stack
.
Push
(
base
)
case
SUB
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
self
.
Printf
(
" %v - %v"
,
y
,
x
)
...
...
@@ -263,7 +280,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
// Pop result back on the stack
stack
.
Push
(
base
)
case
MUL
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
self
.
Printf
(
" %v * %v"
,
y
,
x
)
...
...
@@ -275,7 +291,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
// Pop result back on the stack
stack
.
Push
(
base
)
case
DIV
:
require
(
2
)
x
,
y
:=
stack
.
Pop
(),
stack
.
Pop
()
self
.
Printf
(
" %v / %v"
,
x
,
y
)
...
...
@@ -289,7 +304,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
// Pop result back on the stack
stack
.
Push
(
base
)
case
SDIV
:
require
(
2
)
x
,
y
:=
S256
(
stack
.
Pop
()),
S256
(
stack
.
Pop
())
self
.
Printf
(
" %v / %v"
,
x
,
y
)
...
...
@@ -312,7 +326,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
self
.
Printf
(
" = %v"
,
base
)
stack
.
Push
(
base
)
case
MOD
:
require
(
2
)
x
,
y
:=
stack
.
Pop
(),
stack
.
Pop
()
self
.
Printf
(
" %v %% %v"
,
x
,
y
)
...
...
@@ -328,7 +341,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
self
.
Printf
(
" = %v"
,
base
)
stack
.
Push
(
base
)
case
SMOD
:
require
(
2
)
x
,
y
:=
S256
(
stack
.
Pop
()),
S256
(
stack
.
Pop
())
self
.
Printf
(
" %v %% %v"
,
x
,
y
)
...
...
@@ -352,7 +364,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
stack
.
Push
(
base
)
case
EXP
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
self
.
Printf
(
" %v ** %v"
,
y
,
x
)
...
...
@@ -365,14 +376,12 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
stack
.
Push
(
base
)
case
NEG
:
require
(
1
)
base
.
Sub
(
Pow256
,
stack
.
Pop
())
base
=
U256
(
base
)
stack
.
Push
(
base
)
case
LT
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
self
.
Printf
(
" %v < %v"
,
y
,
x
)
// x < y
...
...
@@ -382,7 +391,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
stack
.
Push
(
ethutil
.
BigFalse
)
}
case
GT
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
self
.
Printf
(
" %v > %v"
,
y
,
x
)
...
...
@@ -394,7 +402,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
}
case
SLT
:
require
(
2
)
y
,
x
:=
S256
(
stack
.
Pop
()),
S256
(
stack
.
Pop
())
self
.
Printf
(
" %v < %v"
,
y
,
x
)
// x < y
...
...
@@ -404,7 +411,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
stack
.
Push
(
ethutil
.
BigFalse
)
}
case
SGT
:
require
(
2
)
y
,
x
:=
S256
(
stack
.
Pop
()),
S256
(
stack
.
Pop
())
self
.
Printf
(
" %v > %v"
,
y
,
x
)
...
...
@@ -416,7 +422,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
}
case
EQ
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
self
.
Printf
(
" %v == %v"
,
y
,
x
)
...
...
@@ -427,7 +432,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
stack
.
Push
(
ethutil
.
BigFalse
)
}
case
NOT
:
require
(
1
)
x
:=
stack
.
Pop
()
if
x
.
Cmp
(
ethutil
.
BigFalse
)
>
0
{
stack
.
Push
(
ethutil
.
BigFalse
)
...
...
@@ -437,25 +441,21 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
// 0x10 range
case
AND
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
self
.
Printf
(
" %v & %v"
,
y
,
x
)
stack
.
Push
(
base
.
And
(
y
,
x
))
case
OR
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
self
.
Printf
(
" %v | %v"
,
y
,
x
)
stack
.
Push
(
base
.
Or
(
y
,
x
))
case
XOR
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
self
.
Printf
(
" %v ^ %v"
,
y
,
x
)
stack
.
Push
(
base
.
Xor
(
y
,
x
))
case
BYTE
:
require
(
2
)
val
,
th
:=
stack
.
Popn
()
if
th
.
Cmp
(
big
.
NewInt
(
32
))
<
0
{
...
...
@@ -470,7 +470,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
stack
.
Push
(
base
)
case
ADDMOD
:
require
(
3
)
x
:=
stack
.
Pop
()
y
:=
stack
.
Pop
()
...
...
@@ -485,7 +484,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
stack
.
Push
(
base
)
case
MULMOD
:
require
(
3
)
x
:=
stack
.
Pop
()
y
:=
stack
.
Pop
()
...
...
@@ -502,7 +500,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
// 0x20 range
case
SHA3
:
require
(
2
)
size
,
offset
:=
stack
.
Popn
()
data
:=
ethcrypto
.
Sha3
(
mem
.
Get
(
offset
.
Int64
(),
size
.
Int64
()))
...
...
@@ -515,7 +512,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
self
.
Printf
(
" => %x"
,
closure
.
Address
())
case
BALANCE
:
require
(
1
)
addr
:=
stack
.
Pop
()
.
Bytes
()
balance
:=
state
.
GetBalance
(
addr
)
...
...
@@ -541,7 +537,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
self
.
Printf
(
" => %v"
,
value
)
case
CALLDATALOAD
:
require
(
1
)
var
(
offset
=
stack
.
Pop
()
data
=
make
([]
byte
,
32
)
...
...
@@ -675,7 +670,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
self
.
Printf
(
" => 0x%x"
,
data
.
Bytes
())
case
POP
:
require
(
1
)
stack
.
Pop
()
case
DUP1
,
DUP2
,
DUP3
,
DUP4
,
DUP5
,
DUP6
,
DUP7
,
DUP8
,
DUP9
,
DUP10
,
DUP11
,
DUP12
,
DUP13
,
DUP14
,
DUP15
,
DUP16
:
n
:=
int
(
op
-
DUP1
+
1
)
...
...
@@ -692,21 +686,18 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
self
.
Printf
(
" => [%d] %x [0] %x"
,
n
,
x
.
Bytes
(),
y
.
Bytes
())
case
MLOAD
:
require
(
1
)
offset
:=
stack
.
Pop
()
val
:=
ethutil
.
BigD
(
mem
.
Get
(
offset
.
Int64
(),
32
))
stack
.
Push
(
val
)
self
.
Printf
(
" => 0x%x"
,
val
.
Bytes
())
case
MSTORE
:
// Store the value at stack top-1 in to memory at location stack top
require
(
2
)
// Pop value of the stack
val
,
mStart
:=
stack
.
Popn
()
mem
.
Set
(
mStart
.
Int64
(),
32
,
ethutil
.
BigToBytes
(
val
,
256
))
self
.
Printf
(
" => 0x%x"
,
val
)
case
MSTORE8
:
require
(
2
)
off
:=
stack
.
Pop
()
val
:=
stack
.
Pop
()
...
...
@@ -714,14 +705,12 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
self
.
Printf
(
" => [%v] 0x%x"
,
off
,
val
)
case
SLOAD
:
require
(
1
)
loc
:=
stack
.
Pop
()
val
:=
ethutil
.
BigD
(
state
.
GetState
(
closure
.
Address
(),
loc
.
Bytes
()))
stack
.
Push
(
val
)
self
.
Printf
(
" {0x%x : 0x%x}"
,
loc
.
Bytes
(),
val
.
Bytes
())
case
SSTORE
:
require
(
2
)
val
,
loc
:=
stack
.
Popn
()
state
.
SetState
(
closure
.
Address
(),
loc
.
Bytes
(),
val
)
...
...
@@ -732,13 +721,11 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
self
.
Printf
(
" {0x%x : 0x%x}"
,
loc
.
Bytes
(),
val
.
Bytes
())
case
JUMP
:
require
(
1
)
jump
(
stack
.
Pop
())
continue
case
JUMPI
:
require
(
2
)
cond
,
pos
:=
stack
.
Popn
()
if
cond
.
Cmp
(
ethutil
.
BigTrue
)
>=
0
{
...
...
@@ -756,7 +743,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
stack
.
Push
(
closure
.
Gas
)
// 0x60 range
case
CREATE
:
require
(
3
)
var
(
err
error
...
...
@@ -801,8 +787,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
self
.
Dbg
.
SetCode
(
closure
.
Code
)
}
case
CALL
,
CALLCODE
:
require
(
7
)
self
.
Endl
()
gas
:=
stack
.
Pop
()
...
...
@@ -842,7 +826,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
}
case
RETURN
:
require
(
2
)
size
,
offset
:=
stack
.
Popn
()
ret
:=
mem
.
Get
(
offset
.
Int64
(),
size
.
Int64
())
...
...
@@ -850,7 +833,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
return
closure
.
Return
(
ret
),
nil
case
SUICIDE
:
require
(
1
)
receiver
:=
state
.
GetOrNewStateObject
(
stack
.
Pop
()
.
Bytes
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录