mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/evm: polishes re tracer flags
This commit is contained in:
parent
2133961a84
commit
dc79009925
2 changed files with 34 additions and 35 deletions
|
|
@ -28,15 +28,15 @@ import (
|
|||
var (
|
||||
TraceFlag = &cli.BoolFlag{
|
||||
Name: "trace",
|
||||
Usage: "Output full trace logs to a file named: trace-<txIndex>-<txHash>.json or trace-<txIndex>-<txHash>.jsonl",
|
||||
Usage: "Configures the use of the JSON opcode tracer. This tracer emits traces to files as trace-<txIndex>-<txHash>.jsonl",
|
||||
}
|
||||
TraceTracerFlag = &cli.StringFlag{
|
||||
Name: "trace.tracer",
|
||||
Usage: "The type of tracer. It could be native or js tracers, eg: callTracer,4byteTracer",
|
||||
Usage: "Configures the use of a custom tracer, e.g native or js tracers. Examples are callTracer and 4byteTracer. These tracers emit results into files as trace-<txIndex>-<txHash>.json",
|
||||
}
|
||||
TraceTracerConfigFlag = &cli.StringFlag{
|
||||
Name: "trace.jsonconfig",
|
||||
Usage: "The configurations of --trace.tracer, in JSON encoded format",
|
||||
Usage: "The configurations for the custom tracer specified by --trace.tracer. If provided, must be in JSON format",
|
||||
}
|
||||
TraceEnableMemoryFlag = &cli.BoolFlag{
|
||||
Name: "trace.memory",
|
||||
|
|
|
|||
|
|
@ -93,8 +93,22 @@ func Transition(ctx *cli.Context) error {
|
|||
return NewError(ErrorIO, fmt.Errorf("failed creating output basedir: %v", err))
|
||||
}
|
||||
|
||||
if ctx.Bool(TraceFlag.Name) {
|
||||
if ctx.IsSet(TraceTracerFlag.Name) {
|
||||
if ctx.Bool(TraceFlag.Name) { // JSON opcode tracing
|
||||
// Configure the EVM logger
|
||||
logConfig := &logger.Config{
|
||||
DisableStack: ctx.Bool(TraceDisableStackFlag.Name),
|
||||
EnableMemory: ctx.Bool(TraceEnableMemoryFlag.Name),
|
||||
EnableReturnData: ctx.Bool(TraceEnableReturnDataFlag.Name),
|
||||
Debug: true,
|
||||
}
|
||||
getTracer = func(txIndex int, txHash common.Hash) (vm.EVMLogger, error) {
|
||||
traceFile, err := os.Create(path.Join(baseDir, fmt.Sprintf("trace-%d-%v.jsonl", txIndex, txHash.String())))
|
||||
if err != nil {
|
||||
return nil, NewError(ErrorIO, fmt.Errorf("failed creating trace-file: %v", err))
|
||||
}
|
||||
return &traceWriter{logger.NewJSONLogger(logConfig, traceFile), traceFile}, nil
|
||||
}
|
||||
} else if ctx.IsSet(TraceTracerFlag.Name) {
|
||||
var config json.RawMessage
|
||||
if ctx.IsSet(TraceTracerConfigFlag.Name) {
|
||||
config = []byte(ctx.String(TraceTracerConfigFlag.Name))
|
||||
|
|
@ -110,22 +124,7 @@ func Transition(ctx *cli.Context) error {
|
|||
}
|
||||
return &traceWriter{tracer, traceFile}, nil
|
||||
}
|
||||
} else {
|
||||
// Configure the EVM logger
|
||||
logConfig := &logger.Config{
|
||||
DisableStack: ctx.Bool(TraceDisableStackFlag.Name),
|
||||
EnableMemory: ctx.Bool(TraceEnableMemoryFlag.Name),
|
||||
EnableReturnData: ctx.Bool(TraceEnableReturnDataFlag.Name),
|
||||
Debug: true,
|
||||
}
|
||||
getTracer = func(txIndex int, txHash common.Hash) (vm.EVMLogger, error) {
|
||||
traceFile, err := os.Create(path.Join(baseDir, fmt.Sprintf("trace-%d-%v.jsonl", txIndex, txHash.String())))
|
||||
if err != nil {
|
||||
return nil, NewError(ErrorIO, fmt.Errorf("failed creating trace-file: %v", err))
|
||||
}
|
||||
return &traceWriter{logger.NewJSONLogger(logConfig, traceFile), traceFile}, nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// We need to load three things: alloc, env and transactions. May be either in
|
||||
// stdin input or in files.
|
||||
|
|
|
|||
Loading…
Reference in a new issue