mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 00:43:46 +00:00
Merge branch 'extended-tracer-backport-1.13.5' into extended-tracer-sei
# Conflicts: # cmd/geth/config.go
This commit is contained in:
commit
04d3f64a96
7 changed files with 24 additions and 18 deletions
|
|
@ -36,7 +36,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/eth/catalyst"
|
"github.com/ethereum/go-ethereum/eth/catalyst"
|
||||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
"github.com/ethereum/go-ethereum/eth/tracers/directory"
|
"github.com/ethereum/go-ethereum/eth/tracers/directory/live"
|
||||||
"github.com/ethereum/go-ethereum/lib/ethapi"
|
"github.com/ethereum/go-ethereum/lib/ethapi"
|
||||||
"github.com/ethereum/go-ethereum/lib/flags"
|
"github.com/ethereum/go-ethereum/lib/flags"
|
||||||
"github.com/ethereum/go-ethereum/lib/version"
|
"github.com/ethereum/go-ethereum/lib/version"
|
||||||
|
|
@ -181,7 +181,7 @@ 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 := directory.LiveDirectory.New(name)
|
t, err := live.Directory.New(name)
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/eth/filters"
|
"github.com/ethereum/go-ethereum/eth/filters"
|
||||||
"github.com/ethereum/go-ethereum/eth/gasprice"
|
"github.com/ethereum/go-ethereum/eth/gasprice"
|
||||||
"github.com/ethereum/go-ethereum/eth/tracers"
|
"github.com/ethereum/go-ethereum/eth/tracers"
|
||||||
"github.com/ethereum/go-ethereum/eth/tracers/directory"
|
"github.com/ethereum/go-ethereum/eth/tracers/directory/live"
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
"github.com/ethereum/go-ethereum/ethdb/remotedb"
|
"github.com/ethereum/go-ethereum/ethdb/remotedb"
|
||||||
"github.com/ethereum/go-ethereum/ethstats"
|
"github.com/ethereum/go-ethereum/ethstats"
|
||||||
|
|
@ -2124,7 +2124,7 @@ 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 := directory.LiveDirectory.New(name)
|
t, err := live.Directory.New(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("Failed to create tracer %q: %v", name, err)
|
Fatalf("Failed to create tracer %q: %v", name, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -292,10 +292,11 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
|
||||||
var logger BlockchainLogger
|
var logger BlockchainLogger
|
||||||
if vmConfig.Tracer != nil {
|
if vmConfig.Tracer != nil {
|
||||||
l, ok := vmConfig.Tracer.(BlockchainLogger)
|
l, ok := vmConfig.Tracer.(BlockchainLogger)
|
||||||
if !ok {
|
if ok {
|
||||||
return nil, errors.New("only extended tracers are supported for live mode")
|
logger = l
|
||||||
|
} else {
|
||||||
|
log.Warn("only extended tracers are supported for live mode")
|
||||||
}
|
}
|
||||||
logger = l
|
|
||||||
}
|
}
|
||||||
// Setup the genesis block, commit the provided genesis specification
|
// Setup the genesis block, commit the provided genesis specification
|
||||||
// to database if the genesis block is not present yet, or load the
|
// to database if the genesis block is not present yet, or load the
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/eth/tracers/logger"
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
|
|
@ -3247,7 +3248,7 @@ func testDeleteRecreateSlots(t *testing.T, scheme string) {
|
||||||
})
|
})
|
||||||
// Import the canonical chain
|
// Import the canonical chain
|
||||||
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), DefaultCacheConfigWithScheme(scheme), gspec, nil, engine, vm.Config{
|
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), DefaultCacheConfigWithScheme(scheme), gspec, nil, engine, vm.Config{
|
||||||
//Tracer: logger.NewJSONLogger(nil, os.Stdout),
|
Tracer: logger.NewJSONLogger(nil, os.Stdout),
|
||||||
}, nil, nil)
|
}, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create tester chain: %v", err)
|
t.Fatalf("failed to create tester chain: %v", err)
|
||||||
|
|
@ -3329,7 +3330,7 @@ func testDeleteRecreateAccount(t *testing.T, scheme string) {
|
||||||
})
|
})
|
||||||
// Import the canonical chain
|
// Import the canonical chain
|
||||||
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), DefaultCacheConfigWithScheme(scheme), gspec, nil, engine, vm.Config{
|
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), DefaultCacheConfigWithScheme(scheme), gspec, nil, engine, vm.Config{
|
||||||
//Tracer: logger.NewJSONLogger(nil, os.Stdout),
|
Tracer: logger.NewJSONLogger(nil, os.Stdout),
|
||||||
}, nil, nil)
|
}, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create tester chain: %v", err)
|
t.Fatalf("failed to create tester chain: %v", err)
|
||||||
|
|
@ -4681,7 +4682,7 @@ func TestEIP3651(t *testing.T) {
|
||||||
|
|
||||||
b.AddTx(tx)
|
b.AddTx(tx)
|
||||||
})
|
})
|
||||||
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), nil, gspec, nil, engine, vm.Config{ /*Tracer: logger.NewMarkdownLogger(&logger.Config{}, os.Stderr)*/ }, nil, nil)
|
chain, err := NewBlockChain(rawdb.NewMemoryDatabase(), nil, gspec, nil, engine, vm.Config{Tracer: logger.NewMarkdownLogger(&logger.Config{}, os.Stderr)}, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create tester chain: %v", err)
|
t.Fatalf("failed to create tester chain: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package directory
|
package live
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -8,21 +8,21 @@ import (
|
||||||
|
|
||||||
type ctorFunc func() (core.BlockchainLogger, error)
|
type ctorFunc func() (core.BlockchainLogger, error)
|
||||||
|
|
||||||
// LiveDirectory 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.
|
||||||
var LiveDirectory = liveDirectory{elems: make(map[string]ctorFunc)}
|
var Directory = directory{elems: make(map[string]ctorFunc)}
|
||||||
|
|
||||||
type liveDirectory struct {
|
type directory struct {
|
||||||
elems map[string]ctorFunc
|
elems map[string]ctorFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register registers a tracer constructor by name.
|
// Register registers a tracer constructor by name.
|
||||||
func (d *liveDirectory) Register(name string, f ctorFunc) {
|
func (d *directory) Register(name string, f ctorFunc) {
|
||||||
d.elems[name] = f
|
d.elems[name] = f
|
||||||
}
|
}
|
||||||
|
|
||||||
// New instantiates a tracer by name.
|
// New instantiates a tracer by name.
|
||||||
func (d *liveDirectory) New(name string) (core.BlockchainLogger, error) {
|
func (d *directory) New(name string) (core.BlockchainLogger, error) {
|
||||||
if f, ok := d.elems[name]; ok {
|
if f, ok := d.elems[name]; ok {
|
||||||
return f()
|
return f()
|
||||||
}
|
}
|
||||||
|
|
@ -8,12 +8,12 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
"github.com/ethereum/go-ethereum/eth/tracers/directory"
|
"github.com/ethereum/go-ethereum/eth/tracers/directory/live"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
directory.LiveDirectory.Register("noop", newNoopTracer)
|
live.Directory.Register("noop", newNoopTracer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// noop is a no-op live tracer. It's there to
|
// noop is a no-op live tracer. It's there to
|
||||||
|
|
|
||||||
|
|
@ -335,6 +335,10 @@ func NewMarkdownLogger(cfg *Config, writer io.Writer) *mdLogger {
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *mdLogger) CaptureTxStart(env *vm.EVM, tx *types.Transaction, from common.Address) {
|
||||||
|
t.env = env
|
||||||
|
}
|
||||||
|
|
||||||
func (t *mdLogger) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
func (t *mdLogger) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
||||||
if !create {
|
if !create {
|
||||||
fmt.Fprintf(t.out, "From: `%v`\nTo: `%v`\nData: `%#x`\nGas: `%d`\nValue `%v` wei\n",
|
fmt.Fprintf(t.out, "From: `%v`\nTo: `%v`\nData: `%#x`\nGas: `%d`\nValue `%v` wei\n",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue