diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 3e0da27edd..10d2224a14 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -259,6 +259,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) { utils.EnableBuildInfo(git.Commit, git.Date), utils.EnableMinerInfo(ctx, &cfg.Eth.Miner), utils.EnableNodeInfo(&cfg.Eth.TxPool, stack.Server().NodeInfo()), + utils.EnableNodeTrack(ctx, &cfg.Eth, stack), ) return stack, backend } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 1a0f0a040f..f26ce3881e 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -35,6 +35,8 @@ import ( "strings" "time" + "github.com/ethereum/go-ethereum/internal/version" + "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/beacon/fakebeacon" @@ -2317,6 +2319,67 @@ func EnableNodeInfo(poolConfig *legacypool.Config, nodeInfo *p2p.NodeInfo) Setup } } +func EnableNodeTrack(ctx *cli.Context, cfg *ethconfig.Config, stack *node.Node) SetupMetricsOption { + nodeInfo := stack.Server().NodeInfo() + return func() { + // register node info into metrics + metrics.NewRegisteredLabel("node-stats", nil).Mark(map[string]interface{}{ + "NodeType": parseNodeType(), + "ENR": nodeInfo.ENR, + "Mining": ctx.Bool(MiningEnabledFlag.Name), + "Etherbase": parseEtherbase(cfg), + "MiningFeatures": parseMiningFeatures(ctx, cfg), + "DBFeatures": parseDBFeatures(cfg, stack), + }) + } +} + +func parseEtherbase(cfg *ethconfig.Config) string { + if cfg.Miner.Etherbase == (common.Address{}) { + return "" + } + return cfg.Miner.Etherbase.String() +} + +func parseNodeType() string { + git, _ := version.VCS() + version := []string{params.VersionWithMeta} + if len(git.Commit) >= 7 { + version = append(version, git.Commit[:7]) + } + if git.Date != "" { + version = append(version, git.Date) + } + arch := []string{runtime.GOOS, runtime.GOARCH} + infos := []string{"BSC", strings.Join(version, "-"), strings.Join(arch, "-"), runtime.Version()} + return strings.Join(infos, "/") +} + +func parseDBFeatures(cfg *ethconfig.Config, stack *node.Node) string { + var features []string + if cfg.StateScheme == rawdb.PathScheme { + features = append(features, "PBSS") + } + if stack.CheckIfMultiDataBase() { + features = append(features, "MultiDB") + } + return strings.Join(features, "|") +} + +func parseMiningFeatures(ctx *cli.Context, cfg *ethconfig.Config) string { + if !ctx.Bool(MiningEnabledFlag.Name) { + return "" + } + var features []string + if cfg.Miner.Mev.Enabled { + features = append(features, "MEV") + } + if cfg.Miner.VoteEnable { + features = append(features, "FFVoting") + } + return strings.Join(features, "|") +} + func SetupMetrics(ctx *cli.Context, options ...SetupMetricsOption) { if metrics.Enabled { log.Info("Enabling metrics collection") diff --git a/core/blockchain.go b/core/blockchain.go index c50520b203..b2a56d74bf 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -100,6 +100,8 @@ var ( blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil) blockReorgDropMeter = metrics.NewRegisteredMeter("chain/reorg/drop", nil) + blockRecvTimeDiffGauge = metrics.NewRegisteredGauge("chain/block/recvtimediff", nil) + errStateRootVerificationFailed = errors.New("state root verification failed") errInsertionInterrupted = errors.New("insertion is interrupted") errChainStopped = errors.New("blockchain is stopped") @@ -2055,6 +2057,9 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error) return 0, nil } + if len(chain) > 0 { + blockRecvTimeDiffGauge.Update(time.Now().Unix() - int64(chain[0].Time())) + } // Start a parallel signature recovery (signer will fluke on fork transition, minimal perf loss) signer := types.MakeSigner(bc.chainConfig, chain[0].Number(), chain[0].Time()) go SenderCacher.RecoverFromBlocks(signer, chain)