-
Notifications
You must be signed in to change notification settings - Fork 20.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/evm: t8n support native tracers #28557
Merged
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
2a8b1a8
eth/tracers: JSONLogger implement tracers.Tracer
jsvisa 467f056
cmd/evm: use tracers.Trace instead of vm.EVMLogger
jsvisa 4c332a7
cmd/evm: add --trace.tracer
jsvisa 5044f95
cmd/evm: add --trace.tracer.config
jsvisa aea5fe0
cmd/evm/internal: simple
jsvisa 17455a1
cmd/evm/internal: check nil
jsvisa dce2e9b
cmd/evm/internal: trace.tracer usage
jsvisa 37f9e52
cmd/evm/t8n: simple
jsvisa 583fb9b
cmd/evm: remove deprecated flags, refactor tracewriter
holiman 6be8969
eth/tracers/logger: revert json-logger change
holiman 931c814
cm/evm: initialize tracer before getTracer
jsvisa 2d1f7eb
json -> jsonl
jsvisa 7c406db
cmd/evm: flag description
jsvisa a290bab
cmd/evm: file
jsvisa 3adc0c4
cmd/evm: keep json
jsvisa 2133961
Revert "cm/evm: initialize tracer before getTracer"
jsvisa dc79009
cmd/evm: polishes re tracer flags
holiman a9cbeb7
cmd/evm/internal: lint nits
holiman 1f47de2
Merge branch 'master' into evm-t8n-calltracer
holiman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2020 The go-ethereum Authors | ||
// This file is part of go-ethereum. | ||
// | ||
// go-ethereum is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// go-ethereum is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package t8ntool | ||
|
||
import ( | ||
"encoding/json" | ||
"io" | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/vm" | ||
"github.com/ethereum/go-ethereum/eth/tracers" | ||
"github.com/ethereum/go-ethereum/log" | ||
) | ||
|
||
// traceWriter is an vm.EVMLogger which also holds an inner logger/tracer. | ||
// When the TxEnd event happens, the inner tracer result is written to the file, and | ||
// the file is closed. | ||
type traceWriter struct { | ||
inner vm.EVMLogger | ||
f io.WriteCloser | ||
} | ||
|
||
// Compile-time interface check | ||
var _ = vm.EVMLogger((*traceWriter)(nil)) | ||
|
||
func (t *traceWriter) CaptureTxEnd(restGas uint64) { | ||
t.inner.CaptureTxEnd(restGas) | ||
defer t.f.Close() | ||
|
||
if tracer, ok := t.inner.(tracers.Tracer); ok { | ||
result, err := tracer.GetResult() | ||
if err != nil { | ||
log.Warn("Error in tracer", "err", err) | ||
return | ||
} | ||
err = json.NewEncoder(t.f).Encode(result) | ||
if err != nil { | ||
log.Warn("Error writing tracer output", "err", err) | ||
return | ||
} | ||
} | ||
} | ||
|
||
func (t *traceWriter) CaptureTxStart(gasLimit uint64) { t.inner.CaptureTxStart(gasLimit) } | ||
func (t *traceWriter) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) { | ||
t.inner.CaptureStart(env, from, to, create, input, gas, value) | ||
} | ||
|
||
func (t *traceWriter) CaptureEnd(output []byte, gasUsed uint64, err error) { | ||
t.inner.CaptureEnd(output, gasUsed, err) | ||
} | ||
|
||
func (t *traceWriter) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) { | ||
t.inner.CaptureEnter(typ, from, to, input, gas, value) | ||
} | ||
|
||
func (t *traceWriter) CaptureExit(output []byte, gasUsed uint64, err error) { | ||
t.inner.CaptureExit(output, gasUsed, err) | ||
} | ||
|
||
func (t *traceWriter) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) { | ||
t.inner.CaptureState(pc, op, gas, cost, scope, rData, depth, err) | ||
} | ||
func (t *traceWriter) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error) { | ||
t.inner.CaptureFault(pc, op, gas, cost, scope, depth, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the
--trace
configures the json tracer. For the other ones, it's implied. Why would you want to run a calltracer if it does not produce any output?I'll push a fix