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
3e0dbe0e
Commit
3e0dbe0e
authored
Jul 19, 2017
by
Felix Lange
Committed by
GitHub
Jul 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/vm: remove logging and add section labels to struct logs (#14782)
parent
1802682f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
23 deletions
+16
-23
contracts.go
core/vm/contracts.go
+0
-3
interpreter.go
core/vm/interpreter.go
+0
-11
logger.go
core/vm/logger.go
+16
-9
No files found.
core/vm/contracts.go
View file @
3e0dbe0e
...
...
@@ -23,7 +23,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"golang.org/x/crypto/ripemd160"
)
...
...
@@ -76,14 +75,12 @@ func (c *ecrecover) Run(in []byte) ([]byte, error) {
// tighter sig s values in homestead only apply to tx sigs
if
!
allZero
(
in
[
32
:
63
])
||
!
crypto
.
ValidateSignatureValues
(
v
,
r
,
s
,
false
)
{
log
.
Trace
(
"ECRECOVER error: v, r or s value invalid"
)
return
nil
,
nil
}
// v needs to be at the end for libsecp256k1
pubKey
,
err
:=
crypto
.
Ecrecover
(
in
[
:
32
],
append
(
in
[
64
:
128
],
v
))
// make sure the public key is a valid one
if
err
!=
nil
{
log
.
Trace
(
"ECRECOVER failed"
,
"err"
,
err
)
return
nil
,
nil
}
...
...
core/vm/interpreter.go
View file @
3e0dbe0e
...
...
@@ -19,12 +19,10 @@ package vm
import
(
"fmt"
"sync/atomic"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
)
...
...
@@ -122,19 +120,12 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret
)
contract
.
Input
=
input
// User defer pattern to check for an error and, based on the error being nil or not, use all gas and return.
defer
func
()
{
if
err
!=
nil
&&
in
.
cfg
.
Debug
{
// XXX For debugging
//fmt.Printf("%04d: %8v cost = %-8d stack = %-8d ERR = %v\n", pc, op, cost, stack.len(), err)
in
.
cfg
.
Tracer
.
CaptureState
(
in
.
evm
,
pc
,
op
,
contract
.
Gas
,
cost
,
mem
,
stack
,
contract
,
in
.
evm
.
depth
,
err
)
}
}()
log
.
Debug
(
"interpreter running contract"
,
"hash"
,
codehash
[
:
])
tstart
:=
time
.
Now
()
defer
log
.
Debug
(
"interpreter finished running contract"
,
"hash"
,
codehash
[
:
],
"elapsed"
,
time
.
Since
(
tstart
))
// The Interpreter main run loop (contextual). This loop runs until either an
// explicit STOP, RETURN or SELFDESTRUCT is executed, an error occurred during
// the execution of one of the operations or until the done flag is set by the
...
...
@@ -190,8 +181,6 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret
if
in
.
cfg
.
Debug
{
in
.
cfg
.
Tracer
.
CaptureState
(
in
.
evm
,
pc
,
op
,
contract
.
Gas
,
cost
,
mem
,
stack
,
contract
,
in
.
evm
.
depth
,
err
)
}
// XXX For debugging
//fmt.Printf("%04d: %8v cost = %-8d stack = %-8d\n", pc, op, cost, stack.len())
// execute the operation
res
,
err
:=
operation
.
execute
(
&
pc
,
in
.
evm
,
contract
,
mem
,
stack
)
...
...
core/vm/logger.go
View file @
3e0dbe0e
...
...
@@ -196,20 +196,27 @@ func (l *StructLogger) StructLogs() []StructLog {
// WriteTrace writes a formatted trace to the given writer
func
WriteTrace
(
writer
io
.
Writer
,
logs
[]
StructLog
)
{
for
_
,
log
:=
range
logs
{
fmt
.
Fprintf
(
writer
,
"%-1
0
spc=%08d gas=%v cost=%v"
,
log
.
Op
,
log
.
Pc
,
log
.
Gas
,
log
.
GasCost
)
fmt
.
Fprintf
(
writer
,
"%-1
6
spc=%08d gas=%v cost=%v"
,
log
.
Op
,
log
.
Pc
,
log
.
Gas
,
log
.
GasCost
)
if
log
.
Err
!=
nil
{
fmt
.
Fprintf
(
writer
,
" ERROR: %v"
,
log
.
Err
)
}
fmt
.
Fprint
f
(
writer
,
"
\n
"
)
fmt
.
Fprint
ln
(
writer
)
for
i
:=
len
(
log
.
Stack
)
-
1
;
i
>=
0
;
i
--
{
fmt
.
Fprintf
(
writer
,
"%08d %x
\n
"
,
len
(
log
.
Stack
)
-
i
-
1
,
math
.
PaddedBigBytes
(
log
.
Stack
[
i
],
32
))
if
len
(
log
.
Stack
)
>
0
{
fmt
.
Fprintln
(
writer
,
"Stack:"
)
for
i
:=
len
(
log
.
Stack
)
-
1
;
i
>=
0
;
i
--
{
fmt
.
Fprintf
(
writer
,
"%08d %x
\n
"
,
len
(
log
.
Stack
)
-
i
-
1
,
math
.
PaddedBigBytes
(
log
.
Stack
[
i
],
32
))
}
}
fmt
.
Fprint
(
writer
,
hex
.
Dump
(
log
.
Memory
))
for
h
,
item
:=
range
log
.
Storage
{
fmt
.
Fprintf
(
writer
,
"%x: %x
\n
"
,
h
,
item
)
if
len
(
log
.
Memory
)
>
0
{
fmt
.
Fprintln
(
writer
,
"Memory:"
)
fmt
.
Fprint
(
writer
,
hex
.
Dump
(
log
.
Memory
))
}
if
len
(
log
.
Storage
)
>
0
{
fmt
.
Fprintln
(
writer
,
"Storage:"
)
for
h
,
item
:=
range
log
.
Storage
{
fmt
.
Fprintf
(
writer
,
"%x: %x
\n
"
,
h
,
item
)
}
}
fmt
.
Fprintln
(
writer
)
}
...
...
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