fix genesis logging

This commit is contained in:
Sina Mahmoodi 2023-06-26 14:58:33 +02:00
parent 0d25fbc37d
commit 8db10784cb
4 changed files with 19 additions and 9 deletions

View File

@ -1741,6 +1741,9 @@ 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)

View File

@ -250,11 +250,19 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
Journal: cacheConfig.TrieCleanJournal,
Preimages: cacheConfig.Preimages,
})
var logger BlockchainLogger
if vmConfig.Tracer != nil {
l, ok := vmConfig.Tracer.(BlockchainLogger)
if !ok {
return nil, fmt.Errorf("only extended tracers are supported for live mode")
}
logger = l
}
// Setup the genesis block, commit the provided genesis specification
// to database if the genesis block is not present yet, or load the
// stored one from database.
// TODO: pass in blockchainLogger here to catch genesis block and allocs
chainConfig, genesisHash, genesisErr := SetupGenesisBlockWithOverride(db, triedb, genesis, overrides, nil)
chainConfig, genesisHash, genesisErr := SetupGenesisBlockWithOverride(db, triedb, genesis, overrides, logger)
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
return nil, genesisErr
}
@ -265,14 +273,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
}
log.Info(strings.Repeat("-", 153))
log.Info("")
var logger BlockchainLogger
if vmConfig.Tracer != nil {
l, ok := vmConfig.Tracer.(BlockchainLogger)
if !ok {
return nil, fmt.Errorf("only extended tracers are supported for live mode")
}
logger = l
}
bc := &BlockChain{
chainConfig: chainConfig,

View File

@ -42,6 +42,7 @@ 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"
@ -192,6 +193,9 @@ 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 {

View File

@ -147,6 +147,9 @@ 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:"-"`