Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
4e181c57
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,发现更多精彩内容 >>
提交
4e181c57
编写于
3月 16, 2015
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Moved gas
上级
6aa390ab
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
65 addition
and
66 deletion
+65
-66
vm/common.go
vm/common.go
+16
-62
vm/gas.go
vm/gas.go
+49
-0
vm/vm.go
vm/vm.go
+0
-4
未找到文件。
vm/common.go
浏览文件 @
4e181c57
...
...
@@ -18,8 +18,23 @@ type Type byte
const
(
StdVmTy
Type
=
iota
JitVmTy
MaxVmTy
MaxCallDepth
=
1025
LogTyPretty
byte
=
0x1
LogTyDiff
byte
=
0x2
)
var
(
Pow256
=
common
.
BigPow
(
2
,
256
)
U256
=
common
.
U256
S256
=
common
.
S256
Zero
=
common
.
Big0
max
=
big
.
NewInt
(
math
.
MaxInt64
)
)
func
NewVm
(
env
Environment
)
VirtualMachine
{
...
...
@@ -34,67 +49,6 @@ func NewVm(env Environment) VirtualMachine {
}
}
var
(
GasQuickStep
=
big
.
NewInt
(
2
)
GasFastestStep
=
big
.
NewInt
(
3
)
GasFastStep
=
big
.
NewInt
(
5
)
GasMidStep
=
big
.
NewInt
(
8
)
GasSlowStep
=
big
.
NewInt
(
10
)
GasExtStep
=
big
.
NewInt
(
20
)
GasStorageGet
=
big
.
NewInt
(
50
)
GasStorageAdd
=
big
.
NewInt
(
20000
)
GasStorageMod
=
big
.
NewInt
(
5000
)
GasLogBase
=
big
.
NewInt
(
375
)
GasLogTopic
=
big
.
NewInt
(
375
)
GasLogByte
=
big
.
NewInt
(
8
)
GasCreate
=
big
.
NewInt
(
32000
)
GasCreateByte
=
big
.
NewInt
(
200
)
GasCall
=
big
.
NewInt
(
40
)
GasCallValueTransfer
=
big
.
NewInt
(
9000
)
GasStipend
=
big
.
NewInt
(
2300
)
GasCallNewAccount
=
big
.
NewInt
(
25000
)
GasReturn
=
big
.
NewInt
(
0
)
GasStop
=
big
.
NewInt
(
0
)
GasJumpDest
=
big
.
NewInt
(
1
)
RefundStorage
=
big
.
NewInt
(
15000
)
RefundSuicide
=
big
.
NewInt
(
24000
)
GasMemWord
=
big
.
NewInt
(
3
)
GasQuadCoeffDenom
=
big
.
NewInt
(
512
)
GasContractByte
=
big
.
NewInt
(
200
)
GasTransaction
=
big
.
NewInt
(
21000
)
GasTxDataNonzeroByte
=
big
.
NewInt
(
68
)
GasTxDataZeroByte
=
big
.
NewInt
(
4
)
GasTx
=
big
.
NewInt
(
21000
)
GasExp
=
big
.
NewInt
(
10
)
GasExpByte
=
big
.
NewInt
(
10
)
GasSha3Base
=
big
.
NewInt
(
30
)
GasSha3Word
=
big
.
NewInt
(
6
)
GasSha256Base
=
big
.
NewInt
(
60
)
GasSha256Word
=
big
.
NewInt
(
12
)
GasRipemdBase
=
big
.
NewInt
(
600
)
GasRipemdWord
=
big
.
NewInt
(
12
)
GasEcrecover
=
big
.
NewInt
(
3000
)
GasIdentityBase
=
big
.
NewInt
(
15
)
GasIdentityWord
=
big
.
NewInt
(
3
)
GasCopyWord
=
big
.
NewInt
(
3
)
Pow256
=
common
.
BigPow
(
2
,
256
)
LogTyPretty
byte
=
0x1
LogTyDiff
byte
=
0x2
U256
=
common
.
U256
S256
=
common
.
S256
Zero
=
common
.
Big0
)
const
MaxCallDepth
=
1025
func
calcMemSize
(
off
,
l
*
big
.
Int
)
*
big
.
Int
{
if
l
.
Cmp
(
common
.
Big0
)
==
0
{
return
common
.
Big0
...
...
vm/gas.go
浏览文件 @
4e181c57
...
...
@@ -7,6 +7,55 @@ type req struct {
gas
*
big
.
Int
}
var
(
GasQuickStep
=
big
.
NewInt
(
2
)
GasFastestStep
=
big
.
NewInt
(
3
)
GasFastStep
=
big
.
NewInt
(
5
)
GasMidStep
=
big
.
NewInt
(
8
)
GasSlowStep
=
big
.
NewInt
(
10
)
GasExtStep
=
big
.
NewInt
(
20
)
GasStorageGet
=
big
.
NewInt
(
50
)
GasStorageAdd
=
big
.
NewInt
(
20000
)
GasStorageMod
=
big
.
NewInt
(
5000
)
GasLogBase
=
big
.
NewInt
(
375
)
GasLogTopic
=
big
.
NewInt
(
375
)
GasLogByte
=
big
.
NewInt
(
8
)
GasCreate
=
big
.
NewInt
(
32000
)
GasCreateByte
=
big
.
NewInt
(
200
)
GasCall
=
big
.
NewInt
(
40
)
GasCallValueTransfer
=
big
.
NewInt
(
9000
)
GasStipend
=
big
.
NewInt
(
2300
)
GasCallNewAccount
=
big
.
NewInt
(
25000
)
GasReturn
=
big
.
NewInt
(
0
)
GasStop
=
big
.
NewInt
(
0
)
GasJumpDest
=
big
.
NewInt
(
1
)
RefundStorage
=
big
.
NewInt
(
15000
)
RefundSuicide
=
big
.
NewInt
(
24000
)
GasMemWord
=
big
.
NewInt
(
3
)
GasQuadCoeffDenom
=
big
.
NewInt
(
512
)
GasContractByte
=
big
.
NewInt
(
200
)
GasTransaction
=
big
.
NewInt
(
21000
)
GasTxDataNonzeroByte
=
big
.
NewInt
(
68
)
GasTxDataZeroByte
=
big
.
NewInt
(
4
)
GasTx
=
big
.
NewInt
(
21000
)
GasExp
=
big
.
NewInt
(
10
)
GasExpByte
=
big
.
NewInt
(
10
)
GasSha3Base
=
big
.
NewInt
(
30
)
GasSha3Word
=
big
.
NewInt
(
6
)
GasSha256Base
=
big
.
NewInt
(
60
)
GasSha256Word
=
big
.
NewInt
(
12
)
GasRipemdBase
=
big
.
NewInt
(
600
)
GasRipemdWord
=
big
.
NewInt
(
12
)
GasEcrecover
=
big
.
NewInt
(
3000
)
GasIdentityBase
=
big
.
NewInt
(
15
)
GasIdentityWord
=
big
.
NewInt
(
3
)
GasCopyWord
=
big
.
NewInt
(
3
)
)
var
_baseCheck
=
map
[
OpCode
]
req
{
// Req stack Gas price
ADD
:
{
2
,
GasFastestStep
},
...
...
vm/vm.go
浏览文件 @
4e181c57
...
...
@@ -33,10 +33,7 @@ func New(env Environment) *Vm {
}
func
(
self
*
Vm
)
Run
(
context
*
Context
,
callData
[]
byte
)
(
ret
[]
byte
,
err
error
)
{
//func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, callData []byte) (ret []byte, err error) {
self
.
env
.
SetDepth
(
self
.
env
.
Depth
()
+
1
)
//context := NewContext(caller, me, code, gas, price)
var
(
caller
=
context
.
caller
code
=
context
.
Code
...
...
@@ -57,7 +54,6 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
ret
=
context
.
Return
(
nil
)
err
=
fmt
.
Errorf
(
"%v"
,
r
)
}
}()
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录