Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
fe070ab5
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,发现更多精彩内容 >>
未验证
提交
fe070ab5
编写于
12月 18, 2017
作者:
P
Péter Szilágyi
提交者:
GitHub
12月 18, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15674 from chfast/vm-no-snapshot-param
core/vm: Remove snapshot param from Interpreter.Run()
上级
8c33ac10
fb5f25ee
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
11 addition
and
11 deletion
+11
-11
core/vm/evm.go
core/vm/evm.go
+7
-7
core/vm/interpreter.go
core/vm/interpreter.go
+3
-3
internal/ethapi/tracer_test.go
internal/ethapi/tracer_test.go
+1
-1
未找到文件。
core/vm/evm.go
浏览文件 @
fe070ab5
...
...
@@ -38,7 +38,7 @@ type (
)
// run runs the given contract and takes care of running precompiles with a fallback to the byte code interpreter.
func
run
(
evm
*
EVM
,
snapshot
int
,
contract
*
Contract
,
input
[]
byte
)
([]
byte
,
error
)
{
func
run
(
evm
*
EVM
,
contract
*
Contract
,
input
[]
byte
)
([]
byte
,
error
)
{
if
contract
.
CodeAddr
!=
nil
{
precompiles
:=
PrecompiledContractsHomestead
if
evm
.
ChainConfig
()
.
IsByzantium
(
evm
.
BlockNumber
)
{
...
...
@@ -48,7 +48,7 @@ func run(evm *EVM, snapshot int, contract *Contract, input []byte) ([]byte, erro
return
RunPrecompiledContract
(
p
,
input
,
contract
)
}
}
return
evm
.
interpreter
.
Run
(
snapshot
,
contract
,
input
)
return
evm
.
interpreter
.
Run
(
contract
,
input
)
}
// Context provides the EVM with auxiliary information. Once provided
...
...
@@ -171,7 +171,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
contract
:=
NewContract
(
caller
,
to
,
value
,
gas
)
contract
.
SetCallCode
(
&
addr
,
evm
.
StateDB
.
GetCodeHash
(
addr
),
evm
.
StateDB
.
GetCode
(
addr
))
ret
,
err
=
run
(
evm
,
snapshot
,
contract
,
input
)
ret
,
err
=
run
(
evm
,
contract
,
input
)
// When an error was returned by the EVM or when setting the creation code
// above we revert to the snapshot and consume any gas remaining. Additionally
// when we're in homestead this also counts for code storage gas errors.
...
...
@@ -215,7 +215,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
contract
:=
NewContract
(
caller
,
to
,
value
,
gas
)
contract
.
SetCallCode
(
&
addr
,
evm
.
StateDB
.
GetCodeHash
(
addr
),
evm
.
StateDB
.
GetCode
(
addr
))
ret
,
err
=
run
(
evm
,
snapshot
,
contract
,
input
)
ret
,
err
=
run
(
evm
,
contract
,
input
)
if
err
!=
nil
{
evm
.
StateDB
.
RevertToSnapshot
(
snapshot
)
if
err
!=
errExecutionReverted
{
...
...
@@ -248,7 +248,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
contract
:=
NewContract
(
caller
,
to
,
nil
,
gas
)
.
AsDelegate
()
contract
.
SetCallCode
(
&
addr
,
evm
.
StateDB
.
GetCodeHash
(
addr
),
evm
.
StateDB
.
GetCode
(
addr
))
ret
,
err
=
run
(
evm
,
snapshot
,
contract
,
input
)
ret
,
err
=
run
(
evm
,
contract
,
input
)
if
err
!=
nil
{
evm
.
StateDB
.
RevertToSnapshot
(
snapshot
)
if
err
!=
errExecutionReverted
{
...
...
@@ -291,7 +291,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
// When an error was returned by the EVM or when setting the creation code
// above we revert to the snapshot and consume any gas remaining. Additionally
// when we're in Homestead this also counts for code storage gas errors.
ret
,
err
=
run
(
evm
,
snapshot
,
contract
,
input
)
ret
,
err
=
run
(
evm
,
contract
,
input
)
if
err
!=
nil
{
evm
.
StateDB
.
RevertToSnapshot
(
snapshot
)
if
err
!=
errExecutionReverted
{
...
...
@@ -338,7 +338,7 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I
if
evm
.
vmConfig
.
NoRecursion
&&
evm
.
depth
>
0
{
return
nil
,
contractAddr
,
gas
,
nil
}
ret
,
err
=
run
(
evm
,
snapshot
,
contract
,
nil
)
ret
,
err
=
run
(
evm
,
contract
,
nil
)
// check whether the max code size has been exceeded
maxCodeSizeExceeded
:=
evm
.
ChainConfig
()
.
IsEIP158
(
evm
.
BlockNumber
)
&&
len
(
ret
)
>
params
.
MaxCodeSize
// if the contract creation ran successfully and no errors were returned
...
...
core/vm/interpreter.go
浏览文件 @
fe070ab5
...
...
@@ -107,9 +107,9 @@ func (in *Interpreter) enforceRestrictions(op OpCode, operation operation, stack
// the return byte-slice and an error if one occurred.
//
// It's important to note that any errors returned by the interpreter should be
// considered a revert-and-consume-all-gas operation
. No error specific checks
//
should be handled to reduce complexity and errors further down the in
.
func
(
in
*
Interpreter
)
Run
(
snapshot
int
,
contract
*
Contract
,
input
[]
byte
)
(
ret
[]
byte
,
err
error
)
{
// considered a revert-and-consume-all-gas operation
except for
//
errExecutionReverted which means revert-and-keep-gas-left
.
func
(
in
*
Interpreter
)
Run
(
contract
*
Contract
,
input
[]
byte
)
(
ret
[]
byte
,
err
error
)
{
// Increment the call depth which is restricted to 1024
in
.
evm
.
depth
++
defer
func
()
{
in
.
evm
.
depth
--
}()
...
...
internal/ethapi/tracer_test.go
浏览文件 @
fe070ab5
...
...
@@ -48,7 +48,7 @@ func runTrace(tracer *JavascriptTracer) (interface{}, error) {
contract
:=
vm
.
NewContract
(
account
{},
account
{},
big
.
NewInt
(
0
),
10000
)
contract
.
Code
=
[]
byte
{
byte
(
vm
.
PUSH1
),
0x1
,
byte
(
vm
.
PUSH1
),
0x1
,
0x0
}
_
,
err
:=
env
.
Interpreter
()
.
Run
(
0
,
contract
,
[]
byte
{})
_
,
err
:=
env
.
Interpreter
()
.
Run
(
contract
,
[]
byte
{})
if
err
!=
nil
{
return
nil
,
err
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录