good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
6fb6e667
"git@gfx.cafe:open/bor.git" did not exist on "15540ae9928441a38f8af47d8227347e6bada5ae"
Commit
6fb6e667
authored
Jun 10, 2015
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
core/vm, core/state: added storage to structured vm logging
parent
38c61f6f
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
core/state/state_object.go
+16
-0
16 additions, 0 deletions
core/state/state_object.go
core/vm/environment.go
+6
-5
6 additions, 5 deletions
core/vm/environment.go
core/vm/vm.go
+10
-3
10 additions, 3 deletions
core/vm/vm.go
core/vm_logger.go
+7
-1
7 additions, 1 deletion
core/vm_logger.go
with
39 additions
and
9 deletions
core/state/state_object.go
+
16
−
0
View file @
6fb6e667
...
@@ -336,6 +336,22 @@ func (self *StateObject) Nonce() uint64 {
...
@@ -336,6 +336,22 @@ func (self *StateObject) Nonce() uint64 {
return
self
.
nonce
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
// Encoding
//
//
...
...
This diff is collapsed.
Click to expand it.
core/vm/environment.go
+
6
−
5
View file @
6fb6e667
...
@@ -39,6 +39,7 @@ type StructLog struct {
...
@@ -39,6 +39,7 @@ type StructLog struct {
Gas
*
big
.
Int
Gas
*
big
.
Int
Memory
[]
byte
Memory
[]
byte
Stack
[]
*
big
.
Int
Stack
[]
*
big
.
Int
Storage
map
[
common
.
Hash
][]
byte
}
}
type
Account
interface
{
type
Account
interface
{
...
...
This diff is collapsed.
Click to expand it.
core/vm/vm.go
+
10
−
3
View file @
6fb6e667
...
@@ -95,7 +95,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
...
@@ -95,7 +95,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
// Get the memory location of pc
// Get the memory location of pc
op
=
context
.
GetOp
(
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
)
newMemSize
,
gas
,
err
:=
self
.
calculateGasAndSize
(
context
,
caller
,
op
,
statedb
,
mem
,
stack
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -778,13 +778,20 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, callData []byte, context *
...
@@ -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
{
if
Debug
{
mem
:=
make
([]
byte
,
len
(
memory
.
Data
()))
mem
:=
make
([]
byte
,
len
(
memory
.
Data
()))
copy
(
mem
,
memory
.
Data
())
copy
(
mem
,
memory
.
Data
())
stck
:=
make
([]
*
big
.
Int
,
len
(
stack
.
Data
()))
stck
:=
make
([]
*
big
.
Int
,
len
(
stack
.
Data
()))
copy
(
stck
,
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
})
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
core/vm_logger.go
+
7
−
1
View file @
6fb6e667
...
@@ -12,7 +12,7 @@ import (
...
@@ -12,7 +12,7 @@ import (
func
VmStdErrFormat
(
logs
[]
vm
.
StructLog
)
{
func
VmStdErrFormat
(
logs
[]
vm
.
StructLog
)
{
fmt
.
Fprintf
(
os
.
Stderr
,
"VM Stats %d ops
\n
"
,
len
(
logs
))
fmt
.
Fprintf
(
os
.
Stderr
,
"VM Stats %d ops
\n
"
,
len
(
logs
))
for
_
,
log
:=
range
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
))
fmt
.
Fprintln
(
os
.
Stderr
,
"STACK ="
,
len
(
log
.
Stack
))
for
i
,
item
:=
range
log
.
Stack
{
for
i
,
item
:=
range
log
.
Stack
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%04d: %x
\n
"
,
i
,
common
.
LeftPadBytes
(
item
.
Bytes
(),
32
))
fmt
.
Fprintf
(
os
.
Stderr
,
"%04d: %x
\n
"
,
i
,
common
.
LeftPadBytes
(
item
.
Bytes
(),
32
))
...
@@ -36,5 +36,11 @@ func VmStdErrFormat(logs []vm.StructLog) {
...
@@ -36,5 +36,11 @@ func VmStdErrFormat(logs []vm.StructLog) {
addr
++
addr
++
fmt
.
Fprintln
(
os
.
Stderr
,
str
)
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
))
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment