add config for tracers
This commit is contained in:
parent
4cd7cb3637
commit
674a38ed60
|
@ -100,6 +100,7 @@ if one is set. Otherwise it prints the genesis from the datadir.`,
|
||||||
utils.MetricsInfluxDBOrganizationFlag,
|
utils.MetricsInfluxDBOrganizationFlag,
|
||||||
utils.TxLookupLimitFlag,
|
utils.TxLookupLimitFlag,
|
||||||
utils.VMTraceFlag,
|
utils.VMTraceFlag,
|
||||||
|
utils.VMTraceConfigFlag,
|
||||||
utils.TransactionHistoryFlag,
|
utils.TransactionHistoryFlag,
|
||||||
utils.StateHistoryFlag,
|
utils.StateHistoryFlag,
|
||||||
}, utils.DatabaseFlags),
|
}, utils.DatabaseFlags),
|
||||||
|
|
|
@ -18,6 +18,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
@ -181,7 +182,11 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
|
||||||
|
|
||||||
if ctx.IsSet(utils.VMTraceFlag.Name) {
|
if ctx.IsSet(utils.VMTraceFlag.Name) {
|
||||||
if name := ctx.String(utils.VMTraceFlag.Name); name != "" {
|
if name := ctx.String(utils.VMTraceFlag.Name); name != "" {
|
||||||
t, err := live.Directory.New(name)
|
var config string
|
||||||
|
if ctx.IsSet(utils.VMTraceConfigFlag.Name) {
|
||||||
|
config = ctx.String(utils.VMTraceConfigFlag.Name)
|
||||||
|
}
|
||||||
|
t, err := live.Directory.New(name, json.RawMessage(config))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Failed to create tracer %q: %v", name, err)
|
utils.Fatalf("Failed to create tracer %q: %v", name, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,7 @@ var (
|
||||||
utils.DeveloperPeriodFlag,
|
utils.DeveloperPeriodFlag,
|
||||||
utils.VMEnableDebugFlag,
|
utils.VMEnableDebugFlag,
|
||||||
utils.VMTraceFlag,
|
utils.VMTraceFlag,
|
||||||
|
utils.VMTraceConfigFlag,
|
||||||
utils.NetworkIdFlag,
|
utils.NetworkIdFlag,
|
||||||
utils.EthStatsURLFlag,
|
utils.EthStatsURLFlag,
|
||||||
utils.NoCompactionFlag,
|
utils.NoCompactionFlag,
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
@ -502,7 +503,11 @@ var (
|
||||||
Usage: "Name of tracer which should record internal VM operations (costly)",
|
Usage: "Name of tracer which should record internal VM operations (costly)",
|
||||||
Category: flags.VMCategory,
|
Category: flags.VMCategory,
|
||||||
}
|
}
|
||||||
|
VMTraceConfigFlag = &cli.StringFlag{
|
||||||
|
Name: "vmtrace.config",
|
||||||
|
Usage: "Tracer configuration (JSON)",
|
||||||
|
Category: flags.VMCategory,
|
||||||
|
}
|
||||||
// API options.
|
// API options.
|
||||||
RPCGlobalGasCapFlag = &cli.Uint64Flag{
|
RPCGlobalGasCapFlag = &cli.Uint64Flag{
|
||||||
Name: "rpc.gascap",
|
Name: "rpc.gascap",
|
||||||
|
@ -2128,7 +2133,11 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
|
||||||
vmcfg := vm.Config{EnablePreimageRecording: ctx.Bool(VMEnableDebugFlag.Name)}
|
vmcfg := vm.Config{EnablePreimageRecording: ctx.Bool(VMEnableDebugFlag.Name)}
|
||||||
if ctx.IsSet(VMTraceFlag.Name) {
|
if ctx.IsSet(VMTraceFlag.Name) {
|
||||||
if name := ctx.String(VMTraceFlag.Name); name != "" {
|
if name := ctx.String(VMTraceFlag.Name); name != "" {
|
||||||
t, err := live.Directory.New(name)
|
var config string
|
||||||
|
if ctx.IsSet(VMTraceConfigFlag.Name) {
|
||||||
|
config = ctx.String(VMTraceConfigFlag.Name)
|
||||||
|
}
|
||||||
|
t, err := live.Directory.New(name, json.RawMessage(config))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("Failed to create tracer %q: %v", name, err)
|
Fatalf("Failed to create tracer %q: %v", name, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package live
|
package live
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ctorFunc func() (core.BlockchainLogger, error)
|
type ctorFunc func(config json.RawMessage) (core.BlockchainLogger, error)
|
||||||
|
|
||||||
// Directory is the collection of tracers which can be used
|
// Directory is the collection of tracers which can be used
|
||||||
// during normal block import operations.
|
// during normal block import operations.
|
||||||
|
@ -22,9 +23,9 @@ func (d *directory) Register(name string, f ctorFunc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// New instantiates a tracer by name.
|
// New instantiates a tracer by name.
|
||||||
func (d *directory) New(name string) (core.BlockchainLogger, error) {
|
func (d *directory) New(name string, config json.RawMessage) (core.BlockchainLogger, error) {
|
||||||
if f, ok := d.elems[name]; ok {
|
if f, ok := d.elems[name]; ok {
|
||||||
return f()
|
return f(config)
|
||||||
}
|
}
|
||||||
return nil, errors.New("not found")
|
return nil, errors.New("not found")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue