Skip to content

Commit

Permalink
polygon: keep devp2p max peers default to 100 as before (#13361)
Browse files Browse the repository at this point in the history
Follow up after #13003 changed
default devp2p peers from 100 to 32
Keep the previous default of 100 pers for polygon since the
recommendation for it is to keep a higher peer count as per recent
changes to their peering strategy -
https://forum.polygon.technology/t/introducing-our-new-dns-discovery-for-polygon-pos-faster-smarter-more-connected/19871
  • Loading branch information
taratorio authored Jan 9, 2025
1 parent f812087 commit 8cf8b1f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8cf8b1f

Please sign in to comment.