Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
1b1fa049
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,体验更适合开发者的 AI 搜索 >>
提交
1b1fa049
编写于
11月 04, 2014
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed VM and added static analysis for EVM jumps
上级
8cfbf183
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
45 addition
and
34 deletion
+45
-34
chain/chain_manager.go
chain/chain_manager.go
+0
-1
chain/error.go
chain/error.go
+1
-1
tests/vm/gh_test.go
tests/vm/gh_test.go
+5
-1
vm/types.go
vm/types.go
+17
-16
vm/vm_debug.go
vm/vm_debug.go
+22
-15
未找到文件。
chain/chain_manager.go
浏览文件 @
1b1fa049
...
...
@@ -348,7 +348,6 @@ func (self *ChainManager) TestChain(chain *BlockChain) (td *big.Int, err error)
return
}
l
.
td
=
td
i
++
}
if
td
.
Cmp
(
self
.
TD
)
<=
0
{
...
...
chain/error.go
浏览文件 @
1b1fa049
...
...
@@ -123,6 +123,6 @@ func (self *TDError) Error() string {
return
fmt
.
Sprintf
(
"incoming chain has a lower or equal TD (%v <= %v)"
,
self
.
a
,
self
.
b
)
}
func
IsTDError
(
e
error
)
bool
{
_
,
ok
:=
e
rr
.
(
*
TDError
)
_
,
ok
:=
e
.
(
*
TDError
)
return
ok
}
tests/vm/gh_test.go
浏览文件 @
1b1fa049
...
...
@@ -88,11 +88,14 @@ func TestVMArithmetic(t *testing.T) {
RunVmTest
(
fn
,
t
)
}
/*
deleted?
func TestVMSystemOperation(t *testing.T) {
//
helper.Logger.SetLogLevel(5)
helper.Logger.SetLogLevel(5)
const fn = "../files/vmtests/vmSystemOperationsTest.json"
RunVmTest(fn, t)
}
*/
func
TestBitwiseLogicOperation
(
t
*
testing
.
T
)
{
const
fn
=
"../files/vmtests/vmBitwiseLogicOperationTest.json"
...
...
@@ -110,6 +113,7 @@ func TestEnvironmentalInfo(t *testing.T) {
}
func
TestFlowOperation
(
t
*
testing
.
T
)
{
// helper.Logger.SetLogLevel(5)
const
fn
=
"../files/vmtests/vmIOandFlowOperationsTest.json"
RunVmTest
(
fn
,
t
)
}
...
...
vm/types.go
浏览文件 @
1b1fa049
...
...
@@ -173,22 +173,23 @@ const (
// Since the opcodes aren't all in order we can't use a regular slice
var
opCodeToString
=
map
[
OpCode
]
string
{
// 0x0 range - arithmetic ops
STOP
:
"STOP"
,
ADD
:
"ADD"
,
MUL
:
"MUL"
,
SUB
:
"SUB"
,
DIV
:
"DIV"
,
SDIV
:
"SDIV"
,
MOD
:
"MOD"
,
SMOD
:
"SMOD"
,
EXP
:
"EXP"
,
NOT
:
"NOT"
,
LT
:
"LT"
,
GT
:
"GT"
,
SLT
:
"SLT"
,
SGT
:
"SGT"
,
EQ
:
"EQ"
,
ISZERO
:
"ISZERO"
,
STOP
:
"STOP"
,
ADD
:
"ADD"
,
MUL
:
"MUL"
,
SUB
:
"SUB"
,
DIV
:
"DIV"
,
SDIV
:
"SDIV"
,
MOD
:
"MOD"
,
SMOD
:
"SMOD"
,
EXP
:
"EXP"
,
NOT
:
"NOT"
,
LT
:
"LT"
,
GT
:
"GT"
,
SLT
:
"SLT"
,
SGT
:
"SGT"
,
EQ
:
"EQ"
,
ISZERO
:
"ISZERO"
,
SIGNEXTEND
:
"SIGNEXTEND"
,
// 0x10 range - bit ops
AND
:
"AND"
,
...
...
vm/vm_debug.go
浏览文件 @
1b1fa049
...
...
@@ -59,32 +59,34 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
var
(
op
OpCode
mem
=
&
Memory
{}
stack
=
NewStack
()
pc
=
big
.
NewInt
(
0
)
step
=
0
prevStep
=
0
statedb
=
self
.
env
.
State
()
require
=
func
(
m
int
)
{
destinations
=
analyseJumpDests
(
closure
.
Code
)
mem
=
&
Memory
{}
stack
=
NewStack
()
pc
=
big
.
NewInt
(
0
)
step
=
0
prevStep
=
0
statedb
=
self
.
env
.
State
()
require
=
func
(
m
int
)
{
if
stack
.
Len
()
<
m
{
panic
(
fmt
.
Sprintf
(
"%04v (%v) stack err size = %d, required = %d"
,
pc
,
op
,
stack
.
Len
(),
m
))
}
}
jump
=
func
(
pos
*
big
.
Int
)
{
p
:=
int
(
pos
.
Int64
())
jump
=
func
(
from
,
to
*
big
.
Int
)
{
p
:=
int
(
to
.
Int64
())
self
.
Printf
(
" ~> %v"
,
pos
)
self
.
Printf
(
" ~> %v"
,
to
)
// Return to start
if
p
==
0
{
pc
=
big
.
NewInt
(
0
)
}
else
{
nop
:=
OpCode
(
closure
.
GetOp
(
p
-
1
))
if
nop
!=
JUMPDEST
{
nop
:=
OpCode
(
closure
.
GetOp
(
p
))
if
!
(
nop
==
JUMPDEST
||
destinations
[
from
.
Int64
()]
!=
nil
)
{
panic
(
fmt
.
Sprintf
(
"JUMP missed JUMPDEST (%v) %v"
,
nop
,
p
))
}
pc
=
pos
pc
=
to
}
self
.
Endl
()
...
...
@@ -406,6 +408,11 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
}
else
{
num
.
And
(
num
,
mask
)
}
num
=
U256
(
num
)
self
.
Printf
(
" = %v"
,
num
)
stack
.
Push
(
num
)
}
case
NOT
:
...
...
@@ -765,14 +772,14 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
self
.
Printf
(
" {0x%x : 0x%x}"
,
loc
.
Bytes
(),
val
.
Bytes
())
case
JUMP
:
jump
(
stack
.
Pop
())
jump
(
pc
,
stack
.
Pop
())
continue
case
JUMPI
:
cond
,
pos
:=
stack
.
Popn
()
if
cond
.
Cmp
(
ethutil
.
BigTrue
)
>=
0
{
jump
(
pos
)
jump
(
p
c
,
p
os
)
continue
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录