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
ff5b3ef0
Commit
ff5b3ef0
authored
Jun 10, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/vm: added structured logging
parent
468501cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
+22
-8
execution.go
core/execution.go
+0
-4
vm.go
core/vm/vm.go
+22
-4
No files found.
core/execution.go
View file @
ff5b3ef0
...
...
@@ -2,7 +2,6 @@ package core
import
(
"math/big"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
...
...
@@ -49,8 +48,6 @@ func (self *Execution) Create(caller vm.ContextRef) (ret []byte, err error, acco
}
func
(
self
*
Execution
)
exec
(
contextAddr
*
common
.
Address
,
code
[]
byte
,
caller
vm
.
ContextRef
)
(
ret
[]
byte
,
err
error
)
{
start
:=
time
.
Now
()
env
:=
self
.
env
evm
:=
self
.
evm
if
env
.
Depth
()
>
int
(
params
.
CallCreateDepth
.
Int64
())
{
...
...
@@ -96,7 +93,6 @@ func (self *Execution) exec(contextAddr *common.Address, code []byte, caller vm.
context
.
SetCallCode
(
contextAddr
,
code
)
ret
,
err
=
evm
.
Run
(
context
,
self
.
input
)
evm
.
Printf
(
"message call took %v"
,
time
.
Since
(
start
))
.
Endl
()
if
err
!=
nil
{
env
.
State
()
.
Set
(
snapshot
)
}
...
...
core/vm/vm.go
View file @
ff5b3ef0
...
...
@@ -11,10 +11,18 @@ import (
"github.com/ethereum/go-ethereum/params"
)
type
log
struct
{
op
OpCode
gas
*
big
.
Int
memory
[]
byte
stack
[]
*
big
.
Int
}
type
Vm
struct
{
env
Environment
logTy
byte
// structured logging
Logs
[]
log
logStr
string
err
error
...
...
@@ -32,9 +40,7 @@ type Vm struct {
}
func
New
(
env
Environment
)
*
Vm
{
lt
:=
LogTyPretty
return
&
Vm
{
debug
:
Debug
,
env
:
env
,
logTy
:
lt
,
Recoverable
:
true
}
return
&
Vm
{
env
:
env
,
Recoverable
:
true
}
}
func
(
self
*
Vm
)
Run
(
context
*
Context
,
callData
[]
byte
)
(
ret
[]
byte
,
err
error
)
{
...
...
@@ -106,6 +112,8 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
// Get the memory location of pc
op
=
context
.
GetOp
(
pc
)
self
.
Log
(
op
,
context
.
Gas
,
mem
,
stack
)
self
.
Printf
(
"(pc) %-3d -o- %-14s (m) %-4d (s) %-4d "
,
pc
,
op
.
String
(),
mem
.
Len
(),
stack
.
len
())
newMemSize
,
gas
,
err
:=
self
.
calculateGasAndSize
(
context
,
caller
,
op
,
statedb
,
mem
,
stack
)
if
err
!=
nil
{
...
...
@@ -855,6 +863,16 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
return
newMemSize
,
gas
,
nil
}
func
(
vm
*
Vm
)
Log
(
op
OpCode
,
gas
*
big
.
Int
,
memory
*
Memory
,
stack
*
stack
)
{
if
vm
.
debug
{
mem
:=
make
([]
byte
,
len
(
memory
.
store
))
copy
(
mem
,
memory
.
store
)
stck
:=
make
([]
*
big
.
Int
,
len
(
stack
.
data
))
copy
(
stck
,
stack
.
data
)
vm
.
Logs
=
append
(
vm
.
Logs
,
log
{
op
,
new
(
big
.
Int
)
.
Set
(
gas
),
mem
,
stck
})
}
}
func
(
self
*
Vm
)
RunPrecompiled
(
p
*
PrecompiledAccount
,
callData
[]
byte
,
context
*
Context
)
(
ret
[]
byte
,
err
error
)
{
gas
:=
p
.
Gas
(
len
(
callData
))
if
context
.
UseGas
(
gas
)
{
...
...
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