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
4dc1fb92
Commit
4dc1fb92
authored
Oct 31, 2016
by
Jeffrey Wilcke
Committed by
GitHub
Oct 31, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3064 from pirapira/limit_struct_logs
core/vm: add limit option to LogConfig
parents
b8dec948
bb6115b7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
4 deletions
+16
-4
errors.go
core/vm/errors.go
+1
-0
logger.go
core/vm/logger.go
+9
-2
vm.go
core/vm/vm.go
+4
-1
tracer.go
internal/ethapi/tracer.go
+2
-1
No files found.
core/vm/errors.go
View file @
4dc1fb92
...
@@ -26,3 +26,4 @@ import (
...
@@ -26,3 +26,4 @@ import (
var
OutOfGasError
=
errors
.
New
(
"Out of gas"
)
var
OutOfGasError
=
errors
.
New
(
"Out of gas"
)
var
CodeStoreOutOfGasError
=
errors
.
New
(
"Contract creation code storage out of gas"
)
var
CodeStoreOutOfGasError
=
errors
.
New
(
"Contract creation code storage out of gas"
)
var
DepthError
=
fmt
.
Errorf
(
"Max call depth exceeded (%d)"
,
params
.
CallCreateDepth
)
var
DepthError
=
fmt
.
Errorf
(
"Max call depth exceeded (%d)"
,
params
.
CallCreateDepth
)
var
TraceLimitReachedError
=
errors
.
New
(
"The number of logs reached the specified limit"
)
core/vm/logger.go
View file @
4dc1fb92
...
@@ -42,6 +42,7 @@ type LogConfig struct {
...
@@ -42,6 +42,7 @@ type LogConfig struct {
DisableStack
bool
// disable stack capture
DisableStack
bool
// disable stack capture
DisableStorage
bool
// disable storage capture
DisableStorage
bool
// disable storage capture
FullStorage
bool
// show full storage (slow)
FullStorage
bool
// show full storage (slow)
Limit
int
// maximum length of output, but zero means unlimited
}
}
// StructLog is emitted to the Environment each cycle and lists information about the current internal state
// StructLog is emitted to the Environment each cycle and lists information about the current internal state
...
@@ -64,7 +65,7 @@ type StructLog struct {
...
@@ -64,7 +65,7 @@ type StructLog struct {
// Note that reference types are actual VM data structures; make copies
// Note that reference types are actual VM data structures; make copies
// if you need to retain them beyond the current call.
// if you need to retain them beyond the current call.
type
Tracer
interface
{
type
Tracer
interface
{
CaptureState
(
env
Environment
,
pc
uint64
,
op
OpCode
,
gas
,
cost
*
big
.
Int
,
memory
*
Memory
,
stack
*
Stack
,
contract
*
Contract
,
depth
int
,
err
error
)
CaptureState
(
env
Environment
,
pc
uint64
,
op
OpCode
,
gas
,
cost
*
big
.
Int
,
memory
*
Memory
,
stack
*
Stack
,
contract
*
Contract
,
depth
int
,
err
error
)
error
}
}
// StructLogger is an EVM state logger and implements Tracer.
// StructLogger is an EVM state logger and implements Tracer.
...
@@ -93,7 +94,12 @@ func NewStructLogger(cfg *LogConfig) *StructLogger {
...
@@ -93,7 +94,12 @@ func NewStructLogger(cfg *LogConfig) *StructLogger {
// captureState logs a new structured log message and pushes it out to the environment
// captureState logs a new structured log message and pushes it out to the environment
//
//
// captureState also tracks SSTORE ops to track dirty values.
// captureState also tracks SSTORE ops to track dirty values.
func
(
l
*
StructLogger
)
CaptureState
(
env
Environment
,
pc
uint64
,
op
OpCode
,
gas
,
cost
*
big
.
Int
,
memory
*
Memory
,
stack
*
Stack
,
contract
*
Contract
,
depth
int
,
err
error
)
{
func
(
l
*
StructLogger
)
CaptureState
(
env
Environment
,
pc
uint64
,
op
OpCode
,
gas
,
cost
*
big
.
Int
,
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
TraceLimitReachedError
}
// initialise new changed values storage container for this contract
// initialise new changed values storage container for this contract
// if not present.
// if not present.
if
l
.
changedValues
[
contract
.
Address
()]
==
nil
{
if
l
.
changedValues
[
contract
.
Address
()]
==
nil
{
...
@@ -152,6 +158,7 @@ func (l *StructLogger) CaptureState(env Environment, pc uint64, op OpCode, gas,
...
@@ -152,6 +158,7 @@ func (l *StructLogger) CaptureState(env Environment, pc uint64, op OpCode, gas,
log
:=
StructLog
{
pc
,
op
,
new
(
big
.
Int
)
.
Set
(
gas
),
cost
,
mem
,
stck
,
storage
,
env
.
Depth
(),
err
}
log
:=
StructLog
{
pc
,
op
,
new
(
big
.
Int
)
.
Set
(
gas
),
cost
,
mem
,
stck
,
storage
,
env
.
Depth
(),
err
}
l
.
logs
=
append
(
l
.
logs
,
log
)
l
.
logs
=
append
(
l
.
logs
,
log
)
return
nil
}
}
// StructLogs returns a list of captured log entries
// StructLogs returns a list of captured log entries
...
...
core/vm/vm.go
View file @
4dc1fb92
...
@@ -188,7 +188,10 @@ func (evm *EVM) Run(contract *Contract, input []byte) (ret []byte, err error) {
...
@@ -188,7 +188,10 @@ func (evm *EVM) Run(contract *Contract, input []byte) (ret []byte, err error) {
mem
.
Resize
(
newMemSize
.
Uint64
())
mem
.
Resize
(
newMemSize
.
Uint64
())
// Add a log message
// Add a log message
if
evm
.
cfg
.
Debug
{
if
evm
.
cfg
.
Debug
{
evm
.
cfg
.
Tracer
.
CaptureState
(
evm
.
env
,
pc
,
op
,
contract
.
Gas
,
cost
,
mem
,
stack
,
contract
,
evm
.
env
.
Depth
(),
nil
)
err
=
evm
.
cfg
.
Tracer
.
CaptureState
(
evm
.
env
,
pc
,
op
,
contract
.
Gas
,
cost
,
mem
,
stack
,
contract
,
evm
.
env
.
Depth
(),
nil
)
if
err
!=
nil
{
return
nil
,
err
}
}
}
if
opPtr
:=
evm
.
jumpTable
[
op
];
opPtr
.
valid
{
if
opPtr
:=
evm
.
jumpTable
[
op
];
opPtr
.
valid
{
...
...
internal/ethapi/tracer.go
View file @
4dc1fb92
...
@@ -278,7 +278,7 @@ func wrapError(context string, err error) error {
...
@@ -278,7 +278,7 @@ func wrapError(context string, err error) error {
}
}
// CaptureState implements the Tracer interface to trace a single step of VM execution
// CaptureState implements the Tracer interface to trace a single step of VM execution
func
(
jst
*
JavascriptTracer
)
CaptureState
(
env
vm
.
Environment
,
pc
uint64
,
op
vm
.
OpCode
,
gas
,
cost
*
big
.
Int
,
memory
*
vm
.
Memory
,
stack
*
vm
.
Stack
,
contract
*
vm
.
Contract
,
depth
int
,
err
error
)
{
func
(
jst
*
JavascriptTracer
)
CaptureState
(
env
vm
.
Environment
,
pc
uint64
,
op
vm
.
OpCode
,
gas
,
cost
*
big
.
Int
,
memory
*
vm
.
Memory
,
stack
*
vm
.
Stack
,
contract
*
vm
.
Contract
,
depth
int
,
err
error
)
error
{
if
jst
.
err
==
nil
{
if
jst
.
err
==
nil
{
jst
.
memory
.
memory
=
memory
jst
.
memory
.
memory
=
memory
jst
.
stack
.
stack
=
stack
jst
.
stack
.
stack
=
stack
...
@@ -301,6 +301,7 @@ func (jst *JavascriptTracer) CaptureState(env vm.Environment, pc uint64, op vm.O
...
@@ -301,6 +301,7 @@ func (jst *JavascriptTracer) CaptureState(env vm.Environment, pc uint64, op vm.O
jst
.
err
=
wrapError
(
"step"
,
err
)
jst
.
err
=
wrapError
(
"step"
,
err
)
}
}
}
}
return
nil
}
}
// GetResult calls the Javascript 'result' function and returns its value, or any accumulated error
// GetResult calls the Javascript 'result' function and returns its value, or any accumulated error
...
...
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