diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 97ae92d9205..de1539344f0 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1420,8 +1420,7 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config, nodeName, datadir string, l cfg.MetricsEnabled = ctx.Bool(MetricsEnabledFlag.Name) } - ethPeers := cfg.MaxPeers - logger.Info("Maximum peer count", "ETH", ethPeers, "total", cfg.MaxPeers) + logger.Info("Maximum peer count", "total", cfg.MaxPeers) if netrestrict := ctx.String(NetrestrictFlag.Name); netrestrict != "" { list, err := netutil.ParseNetlist(netrestrict) @@ -1679,15 +1678,23 @@ func setClique(ctx *cli.Context, cfg *params.ConsensusSnapshotConfig, datadir st } } -func setBorConfig(ctx *cli.Context, cfg *ethconfig.Config) { +func setBorConfig(ctx *cli.Context, cfg *ethconfig.Config, nodeConfig *nodecfg.Config, logger log.Logger) { cfg.HeimdallURL = ctx.String(HeimdallURLFlag.Name) cfg.WithoutHeimdall = ctx.Bool(WithoutHeimdallFlag.Name) cfg.WithHeimdallMilestones = ctx.Bool(WithHeimdallMilestones.Name) cfg.WithHeimdallWaypointRecording = ctx.Bool(WithHeimdallWaypoints.Name) cfg.PolygonSync = ctx.Bool(PolygonSyncFlag.Name) cfg.PolygonSyncStage = ctx.Bool(PolygonSyncStageFlag.Name) - heimdall.RecordWayPoints( - cfg.WithHeimdallWaypointRecording || cfg.PolygonSync || cfg.PolygonSyncStage) + heimdall.RecordWayPoints(cfg.WithHeimdallWaypointRecording || cfg.PolygonSync || cfg.PolygonSyncStage) + + chainConfig := params.ChainConfigByChainName(ctx.String(ChainFlag.Name)) + if chainConfig.Bor != nil && !ctx.IsSet(MaxPeersFlag.Name) { + // override default max devp2p peers for polygon as per + // https://forum.polygon.technology/t/introducing-our-new-dns-discovery-for-polygon-pos-faster-smarter-more-connected/19871 + // which encourages high peer count + nodeConfig.P2P.MaxPeers = 100 + logger.Info("Maximum peer count default sanitizing for bor", "total", nodeConfig.P2P.MaxPeers) + } } func setMiner(ctx *cli.Context, cfg *params.MiningConfig) { @@ -1928,7 +1935,7 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C setClique(ctx, &cfg.Clique, nodeConfig.Dirs.DataDir) setMiner(ctx, &cfg.Miner) setWhitelist(ctx, cfg) - setBorConfig(ctx, cfg) + setBorConfig(ctx, cfg, nodeConfig, logger) setSilkworm(ctx, cfg) if err := setBeaconAPI(ctx, cfg); err != nil { log.Error("Failed to set beacon API", "err", err)