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
fb5f25ee
Unverified
Commit
fb5f25ee
authored
Dec 14, 2017
by
Paweł Bylica
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/vm: Remove snapshot param from Interpreter.Run()
parent
5129ef22
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
evm.go
core/vm/evm.go
+7
-7
interpreter.go
core/vm/interpreter.go
+3
-3
tracer_test.go
internal/ethapi/tracer_test.go
+1
-1
No files found.
core/vm/evm.go
View file @
fb5f25ee
...
@@ -38,7 +38,7 @@ type (
...
@@ -38,7 +38,7 @@ type (
)
)
// run runs the given contract and takes care of running precompiles with a fallback to the byte code interpreter.
// 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
{
if
contract
.
CodeAddr
!=
nil
{
precompiles
:=
PrecompiledContractsHomestead
precompiles
:=
PrecompiledContractsHomestead
if
evm
.
ChainConfig
()
.
IsByzantium
(
evm
.
BlockNumber
)
{
if
evm
.
ChainConfig
()
.
IsByzantium
(
evm
.
BlockNumber
)
{
...
@@ -48,7 +48,7 @@ func run(evm *EVM, snapshot int, contract *Contract, input []byte) ([]byte, erro
...
@@ -48,7 +48,7 @@ func run(evm *EVM, snapshot int, contract *Contract, input []byte) ([]byte, erro
return
RunPrecompiledContract
(
p
,
input
,
contract
)
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
// 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
...
@@ -171,7 +171,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
contract
:=
NewContract
(
caller
,
to
,
value
,
gas
)
contract
:=
NewContract
(
caller
,
to
,
value
,
gas
)
contract
.
SetCallCode
(
&
addr
,
evm
.
StateDB
.
GetCodeHash
(
addr
),
evm
.
StateDB
.
GetCode
(
addr
))
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
// 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
// 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.
// 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,
...
@@ -215,7 +215,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
contract
:=
NewContract
(
caller
,
to
,
value
,
gas
)
contract
:=
NewContract
(
caller
,
to
,
value
,
gas
)
contract
.
SetCallCode
(
&
addr
,
evm
.
StateDB
.
GetCodeHash
(
addr
),
evm
.
StateDB
.
GetCode
(
addr
))
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
{
if
err
!=
nil
{
evm
.
StateDB
.
RevertToSnapshot
(
snapshot
)
evm
.
StateDB
.
RevertToSnapshot
(
snapshot
)
if
err
!=
errExecutionReverted
{
if
err
!=
errExecutionReverted
{
...
@@ -248,7 +248,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
...
@@ -248,7 +248,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
contract
:=
NewContract
(
caller
,
to
,
nil
,
gas
)
.
AsDelegate
()
contract
:=
NewContract
(
caller
,
to
,
nil
,
gas
)
.
AsDelegate
()
contract
.
SetCallCode
(
&
addr
,
evm
.
StateDB
.
GetCodeHash
(
addr
),
evm
.
StateDB
.
GetCode
(
addr
))
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
{
if
err
!=
nil
{
evm
.
StateDB
.
RevertToSnapshot
(
snapshot
)
evm
.
StateDB
.
RevertToSnapshot
(
snapshot
)
if
err
!=
errExecutionReverted
{
if
err
!=
errExecutionReverted
{
...
@@ -291,7 +291,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
...
@@ -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
// 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
// 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.
// 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
{
if
err
!=
nil
{
evm
.
StateDB
.
RevertToSnapshot
(
snapshot
)
evm
.
StateDB
.
RevertToSnapshot
(
snapshot
)
if
err
!=
errExecutionReverted
{
if
err
!=
errExecutionReverted
{
...
@@ -338,7 +338,7 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I
...
@@ -338,7 +338,7 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I
if
evm
.
vmConfig
.
NoRecursion
&&
evm
.
depth
>
0
{
if
evm
.
vmConfig
.
NoRecursion
&&
evm
.
depth
>
0
{
return
nil
,
contractAddr
,
gas
,
nil
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
// check whether the max code size has been exceeded
maxCodeSizeExceeded
:=
evm
.
ChainConfig
()
.
IsEIP158
(
evm
.
BlockNumber
)
&&
len
(
ret
)
>
params
.
MaxCodeSize
maxCodeSizeExceeded
:=
evm
.
ChainConfig
()
.
IsEIP158
(
evm
.
BlockNumber
)
&&
len
(
ret
)
>
params
.
MaxCodeSize
// if the contract creation ran successfully and no errors were returned
// if the contract creation ran successfully and no errors were returned
...
...
core/vm/interpreter.go
View file @
fb5f25ee
...
@@ -107,9 +107,9 @@ func (in *Interpreter) enforceRestrictions(op OpCode, operation operation, stack
...
@@ -107,9 +107,9 @@ func (in *Interpreter) enforceRestrictions(op OpCode, operation operation, stack
// the return byte-slice and an error if one occurred.
// the return byte-slice and an error if one occurred.
//
//
// It's important to note that any errors returned by the interpreter should be
// 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
// considered a revert-and-consume-all-gas operation
except for
//
should be handled to reduce complexity and errors further down the in
.
//
errExecutionReverted which means revert-and-keep-gas-left
.
func
(
in
*
Interpreter
)
Run
(
snapshot
int
,
contract
*
Contract
,
input
[]
byte
)
(
ret
[]
byte
,
err
error
)
{
func
(
in
*
Interpreter
)
Run
(
contract
*
Contract
,
input
[]
byte
)
(
ret
[]
byte
,
err
error
)
{
// Increment the call depth which is restricted to 1024
// Increment the call depth which is restricted to 1024
in
.
evm
.
depth
++
in
.
evm
.
depth
++
defer
func
()
{
in
.
evm
.
depth
--
}()
defer
func
()
{
in
.
evm
.
depth
--
}()
...
...
internal/ethapi/tracer_test.go
View file @
fb5f25ee
...
@@ -48,7 +48,7 @@ func runTrace(tracer *JavascriptTracer) (interface{}, error) {
...
@@ -48,7 +48,7 @@ func runTrace(tracer *JavascriptTracer) (interface{}, error) {
contract
:=
vm
.
NewContract
(
account
{},
account
{},
big
.
NewInt
(
0
),
10000
)
contract
:=
vm
.
NewContract
(
account
{},
account
{},
big
.
NewInt
(
0
),
10000
)
contract
.
Code
=
[]
byte
{
byte
(
vm
.
PUSH1
),
0x1
,
byte
(
vm
.
PUSH1
),
0x1
,
0x0
}
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
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
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