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
10af69b5
Commit
10af69b5
authored
Jun 10, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core, core/vm: moved logger and added gas cost to struct logging
parent
fc2a061d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
10 deletions
+10
-10
state_transition.go
core/state_transition.go
+1
-1
environment.go
core/vm/environment.go
+1
-0
logger.go
core/vm/logger.go
+4
-5
vm.go
core/vm/vm.go
+4
-4
No files found.
core/state_transition.go
View file @
10af69b5
...
...
@@ -224,7 +224,7 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
}
if
vm
.
Debug
{
Vm
StdErrFormat
(
vmenv
.
StructLogs
())
vm
.
StdErrFormat
(
vmenv
.
StructLogs
())
}
self
.
refundGas
()
...
...
core/vm/environment.go
View file @
10af69b5
...
...
@@ -41,6 +41,7 @@ type StructLog struct {
Pc
uint64
Op
OpCode
Gas
*
big
.
Int
GasCost
*
big
.
Int
Memory
[]
byte
Stack
[]
*
big
.
Int
Storage
map
[
common
.
Hash
][]
byte
...
...
core/vm
_
logger.go
→
core/vm
/
logger.go
View file @
10af69b5
package
core
package
vm
import
(
"fmt"
...
...
@@ -6,13 +6,12 @@ import (
"unicode/utf8"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
)
func
VmStdErrFormat
(
logs
[]
vm
.
StructLog
)
{
func
StdErrFormat
(
logs
[]
StructLog
)
{
fmt
.
Fprintf
(
os
.
Stderr
,
"VM Stats %d ops
\n
"
,
len
(
logs
))
for
_
,
log
:=
range
logs
{
fmt
.
Fprintf
(
os
.
Stderr
,
"PC %08d: %s
\n
"
,
log
.
Pc
,
log
.
Op
)
fmt
.
Fprintf
(
os
.
Stderr
,
"PC %08d: %s
GAS: %v COST: %v
\n
"
,
log
.
Pc
,
log
.
Op
,
log
.
Gas
,
log
.
GasCost
)
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
))
...
...
@@ -41,6 +40,6 @@ func VmStdErrFormat(logs []vm.StructLog) {
for
h
,
item
:=
range
log
.
Storage
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%x: %x
\n
"
,
h
,
common
.
LeftPadBytes
(
item
,
32
))
}
fmt
.
Fprintln
(
os
.
Stderr
)
}
}
core/vm/vm.go
View file @
10af69b5
...
...
@@ -100,14 +100,14 @@ func (self *Vm) Run(context *Context, input []byte) (ret []byte, err error) {
// Get the memory location of pc
op
=
context
.
GetOp
(
pc
)
self
.
log
(
pc
,
op
,
context
.
Gas
,
mem
,
stack
,
context
)
// calculate the new memory size and gas price for the current executing opcode
newMemSize
,
gas
,
err
:=
self
.
calculateGasAndSize
(
context
,
caller
,
op
,
statedb
,
mem
,
stack
)
if
err
!=
nil
{
return
nil
,
err
}
self
.
log
(
pc
,
op
,
context
.
Gas
,
gas
,
mem
,
stack
,
context
)
// Use the calculated gas. When insufficient gas is present, use all gas and return an
// Out Of Gas error
if
!
context
.
UseGas
(
gas
)
{
...
...
@@ -789,7 +789,7 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, input []byte, context *Con
// log emits a log event to the environment for each opcode encountered. This is not to be confused with the
// LOG* opcode.
func
(
self
*
Vm
)
log
(
pc
uint64
,
op
OpCode
,
gas
*
big
.
Int
,
memory
*
Memory
,
stack
*
stack
,
context
*
Context
)
{
func
(
self
*
Vm
)
log
(
pc
uint64
,
op
OpCode
,
gas
,
cost
*
big
.
Int
,
memory
*
Memory
,
stack
*
stack
,
context
*
Context
)
{
if
Debug
{
mem
:=
make
([]
byte
,
len
(
memory
.
Data
()))
copy
(
mem
,
memory
.
Data
())
...
...
@@ -802,7 +802,7 @@ func (self *Vm) log(pc uint64, op OpCode, gas *big.Int, memory *Memory, stack *s
storage
[
common
.
BytesToHash
(
k
)]
=
v
})
self
.
env
.
AddStructLog
(
StructLog
{
pc
,
op
,
new
(
big
.
Int
)
.
Set
(
gas
),
mem
,
stck
,
storage
})
self
.
env
.
AddStructLog
(
StructLog
{
pc
,
op
,
new
(
big
.
Int
)
.
Set
(
gas
),
cost
,
mem
,
stck
,
storage
})
}
}
...
...
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