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
6742fc52
Commit
6742fc52
authored
Mar 22, 2017
by
Yohann Leon
Committed by
Felix Lange
Mar 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/vm: use uint64 instead of *big.Int in tracer (#3805)
parent
9b84caf3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
21 deletions
+17
-21
interpreter.go
core/vm/interpreter.go
+2
-6
logger.go
core/vm/logger.go
+5
-5
logger_test.go
core/vm/logger_test.go
+3
-3
api.go
internal/ethapi/api.go
+2
-2
tracer.go
internal/ethapi/tracer.go
+3
-3
tracer_test.go
internal/ethapi/tracer_test.go
+2
-2
No files found.
core/vm/interpreter.go
View file @
6742fc52
...
...
@@ -18,7 +18,6 @@ package vm
import
(
"fmt"
"math/big"
"sync/atomic"
"time"
...
...
@@ -117,9 +116,7 @@ func (evm *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err e
if
err
!=
nil
&&
evm
.
cfg
.
Debug
{
// XXX For debugging
//fmt.Printf("%04d: %8v cost = %-8d stack = %-8d ERR = %v\n", pc, op, cost, stack.len(), err)
// TODO update the tracer
g
,
c
:=
new
(
big
.
Int
)
.
SetUint64
(
contract
.
Gas
),
new
(
big
.
Int
)
.
SetUint64
(
cost
)
evm
.
cfg
.
Tracer
.
CaptureState
(
evm
.
env
,
pc
,
op
,
g
,
c
,
mem
,
stack
,
contract
,
evm
.
env
.
depth
,
err
)
evm
.
cfg
.
Tracer
.
CaptureState
(
evm
.
env
,
pc
,
op
,
contract
.
Gas
,
cost
,
mem
,
stack
,
contract
,
evm
.
env
.
depth
,
err
)
}
}()
...
...
@@ -177,8 +174,7 @@ func (evm *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err e
}
if
evm
.
cfg
.
Debug
{
g
,
c
:=
new
(
big
.
Int
)
.
SetUint64
(
contract
.
Gas
),
new
(
big
.
Int
)
.
SetUint64
(
cost
)
evm
.
cfg
.
Tracer
.
CaptureState
(
evm
.
env
,
pc
,
op
,
g
,
c
,
mem
,
stack
,
contract
,
evm
.
env
.
depth
,
err
)
evm
.
cfg
.
Tracer
.
CaptureState
(
evm
.
env
,
pc
,
op
,
contract
.
Gas
,
cost
,
mem
,
stack
,
contract
,
evm
.
env
.
depth
,
err
)
}
// XXX For debugging
//fmt.Printf("%04d: %8v cost = %-8d stack = %-8d\n", pc, op, cost, stack.len())
...
...
core/vm/logger.go
View file @
6742fc52
...
...
@@ -52,8 +52,8 @@ type LogConfig struct {
type
StructLog
struct
{
Pc
uint64
Op
OpCode
Gas
*
big
.
Int
GasCost
*
big
.
Int
Gas
uint64
GasCost
uint64
Memory
[]
byte
Stack
[]
*
big
.
Int
Storage
map
[
common
.
Hash
]
common
.
Hash
...
...
@@ -67,7 +67,7 @@ type StructLog struct {
// Note that reference types are actual VM data structures; make copies
// if you need to retain them beyond the current call.
type
Tracer
interface
{
CaptureState
(
env
*
EVM
,
pc
uint64
,
op
OpCode
,
gas
,
cost
*
big
.
Int
,
memory
*
Memory
,
stack
*
Stack
,
contract
*
Contract
,
depth
int
,
err
error
)
error
CaptureState
(
env
*
EVM
,
pc
uint64
,
op
OpCode
,
gas
,
cost
uint64
,
memory
*
Memory
,
stack
*
Stack
,
contract
*
Contract
,
depth
int
,
err
error
)
error
}
// StructLogger is an EVM state logger and implements Tracer.
...
...
@@ -96,7 +96,7 @@ func NewStructLogger(cfg *LogConfig) *StructLogger {
// captureState logs a new structured log message and pushes it out to the environment
//
// captureState also tracks SSTORE ops to track dirty values.
func
(
l
*
StructLogger
)
CaptureState
(
env
*
EVM
,
pc
uint64
,
op
OpCode
,
gas
,
cost
*
big
.
Int
,
memory
*
Memory
,
stack
*
Stack
,
contract
*
Contract
,
depth
int
,
err
error
)
error
{
func
(
l
*
StructLogger
)
CaptureState
(
env
*
EVM
,
pc
uint64
,
op
OpCode
,
gas
,
cost
uint64
,
memory
*
Memory
,
stack
*
Stack
,
contract
*
Contract
,
depth
int
,
err
error
)
error
{
// check if already accumulated the specified number of logs
if
l
.
cfg
.
Limit
!=
0
&&
l
.
cfg
.
Limit
<=
len
(
l
.
logs
)
{
return
ErrTraceLimitReached
...
...
@@ -158,7 +158,7 @@ func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost *b
}
}
// create a new snaptshot of the EVM.
log
:=
StructLog
{
pc
,
op
,
new
(
big
.
Int
)
.
Set
(
gas
)
,
cost
,
mem
,
stck
,
storage
,
env
.
depth
,
err
}
log
:=
StructLog
{
pc
,
op
,
gas
,
cost
,
mem
,
stck
,
storage
,
env
.
depth
,
err
}
l
.
logs
=
append
(
l
.
logs
,
log
)
return
nil
...
...
core/vm/logger_test.go
View file @
6742fc52
...
...
@@ -59,7 +59,7 @@ func TestStoreCapture(t *testing.T) {
var
index
common
.
Hash
logger
.
CaptureState
(
env
,
0
,
SSTORE
,
new
(
big
.
Int
),
new
(
big
.
Int
)
,
mem
,
stack
,
contract
,
0
,
nil
)
logger
.
CaptureState
(
env
,
0
,
SSTORE
,
0
,
0
,
mem
,
stack
,
contract
,
0
,
nil
)
if
len
(
logger
.
changedValues
[
contract
.
Address
()])
==
0
{
t
.
Fatalf
(
"expected exactly 1 changed value on address %x, got %d"
,
contract
.
Address
(),
len
(
logger
.
changedValues
[
contract
.
Address
()]))
}
...
...
@@ -81,13 +81,13 @@ func TestStorageCapture(t *testing.T) {
stack
=
newstack
()
)
logger
.
CaptureState
(
env
,
0
,
STOP
,
new
(
big
.
Int
),
new
(
big
.
Int
)
,
mem
,
stack
,
contract
,
0
,
nil
)
logger
.
CaptureState
(
env
,
0
,
STOP
,
0
,
0
,
mem
,
stack
,
contract
,
0
,
nil
)
if
ref
.
calledForEach
{
t
.
Error
(
"didn't expect for each to be called"
)
}
logger
=
NewStructLogger
(
&
LogConfig
{
FullStorage
:
true
})
logger
.
CaptureState
(
env
,
0
,
STOP
,
new
(
big
.
Int
),
new
(
big
.
Int
)
,
mem
,
stack
,
contract
,
0
,
nil
)
logger
.
CaptureState
(
env
,
0
,
STOP
,
0
,
0
,
mem
,
stack
,
contract
,
0
,
nil
)
if
!
ref
.
calledForEach
{
t
.
Error
(
"expected for each to be called"
)
}
...
...
internal/ethapi/api.go
View file @
6742fc52
...
...
@@ -695,8 +695,8 @@ type ExecutionResult struct {
type
StructLogRes
struct
{
Pc
uint64
`json:"pc"`
Op
string
`json:"op"`
Gas
*
big
.
Int
`json:"gas"`
GasCost
*
big
.
Int
`json:"gasCost"`
Gas
uint64
`json:"gas"`
GasCost
uint64
`json:"gasCost"`
Depth
int
`json:"depth"`
Error
error
`json:"error"`
Stack
[]
string
`json:"stack"`
...
...
internal/ethapi/tracer.go
View file @
6742fc52
...
...
@@ -278,7 +278,7 @@ func wrapError(context string, err error) error {
}
// CaptureState implements the Tracer interface to trace a single step of VM execution
func
(
jst
*
JavascriptTracer
)
CaptureState
(
env
*
vm
.
EVM
,
pc
uint64
,
op
vm
.
OpCode
,
gas
,
cost
*
big
.
Int
,
memory
*
vm
.
Memory
,
stack
*
vm
.
Stack
,
contract
*
vm
.
Contract
,
depth
int
,
err
error
)
error
{
func
(
jst
*
JavascriptTracer
)
CaptureState
(
env
*
vm
.
EVM
,
pc
uint64
,
op
vm
.
OpCode
,
gas
,
cost
uint64
,
memory
*
vm
.
Memory
,
stack
*
vm
.
Stack
,
contract
*
vm
.
Contract
,
depth
int
,
err
error
)
error
{
if
jst
.
err
==
nil
{
jst
.
memory
.
memory
=
memory
jst
.
stack
.
stack
=
stack
...
...
@@ -288,8 +288,8 @@ func (jst *JavascriptTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode,
jst
.
log
[
"pc"
]
=
pc
jst
.
log
[
"op"
]
=
ocw
.
toValue
(
jst
.
vm
)
jst
.
log
[
"gas"
]
=
gas
.
Int64
()
jst
.
log
[
"gasPrice"
]
=
cost
.
Int64
()
jst
.
log
[
"gas"
]
=
gas
jst
.
log
[
"gasPrice"
]
=
cost
jst
.
log
[
"memory"
]
=
jst
.
memvalue
jst
.
log
[
"stack"
]
=
jst
.
stackvalue
jst
.
log
[
"depth"
]
=
depth
...
...
internal/ethapi/tracer_test.go
View file @
6742fc52
...
...
@@ -136,10 +136,10 @@ func TestHaltBetweenSteps(t *testing.T) {
env
:=
vm
.
NewEVM
(
vm
.
Context
{},
nil
,
params
.
TestChainConfig
,
vm
.
Config
{
Debug
:
true
,
Tracer
:
tracer
})
contract
:=
vm
.
NewContract
(
&
account
{},
&
account
{},
big
.
NewInt
(
0
),
0
)
tracer
.
CaptureState
(
env
,
0
,
0
,
big
.
NewInt
(
0
),
big
.
NewInt
(
0
)
,
nil
,
nil
,
contract
,
0
,
nil
)
tracer
.
CaptureState
(
env
,
0
,
0
,
0
,
0
,
nil
,
nil
,
contract
,
0
,
nil
)
timeout
:=
errors
.
New
(
"stahp"
)
tracer
.
Stop
(
timeout
)
tracer
.
CaptureState
(
env
,
0
,
0
,
big
.
NewInt
(
0
),
big
.
NewInt
(
0
)
,
nil
,
nil
,
contract
,
0
,
nil
)
tracer
.
CaptureState
(
env
,
0
,
0
,
0
,
0
,
nil
,
nil
,
contract
,
0
,
nil
)
if
_
,
err
:=
tracer
.
GetResult
();
err
.
Error
()
!=
"stahp in server-side tracer function 'step'"
{
t
.
Errorf
(
"Expected timeout error, got %v"
,
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