pass tracer name via cli
This commit is contained in:
parent
216a4b0f5a
commit
659043a1d9
|
@ -54,6 +54,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/eth/filters"
|
||||
"github.com/ethereum/go-ethereum/eth/gasprice"
|
||||
"github.com/ethereum/go-ethereum/eth/tracers"
|
||||
liveTracers "github.com/ethereum/go-ethereum/eth/tracers/live"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/ethdb/remotedb"
|
||||
"github.com/ethereum/go-ethereum/ethstats"
|
||||
|
@ -518,9 +519,9 @@ var (
|
|||
Usage: "Record information useful for VM and contract debugging",
|
||||
Category: flags.VMCategory,
|
||||
}
|
||||
VMTraceFlag = &cli.BoolFlag{
|
||||
VMTraceFlag = &cli.StringFlag{
|
||||
Name: "vmtrace",
|
||||
Usage: "Record internal VM operations (costly)",
|
||||
Usage: "Name of tracer which should record internal VM operations (costly)",
|
||||
Category: flags.VMCategory,
|
||||
}
|
||||
|
||||
|
@ -1723,9 +1724,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
|||
// TODO(fjl): force-enable this in --dev mode
|
||||
cfg.EnablePreimageRecording = ctx.Bool(VMEnableDebugFlag.Name)
|
||||
}
|
||||
if ctx.IsSet(VMTraceFlag.Name) {
|
||||
cfg.LiveTrace = ctx.Bool(VMTraceFlag.Name)
|
||||
}
|
||||
|
||||
if ctx.IsSet(RPCGlobalGasCapFlag.Name) {
|
||||
cfg.RPCGasCap = ctx.Uint64(RPCGlobalGasCapFlag.Name)
|
||||
|
@ -2143,7 +2141,13 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
|
|||
}
|
||||
vmcfg := vm.Config{EnablePreimageRecording: ctx.Bool(VMEnableDebugFlag.Name)}
|
||||
if ctx.IsSet(VMTraceFlag.Name) {
|
||||
vmcfg.Tracer = tracers.NewPrinter()
|
||||
if name := ctx.String(VMTraceFlag.Name); name != "" {
|
||||
t, err := liveTracers.New(name)
|
||||
if err != nil {
|
||||
Fatalf("Failed to create tracer %q: %v", name, err)
|
||||
}
|
||||
vmcfg.Tracer = t
|
||||
}
|
||||
}
|
||||
// Disable transaction indexing/unindexing by default.
|
||||
chain, err := core.NewBlockChain(chainDb, cache, gspec, nil, engine, vmcfg, nil, nil)
|
||||
|
|
|
@ -44,7 +44,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/eth/gasprice"
|
||||
"github.com/ethereum/go-ethereum/eth/protocols/eth"
|
||||
"github.com/ethereum/go-ethereum/eth/protocols/snap"
|
||||
"github.com/ethereum/go-ethereum/eth/tracers"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||
|
@ -194,9 +193,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||
Preimages: config.Preimages,
|
||||
}
|
||||
)
|
||||
if config.LiveTrace {
|
||||
vmConfig.Tracer = tracers.NewPrinter()
|
||||
}
|
||||
// Override the chain config with provided settings.
|
||||
var overrides core.ChainOverrides
|
||||
if config.OverrideCancun != nil {
|
||||
|
|
|
@ -140,9 +140,6 @@ type Config struct {
|
|||
// Enables tracking of SHA3 preimages in the VM
|
||||
EnablePreimageRecording bool
|
||||
|
||||
// LiveTrace will enable tracing during normal chain processing.
|
||||
LiveTrace bool
|
||||
|
||||
// Miscellaneous options
|
||||
DocRoot string `toml:"-"`
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package tracers
|
||||
package live
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
@ -8,14 +8,19 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
register("printer", newPrinter)
|
||||
}
|
||||
|
||||
type Printer struct{}
|
||||
|
||||
func NewPrinter() *Printer {
|
||||
return &Printer{}
|
||||
func newPrinter() (core.BlockchainLogger, error) {
|
||||
return &Printer{}, nil
|
||||
}
|
||||
|
||||
// CaptureStart implements the EVMLogger interface to initialize the tracing operation.
|
||||
|
@ -91,7 +96,7 @@ func (p *Printer) OnGenesisBlock(b *types.Block, alloc core.GenesisAlloc) {
|
|||
fmt.Printf("OnGenesisBlock: b=%v, allocLength=%d\n", b.NumberU64(), len(alloc))
|
||||
}
|
||||
|
||||
func (p *Printer) OnBalanceChange(a common.Address, prev, new *big.Int) {
|
||||
func (p *Printer) OnBalanceChange(a common.Address, prev, new *big.Int, reason state.BalanceChangeReason) {
|
||||
fmt.Printf("OnBalanceChange: a=%v, prev=%v, new=%v\n", a, prev, new)
|
||||
}
|
||||
|
Loading…
Reference in New Issue