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
6fb6e667
Commit
6fb6e667
authored
Jun 10, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/vm, core/state: added storage to structured vm logging
parent
38c61f6f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
9 deletions
+39
-9
state_object.go
core/state/state_object.go
+16
-0
environment.go
core/vm/environment.go
+6
-5
vm.go
core/vm/vm.go
+10
-3
vm_logger.go
core/vm_logger.go
+7
-1
No files found.
core/state/state_object.go
View file @
6fb6e667
...
...
@@ -336,6 +336,22 @@ func (self *StateObject) Nonce() uint64 {
return
self
.
nonce
}
func
(
self
*
StateObject
)
EachStorage
(
cb
func
(
key
,
value
[]
byte
))
{
// When iterating over the storage check the cache first
for
h
,
v
:=
range
self
.
storage
{
cb
([]
byte
(
h
),
v
.
Bytes
())
}
it
:=
self
.
State
.
trie
.
Iterator
()
for
it
.
Next
()
{
// ignore cached values
key
:=
self
.
State
.
trie
.
GetKey
(
it
.
Key
)
if
_
,
ok
:=
self
.
storage
[
string
(
key
)];
!
ok
{
cb
(
key
,
it
.
Value
)
}
}
}
//
// Encoding
//
...
...
core/vm/environment.go
View file @
6fb6e667
...
...
@@ -34,11 +34,12 @@ type Environment interface {
}
type
StructLog
struct
{
Pc
uint64
Op
OpCode
Gas
*
big
.
Int
Memory
[]
byte
Stack
[]
*
big
.
Int
Pc
uint64
Op
OpCode
Gas
*
big
.
Int
Memory
[]
byte
Stack
[]
*
big
.
Int
Storage
map
[
common
.
Hash
][]
byte
}
type
Account
interface
{
...
...
core/vm/vm.go
View file @
6fb6e667
...
...
@@ -95,7 +95,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
// Get the memory location of pc
op
=
context
.
GetOp
(
pc
)
self
.
log
(
pc
,
op
,
context
.
Gas
,
mem
,
stack
)
self
.
log
(
pc
,
op
,
context
.
Gas
,
mem
,
stack
,
context
)
newMemSize
,
gas
,
err
:=
self
.
calculateGasAndSize
(
context
,
caller
,
op
,
statedb
,
mem
,
stack
)
if
err
!=
nil
{
...
...
@@ -778,13 +778,20 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, callData []byte, context *
}
}
func
(
self
*
Vm
)
log
(
pc
uint64
,
op
OpCode
,
gas
*
big
.
Int
,
memory
*
Memory
,
stack
*
Stack
)
{
func
(
self
*
Vm
)
log
(
pc
uint64
,
op
OpCode
,
gas
*
big
.
Int
,
memory
*
Memory
,
stack
*
Stack
,
context
*
Context
)
{
if
Debug
{
mem
:=
make
([]
byte
,
len
(
memory
.
Data
()))
copy
(
mem
,
memory
.
Data
())
stck
:=
make
([]
*
big
.
Int
,
len
(
stack
.
Data
()))
copy
(
stck
,
stack
.
Data
())
self
.
env
.
AddStructLog
(
StructLog
{
pc
,
op
,
new
(
big
.
Int
)
.
Set
(
gas
),
mem
,
stck
})
object
:=
context
.
self
.
(
*
state
.
StateObject
)
storage
:=
make
(
map
[
common
.
Hash
][]
byte
)
object
.
EachStorage
(
func
(
k
,
v
[]
byte
)
{
storage
[
common
.
BytesToHash
(
k
)]
=
v
})
self
.
env
.
AddStructLog
(
StructLog
{
pc
,
op
,
new
(
big
.
Int
)
.
Set
(
gas
),
mem
,
stck
,
storage
})
}
}
...
...
core/vm_logger.go
View file @
6fb6e667
...
...
@@ -12,7 +12,7 @@ import (
func
VmStdErrFormat
(
logs
[]
vm
.
StructLog
)
{
fmt
.
Fprintf
(
os
.
Stderr
,
"VM Stats %d ops
\n
"
,
len
(
logs
))
for
_
,
log
:=
range
logs
{
fmt
.
Fprintf
(
os
.
Stderr
,
"PC %
-3d - %-14
s
\n
"
,
log
.
Pc
,
log
.
Op
)
fmt
.
Fprintf
(
os
.
Stderr
,
"PC %
08d: %
s
\n
"
,
log
.
Pc
,
log
.
Op
)
fmt
.
Fprintln
(
os
.
Stderr
,
"STACK ="
,
len
(
log
.
Stack
))
for
i
,
item
:=
range
log
.
Stack
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%04d: %x
\n
"
,
i
,
common
.
LeftPadBytes
(
item
.
Bytes
(),
32
))
...
...
@@ -36,5 +36,11 @@ func VmStdErrFormat(logs []vm.StructLog) {
addr
++
fmt
.
Fprintln
(
os
.
Stderr
,
str
)
}
fmt
.
Fprintln
(
os
.
Stderr
,
"STORAGE ="
,
len
(
log
.
Storage
))
for
h
,
item
:=
range
log
.
Storage
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%x: %x
\n
"
,
h
,
common
.
LeftPadBytes
(
item
,
32
))
}
}
}
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