github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/netconf/flags.go (about)

     1  package netconf
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	"github.com/spf13/pflag"
     8  	"github.com/spf13/viper"
     9  
    10  	p2pconfig "github.com/onflow/flow-go/network/p2p/config"
    11  )
    12  
    13  const (
    14  	// All constant strings are used for CLI flag names and corresponding keys for config values.
    15  	// network configuration
    16  	networkingConnectionPruning       = "networking-connection-pruning"
    17  	preferredUnicastsProtocols        = "preferred-unicast-protocols"
    18  	receivedMessageCacheSize          = "received-message-cache-size"
    19  	peerUpdateInterval                = "peerupdate-interval"
    20  	dnsCacheTTL                       = "dns-cache-ttl"
    21  	disallowListNotificationCacheSize = "disallow-list-notification-cache-size"
    22  	// resource manager config
    23  	rootResourceManagerPrefix  = "libp2p-resource-manager"
    24  	memoryLimitRatioPrefix     = "memory-limit-ratio"
    25  	fileDescriptorsRatioPrefix = "file-descriptors-ratio"
    26  	limitsOverridePrefix       = "limits-override"
    27  	systemScope                = "system"
    28  	transientScope             = "transient"
    29  	protocolScope              = "protocol"
    30  	peerScope                  = "peer"
    31  	peerProtocolScope          = "peer-protocol"
    32  	inboundStreamLimit         = "streams-inbound"
    33  	outboundStreamLimit        = "streams-outbound"
    34  	inboundConnectionLimit     = "connections-inbound"
    35  	outboundConnectionLimit    = "connections-outbound"
    36  	fileDescriptorsLimit       = "fd"
    37  	memoryLimitBytes           = "memory-bytes"
    38  
    39  	alspDisabled                       = "alsp-disable-penalty"
    40  	alspSpamRecordCacheSize            = "alsp-spam-record-cache-size"
    41  	alspSpamRecordQueueSize            = "alsp-spam-report-queue-size"
    42  	alspHearBeatInterval               = "alsp-heart-beat-interval"
    43  	alspSyncEngineBatchRequestBaseProb = "alsp-sync-engine-batch-request-base-prob"
    44  	alspSyncEngineRangeRequestBaseProb = "alsp-sync-engine-range-request-base-prob"
    45  	alspSyncEngineSyncRequestProb      = "alsp-sync-engine-sync-request-prob"
    46  )
    47  
    48  func AllFlagNames() []string {
    49  	allFlags := []string{
    50  		networkingConnectionPruning,
    51  		preferredUnicastsProtocols,
    52  		receivedMessageCacheSize,
    53  		peerUpdateInterval,
    54  		BuildFlagName(unicastKey, MessageTimeoutKey),
    55  		BuildFlagName(unicastKey, unicastManagerKey, createStreamBackoffDelayKey),
    56  		BuildFlagName(unicastKey, unicastManagerKey, streamZeroRetryResetThresholdKey),
    57  		BuildFlagName(unicastKey, unicastManagerKey, maxStreamCreationRetryAttemptTimesKey),
    58  		BuildFlagName(unicastKey, unicastManagerKey, configCacheSizeKey),
    59  		dnsCacheTTL,
    60  		disallowListNotificationCacheSize,
    61  		BuildFlagName(unicastKey, rateLimiterKey, messageRateLimitKey),
    62  		BuildFlagName(unicastKey, rateLimiterKey, BandwidthRateLimitKey),
    63  		BuildFlagName(unicastKey, rateLimiterKey, BandwidthBurstLimitKey),
    64  		BuildFlagName(unicastKey, rateLimiterKey, LockoutDurationKey),
    65  		BuildFlagName(unicastKey, rateLimiterKey, DryRunKey),
    66  		BuildFlagName(unicastKey, enableStreamProtectionKey),
    67  		BuildFlagName(rootResourceManagerPrefix, memoryLimitRatioPrefix),
    68  		BuildFlagName(rootResourceManagerPrefix, fileDescriptorsRatioPrefix),
    69  		BuildFlagName(connectionManagerKey, highWatermarkKey),
    70  		BuildFlagName(connectionManagerKey, lowWatermarkKey),
    71  		BuildFlagName(connectionManagerKey, silencePeriodKey),
    72  		BuildFlagName(connectionManagerKey, gracePeriodKey),
    73  		alspDisabled,
    74  		alspSpamRecordCacheSize,
    75  		alspSpamRecordQueueSize,
    76  		alspHearBeatInterval,
    77  		alspSyncEngineBatchRequestBaseProb,
    78  		alspSyncEngineRangeRequestBaseProb,
    79  		alspSyncEngineSyncRequestProb,
    80  
    81  		BuildFlagName(gossipsubKey, p2pconfig.PeerScoringEnabledKey),
    82  		BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.LocalMeshLogIntervalKey),
    83  		BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.ScoreTracerIntervalKey),
    84  		BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.RPCSentTrackerCacheSizeKey),
    85  		BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.RPCSentTrackerQueueCacheSizeKey),
    86  		BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.RPCSentTrackerNumOfWorkersKey),
    87  
    88  		BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.DuplicateMessageCacheTrackerKey, p2pconfig.DuplicateMessageCacheTrackerSizeKey),
    89  		BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.DuplicateMessageCacheTrackerKey, p2pconfig.DuplicateMessageCacheTrackerDecayKey),
    90  		BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.DuplicateMessageCacheTrackerKey, p2pconfig.SkipDecayThresholdKey),
    91  
    92  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.InspectionQueueConfigKey, p2pconfig.NumberOfWorkersKey),
    93  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.InspectionQueueConfigKey, p2pconfig.QueueSizeKey),
    94  
    95  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ClusterPrefixedMessageConfigKey, p2pconfig.TrackerCacheSizeKey),
    96  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ClusterPrefixedMessageConfigKey, p2pconfig.TrackerCacheDecayKey),
    97  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ClusterPrefixedMessageConfigKey, p2pconfig.HardThresholdKey),
    98  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.NotificationCacheSizeKey),
    99  
   100  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.DisabledKey),
   101  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.EnableKey, p2pconfig.GraftKey),
   102  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.EnableKey, p2pconfig.PruneKey),
   103  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.EnableKey, p2pconfig.IHaveKey),
   104  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.EnableKey, p2pconfig.IWantKey),
   105  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.EnableKey, p2pconfig.PublishKey),
   106  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.RejectUnstakedPeers),
   107  
   108  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.TruncationKey, p2pconfig.DisabledKey),
   109  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.TruncationKey, p2pconfig.EnableKey, p2pconfig.GraftKey),
   110  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.TruncationKey, p2pconfig.EnableKey, p2pconfig.PruneKey),
   111  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.TruncationKey, p2pconfig.EnableKey, p2pconfig.IHaveKey),
   112  		BuildFlagName(gossipsubKey,
   113  			p2pconfig.RpcInspectorKey,
   114  			p2pconfig.ValidationConfigKey,
   115  			p2pconfig.ProcessKey,
   116  			p2pconfig.TruncationKey,
   117  			p2pconfig.EnableKey,
   118  			p2pconfig.IHaveKey,
   119  			p2pconfig.MessageIDKey),
   120  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.TruncationKey, p2pconfig.EnableKey, p2pconfig.IWantConfigKey),
   121  		BuildFlagName(gossipsubKey,
   122  			p2pconfig.RpcInspectorKey,
   123  			p2pconfig.ValidationConfigKey,
   124  			p2pconfig.ProcessKey,
   125  			p2pconfig.TruncationKey,
   126  			p2pconfig.EnableKey,
   127  			p2pconfig.IWantKey,
   128  			p2pconfig.MessageIDKey),
   129  
   130  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IHaveConfigKey, p2pconfig.MessageCountThreshold),
   131  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IHaveConfigKey, p2pconfig.MessageIdCountThreshold),
   132  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IHaveConfigKey, p2pconfig.DuplicateTopicIdThresholdKey),
   133  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IHaveConfigKey, p2pconfig.DuplicateMessageIdThresholdKey),
   134  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IHaveConfigKey, p2pconfig.InvalidTopicIdThresholdKey),
   135  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.GraftPruneKey, p2pconfig.DuplicateTopicIdThresholdKey),
   136  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.GraftPruneKey, p2pconfig.InvalidTopicIdThresholdKey),
   137  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.GraftPruneKey, p2pconfig.MessageCountThreshold),
   138  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IWantConfigKey, p2pconfig.MessageCountThreshold),
   139  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IWantConfigKey, p2pconfig.MessageIdCountThreshold),
   140  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IWantConfigKey, p2pconfig.CacheMissThresholdKey),
   141  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IWantConfigKey, p2pconfig.DuplicateMsgIDThresholdKey),
   142  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.PublishMessagesConfigKey, p2pconfig.MaxSampleSizeKey),
   143  		BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.PublishMessagesConfigKey, p2pconfig.MessageErrorThresholdKey),
   144  		BuildFlagName(gossipsubKey, p2pconfig.SubscriptionProviderKey, p2pconfig.UpdateIntervalKey),
   145  		BuildFlagName(gossipsubKey, p2pconfig.SubscriptionProviderKey, p2pconfig.CacheSizeKey),
   146  
   147  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.AppSpecificScoreWeightKey),
   148  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.DecayIntervalKey),
   149  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.DecayToZeroKey),
   150  
   151  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.SkipAtomicValidationKey),
   152  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.InvalidMessageDeliveriesWeightKey),
   153  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.InvalidMessageDeliveriesDecayKey),
   154  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.TimeInMeshQuantumKey),
   155  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.TopicWeightKey),
   156  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshMessageDeliveriesDecayKey),
   157  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshMessageDeliveriesCapKey),
   158  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshMessageDeliveryThresholdKey),
   159  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshDeliveriesWeightKey),
   160  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshMessageDeliveriesWindowKey),
   161  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshMessageDeliveryActivationKey),
   162  
   163  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.ThresholdsKey, p2pconfig.GossipThresholdKey),
   164  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.ThresholdsKey, p2pconfig.PublishKey),
   165  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.ThresholdsKey, p2pconfig.GraylistThresholdKey),
   166  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.ThresholdsKey, p2pconfig.AcceptPXThresholdKey),
   167  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.ThresholdsKey, p2pconfig.OpportunisticGraftThresholdKey),
   168  
   169  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.BehaviourKey, p2pconfig.BehaviourPenaltyThresholdKey),
   170  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.BehaviourKey, p2pconfig.BehaviourPenaltyWeightKey),
   171  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.BehaviourKey, p2pconfig.BehaviourPenaltyDecayKey),
   172  
   173  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.MaxDebugLogsKey),
   174  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.MaxAppSpecificKey, p2pconfig.PenaltyKey),
   175  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.MinAppSpecificKey, p2pconfig.PenaltyKey),
   176  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.UnknownIdentityKey, p2pconfig.PenaltyKey),
   177  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.InvalidSubscriptionKey, p2pconfig.PenaltyKey),
   178  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.DuplicateMessageKey, p2pconfig.PenaltyKey),
   179  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.DuplicateMessageKey, p2pconfig.ThresholdKey),
   180  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.MaxAppSpecificKey, p2pconfig.RewardKey),
   181  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.StakedIdentityKey, p2pconfig.RewardKey),
   182  
   183  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.StartupSilenceDurationKey),
   184  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.AppSpecificScoreRegistryKey, p2pconfig.ScoreUpdateWorkerNumKey),
   185  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.AppSpecificScoreRegistryKey, p2pconfig.ScoreUpdateRequestQueueSizeKey),
   186  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.AppSpecificScoreRegistryKey, p2pconfig.InvalidControlMessageNotificationQueueSizeKey),
   187  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.AppSpecificScoreRegistryKey, p2pconfig.ScoreTTLKey),
   188  
   189  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.CacheSizeKey),
   190  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.PenaltyDecaySlowdownThresholdKey),
   191  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.DecayRateReductionFactorKey),
   192  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.PenaltyDecayEvaluationPeriodKey),
   193  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.MinimumSpamPenaltyDecayFactorKey),
   194  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.MaximumSpamPenaltyDecayFactorKey),
   195  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.SkipDecayThresholdKey),
   196  
   197  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.GraftKey),
   198  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.PruneKey),
   199  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.IHaveKey),
   200  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.IWantKey),
   201  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.PublishKey),
   202  		BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.ClusterPrefixedReductionFactorKey),
   203  	}
   204  
   205  	for _, scope := range []string{systemScope, transientScope, protocolScope, peerScope, peerProtocolScope} {
   206  		for _, resource := range []string{inboundStreamLimit,
   207  			outboundStreamLimit,
   208  			inboundConnectionLimit,
   209  			outboundConnectionLimit,
   210  			fileDescriptorsLimit,
   211  			memoryLimitBytes} {
   212  			allFlags = append(allFlags, fmt.Sprintf("%s-%s-%s-%s", rootResourceManagerPrefix, limitsOverridePrefix, scope, resource))
   213  		}
   214  	}
   215  
   216  	return allFlags
   217  }
   218  
   219  // InitializeNetworkFlags initializes all CLI flags for the Flow network configuration on the provided pflag set.
   220  // Args:
   221  //
   222  //	*pflag.FlagSet: the pflag set of the Flow node.
   223  //	*Config: the default network config used to set default values on the flags
   224  func InitializeNetworkFlags(flags *pflag.FlagSet, config *Config) {
   225  	flags.Bool(networkingConnectionPruning, config.NetworkConnectionPruning, "enabling connection trimming")
   226  	flags.Duration(dnsCacheTTL, config.DNSCacheTTL, "time-to-live for dns cache")
   227  	flags.StringSlice(
   228  		preferredUnicastsProtocols, config.PreferredUnicastProtocols, "preferred unicast protocols in ascending order of preference")
   229  	flags.Uint32(receivedMessageCacheSize, config.NetworkReceivedMessageCacheSize, "incoming message cache size at networking layer")
   230  	flags.Uint32(
   231  		disallowListNotificationCacheSize,
   232  		config.DisallowListNotificationCacheSize,
   233  		"cache size for notification events from disallow list")
   234  	flags.Duration(peerUpdateInterval, config.PeerUpdateInterval, "how often to refresh the peer connections for the node")
   235  	flags.Duration(BuildFlagName(unicastKey, MessageTimeoutKey), config.Unicast.MessageTimeout, "how long a unicast transmission can take to complete")
   236  	flags.Duration(BuildFlagName(unicastKey, unicastManagerKey, createStreamBackoffDelayKey), config.Unicast.UnicastManager.CreateStreamBackoffDelay,
   237  		"initial backoff delay between failing to establish a connection with another node and retrying, "+
   238  			"this delay increases exponentially with the number of subsequent failures to establish a connection.")
   239  	flags.Uint64(BuildFlagName(unicastKey, unicastManagerKey, streamZeroRetryResetThresholdKey), config.Unicast.UnicastManager.StreamZeroRetryResetThreshold,
   240  		"reset stream creation retry budget from zero to the maximum after consecutive successful streams reach this threshold.")
   241  	flags.Uint64(BuildFlagName(unicastKey, unicastManagerKey, maxStreamCreationRetryAttemptTimesKey),
   242  		config.Unicast.UnicastManager.MaxStreamCreationRetryAttemptTimes,
   243  		"max attempts to create a unicast stream.")
   244  	flags.Uint32(BuildFlagName(unicastKey, unicastManagerKey, configCacheSizeKey), config.Unicast.UnicastManager.ConfigCacheSize,
   245  		"cache size of the dial config cache, recommended to be big enough to accommodate the entire nodes in the network.")
   246  
   247  	// unicast stream handler rate limits
   248  	flags.Int(BuildFlagName(unicastKey, rateLimiterKey, messageRateLimitKey), config.Unicast.RateLimiter.MessageRateLimit, "maximum number of unicast messages that a peer can send per second")
   249  	flags.Int(BuildFlagName(unicastKey, rateLimiterKey, BandwidthRateLimitKey), config.Unicast.RateLimiter.BandwidthRateLimit,
   250  		"bandwidth size in bytes a peer is allowed to send via unicast streams per second")
   251  	flags.Int(BuildFlagName(unicastKey, rateLimiterKey, BandwidthBurstLimitKey), config.Unicast.RateLimiter.BandwidthBurstLimit, "bandwidth size in bytes a peer is allowed to send at one time")
   252  	flags.Duration(BuildFlagName(unicastKey, rateLimiterKey, LockoutDurationKey), config.Unicast.RateLimiter.LockoutDuration,
   253  		"the number of seconds a peer will be forced to wait before being allowed to successful reconnect to the node after being rate limited")
   254  	flags.Bool(BuildFlagName(unicastKey, rateLimiterKey, DryRunKey), config.Unicast.RateLimiter.DryRun, "disable peer disconnects and connections gating when rate limiting peers")
   255  	flags.Bool(BuildFlagName(unicastKey, enableStreamProtectionKey),
   256  		config.Unicast.EnableStreamProtection,
   257  		"enable stream protection for unicast streams, when enabled, all connections that are being established or have been already established for unicast streams are protected")
   258  
   259  	LoadLibP2PResourceManagerFlags(flags, config)
   260  
   261  	flags.Int(BuildFlagName(connectionManagerKey, lowWatermarkKey), config.ConnectionManager.LowWatermark, "low watermarking for libp2p connection manager")
   262  	flags.Int(BuildFlagName(connectionManagerKey, highWatermarkKey), config.ConnectionManager.HighWatermark, "high watermarking for libp2p connection manager")
   263  	flags.Duration(BuildFlagName(connectionManagerKey, gracePeriodKey), config.ConnectionManager.GracePeriod, "grace period for libp2p connection manager")
   264  	flags.Duration(BuildFlagName(connectionManagerKey, silencePeriodKey), config.ConnectionManager.SilencePeriod, "silence period for libp2p connection manager")
   265  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.PeerScoringEnabledKey), config.GossipSub.PeerScoringEnabled, "enabling peer scoring on pubsub network")
   266  	flags.Duration(BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.LocalMeshLogIntervalKey),
   267  		config.GossipSub.RpcTracer.LocalMeshLogInterval,
   268  		"logging interval for local mesh in gossipsub tracer")
   269  	flags.Duration(BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.ScoreTracerIntervalKey), config.GossipSub.RpcTracer.ScoreTracerInterval,
   270  		"logging interval for peer score tracer in gossipsub, set to 0 to disable")
   271  	flags.Uint32(BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.RPCSentTrackerCacheSizeKey), config.GossipSub.RpcTracer.RPCSentTrackerCacheSize,
   272  		"cache size of the rpc sent tracker used by the gossipsub mesh tracer.")
   273  	flags.Uint32(BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.RPCSentTrackerQueueCacheSizeKey), config.GossipSub.RpcTracer.RPCSentTrackerQueueCacheSize,
   274  		"cache size of the rpc sent tracker worker queue.")
   275  
   276  	flags.Uint32(BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.DuplicateMessageCacheTrackerKey, p2pconfig.DuplicateMessageCacheTrackerSizeKey),
   277  		config.GossipSub.RpcTracer.DuplicateMessageTrackerConfig.CacheSize,
   278  		"cache size of the gossipsub duplicate message tracker.")
   279  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.DuplicateMessageCacheTrackerKey, p2pconfig.DuplicateMessageCacheTrackerDecayKey),
   280  		config.GossipSub.RpcTracer.DuplicateMessageTrackerConfig.Decay,
   281  		"decay rate for the peer duplicate message counters.")
   282  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.DuplicateMessageCacheTrackerKey, p2pconfig.SkipDecayThresholdKey),
   283  		config.GossipSub.RpcTracer.DuplicateMessageTrackerConfig.SkipDecayThreshold,
   284  		"the duplicate message count threshold below which the penalty will not be decayed")
   285  
   286  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcTracerKey, p2pconfig.RPCSentTrackerNumOfWorkersKey), config.GossipSub.RpcTracer.RpcSentTrackerNumOfWorkers,
   287  		"number of workers for the rpc sent tracker worker pool.")
   288  	// gossipsub RPC control message validation limits used for validation configuration and rate limiting
   289  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.InspectionQueueConfigKey, p2pconfig.NumberOfWorkersKey),
   290  		config.GossipSub.RpcInspector.Validation.InspectionQueue.NumberOfWorkers,
   291  		"number of gossipsub RPC control message validation inspector component workers")
   292  	flags.Uint32(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.InspectionQueueConfigKey, p2pconfig.QueueSizeKey),
   293  		config.GossipSub.RpcInspector.Validation.InspectionQueue.Size,
   294  		"queue size for gossipsub RPC validation inspector events worker pool queue.")
   295  	flags.Uint32(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ClusterPrefixedMessageConfigKey, p2pconfig.TrackerCacheSizeKey),
   296  		config.GossipSub.RpcInspector.Validation.ClusterPrefixedMessage.ControlMsgsReceivedCacheSize,
   297  		"cache size for gossipsub RPC validation inspector cluster prefix received tracker.")
   298  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ClusterPrefixedMessageConfigKey, p2pconfig.TrackerCacheDecayKey),
   299  		config.GossipSub.RpcInspector.Validation.ClusterPrefixedMessage.ControlMsgsReceivedCacheDecay,
   300  		"the decay value used to decay cluster prefix received topics received cached counters.")
   301  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ClusterPrefixedMessageConfigKey, p2pconfig.HardThresholdKey),
   302  		config.GossipSub.RpcInspector.Validation.ClusterPrefixedMessage.HardThreshold,
   303  		"the maximum number of cluster-prefixed control messages allowed to be processed when the active cluster id is unset or a mismatch is detected, exceeding this threshold will result in node penalization by gossipsub.")
   304  	// networking event notifications
   305  	flags.Uint32(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.NotificationCacheSizeKey), config.GossipSub.RpcInspector.NotificationCacheSize,
   306  		"cache size for notification events from gossipsub rpc inspector")
   307  	// application layer spam prevention (alsp) protocol
   308  	flags.Bool(alspDisabled, config.AlspConfig.DisablePenalty, "disable the penalty mechanism of the alsp protocol. default value (recommended) is false")
   309  	flags.Uint32(alspSpamRecordCacheSize, config.AlspConfig.SpamRecordCacheSize, "size of spam record cache, recommended to be 10x the number of authorized nodes")
   310  	flags.Uint32(alspSpamRecordQueueSize, config.AlspConfig.SpamReportQueueSize, "size of spam report queue, recommended to be 100x the number of authorized nodes")
   311  	flags.Duration(alspHearBeatInterval,
   312  		config.AlspConfig.HearBeatInterval,
   313  		"interval between two consecutive heartbeat events at alsp, recommended to leave it as default unless you know what you are doing.")
   314  	flags.Float32(alspSyncEngineBatchRequestBaseProb,
   315  		config.AlspConfig.SyncEngine.BatchRequestBaseProb,
   316  		"base probability of creating a misbehavior report for a batch request message")
   317  	flags.Float32(alspSyncEngineRangeRequestBaseProb,
   318  		config.AlspConfig.SyncEngine.RangeRequestBaseProb,
   319  		"base probability of creating a misbehavior report for a range request message")
   320  	flags.Float32(alspSyncEngineSyncRequestProb, config.AlspConfig.SyncEngine.SyncRequestProb, "probability of creating a misbehavior report for a sync request message")
   321  
   322  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.DisabledKey),
   323  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Inspect.Disabled,
   324  		"disable rpc inspection for all control message types")
   325  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.EnableKey, p2pconfig.GraftKey),
   326  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Inspect.EnableGraft,
   327  		"disable graft control message inspection")
   328  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.EnableKey, p2pconfig.PruneKey),
   329  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Inspect.EnablePrune,
   330  		"disable prune control message inspection")
   331  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.EnableKey, p2pconfig.IHaveKey),
   332  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Inspect.EnableIHave,
   333  		"disable ihave control message inspection")
   334  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.EnableKey, p2pconfig.IWantKey),
   335  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Inspect.EnableIWant,
   336  		"disable iwant control message inspection")
   337  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.EnableKey, p2pconfig.PublishKey),
   338  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Inspect.EnablePublish,
   339  		"disable rpc publish message inspection")
   340  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.InspectionKey, p2pconfig.RejectUnstakedPeers),
   341  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Inspect.RejectUnstakedPeers,
   342  		"reject rpcs from unstaked peers")
   343  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.TruncationKey, p2pconfig.DisabledKey),
   344  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Truncate.Disabled,
   345  		"disable rpc truncation for all control message types")
   346  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.TruncationKey, p2pconfig.EnableKey, p2pconfig.GraftKey),
   347  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Truncate.EnableGraft,
   348  		"disable graft control message truncation")
   349  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.TruncationKey, p2pconfig.EnableKey, p2pconfig.PruneKey),
   350  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Truncate.EnablePrune,
   351  		"disable prune control message truncation")
   352  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.TruncationKey, p2pconfig.EnableKey, p2pconfig.IHaveKey),
   353  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Truncate.EnableIHave,
   354  		"disable ihave control message truncation")
   355  	flags.Bool(BuildFlagName(gossipsubKey,
   356  		p2pconfig.RpcInspectorKey,
   357  		p2pconfig.ValidationConfigKey,
   358  		p2pconfig.ProcessKey,
   359  		p2pconfig.TruncationKey,
   360  		p2pconfig.EnableKey,
   361  		p2pconfig.IHaveKey,
   362  		p2pconfig.MessageIDKey),
   363  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Truncate.EnableIHaveMessageIds,
   364  		"disable ihave message id truncation")
   365  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.ProcessKey, p2pconfig.TruncationKey, p2pconfig.EnableKey, p2pconfig.IWantKey),
   366  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Truncate.EnableIWant,
   367  		"disable iwant control message truncation")
   368  	flags.Bool(BuildFlagName(gossipsubKey,
   369  		p2pconfig.RpcInspectorKey,
   370  		p2pconfig.ValidationConfigKey,
   371  		p2pconfig.ProcessKey,
   372  		p2pconfig.TruncationKey,
   373  		p2pconfig.EnableKey,
   374  		p2pconfig.IWantKey,
   375  		p2pconfig.MessageIDKey),
   376  		config.GossipSub.RpcInspector.Validation.InspectionProcess.Truncate.EnableIWantMessageIds,
   377  		"disable iwant message id truncation")
   378  
   379  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IHaveConfigKey, p2pconfig.MessageCountThreshold),
   380  		config.GossipSub.RpcInspector.Validation.IHave.MessageCountThreshold,
   381  		"threshold for the number of ihave control messages to accept on a single RPC message, if exceeded the RPC message will be sampled and truncated")
   382  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IHaveConfigKey, p2pconfig.MessageIdCountThreshold),
   383  		config.GossipSub.RpcInspector.Validation.IHave.MessageIdCountThreshold,
   384  		"threshold for the number of message ids on a single ihave control message to accept, if exceeded the RPC message ids will be sampled and truncated")
   385  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IHaveConfigKey, p2pconfig.DuplicateTopicIdThresholdKey),
   386  		config.GossipSub.RpcInspector.Validation.IHave.DuplicateTopicIdThreshold,
   387  		"the max allowed duplicate topic IDs across all ihave control messages in a single RPC message, if exceeded a misbehavior report will be created")
   388  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IHaveConfigKey, p2pconfig.DuplicateMessageIdThresholdKey),
   389  		config.GossipSub.RpcInspector.Validation.IHave.DuplicateMessageIdThreshold,
   390  		"the max allowed duplicate message IDs in a single ihave control message, if exceeded a misbehavior report will be created")
   391  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IHaveConfigKey, p2pconfig.InvalidTopicIdThresholdKey),
   392  		config.GossipSub.RpcInspector.Validation.IHave.InvalidTopicIdThreshold,
   393  		"the max allowed invalid topics in a single ihave control message, if exceeded a misbehavior report will be created",
   394  	)
   395  
   396  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.GraftPruneKey, p2pconfig.MessageCountThreshold),
   397  		config.GossipSub.RpcInspector.Validation.GraftPrune.MessageCountThreshold,
   398  		"threshold for the number of graft or prune control messages to accept on a single RPC message, if exceeded the RPC message will be sampled and truncated")
   399  	flags.Uint(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IWantConfigKey, p2pconfig.MessageCountThreshold),
   400  		config.GossipSub.RpcInspector.Validation.IWant.MessageCountThreshold,
   401  		"threshold for the number of iwant control messages to accept on a single RPC message, if exceeded the RPC message will be sampled and truncated")
   402  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IWantConfigKey, p2pconfig.MessageIdCountThreshold),
   403  		config.GossipSub.RpcInspector.Validation.IWant.MessageIdCountThreshold,
   404  		"threshold for the number of message ids on a single iwant control message to accept, if exceeded the RPC message ids will be sampled and truncated")
   405  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IWantConfigKey, p2pconfig.CacheMissThresholdKey),
   406  		config.GossipSub.RpcInspector.Validation.IWant.CacheMissThreshold,
   407  		"max number of cache misses (untracked) allowed in a single iWant control message, if exceeded a misbehavior report will be created")
   408  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.IWantConfigKey, p2pconfig.DuplicateMsgIDThresholdKey),
   409  		config.GossipSub.RpcInspector.Validation.IWant.DuplicateMsgIdThreshold,
   410  		"max allowed duplicate message IDs in a single iWant control message, if exceeded a misbehavior report will be created")
   411  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.PublishMessagesConfigKey, p2pconfig.MaxSampleSizeKey),
   412  		config.GossipSub.RpcInspector.Validation.PublishMessages.MaxSampleSize,
   413  		"the max sample size for async validation of publish messages, if exceeded the message will be sampled for inspection, but is not truncated")
   414  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.PublishMessagesConfigKey, p2pconfig.MessageErrorThresholdKey),
   415  		config.GossipSub.RpcInspector.Validation.PublishMessages.ErrorThreshold,
   416  		"the max number of errors allowed in a (sampled) set of publish messages on a single rpc, if exceeded a misbehavior report will be created")
   417  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.GraftPruneKey, p2pconfig.DuplicateTopicIdThresholdKey),
   418  		config.GossipSub.RpcInspector.Validation.GraftPrune.DuplicateTopicIdThreshold,
   419  		"the max allowed duplicate topic IDs across all graft or prune control messages in a single RPC message, if exceeded a misbehavior report will be created")
   420  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.RpcInspectorKey, p2pconfig.ValidationConfigKey, p2pconfig.GraftPruneKey, p2pconfig.InvalidTopicIdThresholdKey),
   421  		config.GossipSub.RpcInspector.Validation.GraftPrune.InvalidTopicIdThreshold,
   422  		"the max allowed invalid topic across all graft or prune control messages in a single RPC message, if exceeded a misbehavior report will be created")
   423  
   424  	flags.Duration(BuildFlagName(gossipsubKey, p2pconfig.SubscriptionProviderKey, p2pconfig.UpdateIntervalKey),
   425  		config.GossipSub.SubscriptionProvider.UpdateInterval,
   426  		"interval for updating the list of subscribed topics for all peers in the gossipsub, recommended value is a few minutes")
   427  	flags.Uint32(BuildFlagName(gossipsubKey, p2pconfig.SubscriptionProviderKey, p2pconfig.CacheSizeKey),
   428  		config.GossipSub.SubscriptionProvider.CacheSize,
   429  		"size of the cache that keeps the list of topics each peer has subscribed to, recommended size is 10x the number of authorized nodes")
   430  
   431  	flags.Duration(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.DecayIntervalKey),
   432  		config.GossipSub.ScoringParameters.PeerScoring.Internal.DecayInterval,
   433  		"interval at which the counters associated with a peer behavior in GossipSub system are decayed, recommended value is one minute")
   434  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.AppSpecificScoreWeightKey),
   435  		config.GossipSub.ScoringParameters.PeerScoring.Internal.AppSpecificScoreWeight,
   436  		"the  weight for app-specific scores")
   437  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.DecayToZeroKey),
   438  		config.GossipSub.ScoringParameters.PeerScoring.Internal.DecayToZero,
   439  		"the maximum value below which a peer scoring counter is reset to zero")
   440  
   441  	flags.Bool(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.SkipAtomicValidationKey),
   442  		config.GossipSub.ScoringParameters.PeerScoring.Internal.TopicParameters.SkipAtomicValidation,
   443  		"the default value for the skip atomic validation flag for topics")
   444  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.InvalidMessageDeliveriesWeightKey),
   445  		config.GossipSub.ScoringParameters.PeerScoring.Internal.TopicParameters.InvalidMessageDeliveriesWeight,
   446  		"this value is applied to the square of the number of invalid message deliveries on a topic")
   447  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.InvalidMessageDeliveriesDecayKey),
   448  		config.GossipSub.ScoringParameters.PeerScoring.Internal.TopicParameters.InvalidMessageDeliveriesDecay,
   449  		"the decay factor used to decay the number of invalid message deliveries")
   450  	flags.Duration(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.TimeInMeshQuantumKey),
   451  		config.GossipSub.ScoringParameters.PeerScoring.Internal.TopicParameters.TimeInMeshQuantum,
   452  		"the time in mesh quantum for the GossipSub scoring system")
   453  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.TopicWeightKey),
   454  		config.GossipSub.ScoringParameters.PeerScoring.Internal.TopicParameters.TopicWeight,
   455  		"the weight of a topic in the GossipSub scoring system")
   456  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshMessageDeliveriesDecayKey),
   457  		config.GossipSub.ScoringParameters.PeerScoring.Internal.TopicParameters.MeshMessageDeliveriesDecay,
   458  		"this is applied to the number of actual message deliveries in a topic mesh at each decay interval (i.e., DecayInterval)")
   459  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshMessageDeliveriesCapKey),
   460  		config.GossipSub.ScoringParameters.PeerScoring.Internal.TopicParameters.MeshMessageDeliveriesCap,
   461  		"The maximum number of actual message deliveries in a topic mesh that is used to calculate the score of a peer in that topic mesh")
   462  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshMessageDeliveryThresholdKey),
   463  		config.GossipSub.ScoringParameters.PeerScoring.Internal.TopicParameters.MeshMessageDeliveryThreshold,
   464  		"The threshold for the number of actual message deliveries in a topic mesh that is used to calculate the score of a peer in that topic mesh")
   465  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshDeliveriesWeightKey),
   466  		config.GossipSub.ScoringParameters.PeerScoring.Internal.TopicParameters.MeshDeliveriesWeight,
   467  		"the weight for applying penalty when a peer is under-performing in a topic mesh")
   468  	flags.Duration(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshMessageDeliveriesWindowKey),
   469  		config.GossipSub.ScoringParameters.PeerScoring.Internal.TopicParameters.MeshMessageDeliveriesWindow,
   470  		"the window size is time interval that we count a delivery of an already seen message towards the score of a peer in a topic mesh. The delivery is counted by GossipSub only if the previous sender of the message is different from the current sender")
   471  	flags.Duration(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.TopicKey, p2pconfig.MeshMessageDeliveryActivationKey),
   472  		config.GossipSub.ScoringParameters.PeerScoring.Internal.TopicParameters.MeshMessageDeliveryActivation,
   473  		"the time interval that we wait for a new peer that joins a topic mesh till start counting the number of actual message deliveries of that peer in that topic mesh")
   474  
   475  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.ThresholdsKey, p2pconfig.GossipThresholdKey),
   476  		config.GossipSub.ScoringParameters.PeerScoring.Internal.Thresholds.Gossip,
   477  		"the threshold when a peer's penalty drops below this threshold, no gossip is emitted towards that peer and gossip from that peer is ignored")
   478  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.ThresholdsKey, p2pconfig.PublishKey),
   479  		config.GossipSub.ScoringParameters.PeerScoring.Internal.Thresholds.Publish,
   480  		"the threshold when a peer's penalty drops below this threshold, self-published messages are not propagated towards this peer")
   481  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.ThresholdsKey, p2pconfig.GraylistThresholdKey),
   482  		config.GossipSub.ScoringParameters.PeerScoring.Internal.Thresholds.Graylist,
   483  		"the threshold when a peer's penalty drops below this threshold, the peer is graylisted, i.e., incoming RPCs from the peer are ignored")
   484  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.ThresholdsKey, p2pconfig.AcceptPXThresholdKey),
   485  		config.GossipSub.ScoringParameters.PeerScoring.Internal.Thresholds.AcceptPX,
   486  		"the threshold when a peer sends us PX information with a prune, we only accept it and connect to the supplied peers if the originating peer's penalty exceeds this threshold")
   487  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.ThresholdsKey, p2pconfig.OpportunisticGraftThresholdKey),
   488  		config.GossipSub.ScoringParameters.PeerScoring.Internal.Thresholds.OpportunisticGraft,
   489  		"the threshold when the median peer penalty in the mesh drops below this value, the peer may select more peers with penalty above the median to opportunistically graft on the mesh")
   490  
   491  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.BehaviourKey, p2pconfig.BehaviourPenaltyThresholdKey),
   492  		config.GossipSub.ScoringParameters.PeerScoring.Internal.Behaviour.PenaltyThreshold,
   493  		"the threshold when the behavior of a peer is considered as bad by GossipSub")
   494  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.BehaviourKey, p2pconfig.BehaviourPenaltyWeightKey),
   495  		config.GossipSub.ScoringParameters.PeerScoring.Internal.Behaviour.PenaltyWeight,
   496  		"the weight for applying penalty when a peer misbehavior goes beyond the threshold")
   497  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.InternalKey, p2pconfig.BehaviourKey, p2pconfig.BehaviourPenaltyDecayKey),
   498  		config.GossipSub.ScoringParameters.PeerScoring.Internal.Behaviour.PenaltyDecay,
   499  		"the decay interval for the misbehavior counter of a peer. The misbehavior counter is incremented by GossipSub for iHave broken promises or the GRAFT flooding attacks (i.e., each GRAFT received from a remote peer while that peer is on a PRUNE backoff)")
   500  
   501  	flags.Uint32(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.MaxDebugLogsKey),
   502  		config.GossipSub.ScoringParameters.PeerScoring.Protocol.MaxDebugLogs,
   503  		"the max number of debug/trace log events per second. Logs emitted above this threshold are dropped")
   504  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.MaxAppSpecificKey, p2pconfig.PenaltyKey),
   505  		config.GossipSub.ScoringParameters.PeerScoring.Protocol.AppSpecificScore.MaxAppSpecificPenalty,
   506  		"the maximum penalty for sever offenses that we apply to a remote node score")
   507  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.MinAppSpecificKey, p2pconfig.PenaltyKey),
   508  		config.GossipSub.ScoringParameters.PeerScoring.Protocol.AppSpecificScore.MinAppSpecificPenalty,
   509  		"the minimum penalty for sever offenses that we apply to a remote node score")
   510  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.UnknownIdentityKey, p2pconfig.PenaltyKey),
   511  		config.GossipSub.ScoringParameters.PeerScoring.Protocol.AppSpecificScore.UnknownIdentityPenalty,
   512  		"the  penalty for unknown identity. It is applied to the peer's score when the peer is not in the identity list")
   513  	flags.Float64(BuildFlagName(gossipsubKey,
   514  		p2pconfig.ScoreParamsKey,
   515  		p2pconfig.PeerScoringKey,
   516  		p2pconfig.ProtocolKey,
   517  		p2pconfig.AppSpecificKey,
   518  		p2pconfig.InvalidSubscriptionKey,
   519  		p2pconfig.PenaltyKey),
   520  		config.GossipSub.ScoringParameters.PeerScoring.Protocol.AppSpecificScore.InvalidSubscriptionPenalty,
   521  		"the  penalty for invalid subscription. It is applied to the peer's score when the peer subscribes to a topic that it is not authorized to subscribe to")
   522  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.DuplicateMessageKey, p2pconfig.PenaltyKey),
   523  		config.GossipSub.ScoringParameters.PeerScoring.Protocol.AppSpecificScore.DuplicateMessagePenalty,
   524  		"the penalty for duplicate messages detected by the gossipsub tracer for a peer")
   525  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.MaxAppSpecificKey, p2pconfig.RewardKey),
   526  		config.GossipSub.ScoringParameters.PeerScoring.Protocol.AppSpecificScore.MaxAppSpecificReward,
   527  		"the reward for well-behaving staked peers")
   528  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.PeerScoringKey, p2pconfig.ProtocolKey, p2pconfig.AppSpecificKey, p2pconfig.StakedIdentityKey, p2pconfig.RewardKey),
   529  		config.GossipSub.ScoringParameters.PeerScoring.Protocol.AppSpecificScore.StakedIdentityReward,
   530  		"the reward for staking peers")
   531  	flags.Float64(BuildFlagName(gossipsubKey,
   532  		p2pconfig.ScoreParamsKey,
   533  		p2pconfig.PeerScoringKey,
   534  		p2pconfig.ProtocolKey,
   535  		p2pconfig.AppSpecificKey,
   536  		p2pconfig.DuplicateMessageKey,
   537  		p2pconfig.ThresholdKey),
   538  		config.GossipSub.ScoringParameters.PeerScoring.Protocol.AppSpecificScore.DuplicateMessageThreshold,
   539  		"the peer's duplicate message count threshold above which the peer will be penalized")
   540  
   541  	flags.Duration(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.StartupSilenceDurationKey),
   542  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.StartupSilenceDuration,
   543  		"the duration of time, after the node startup, during which the scoring registry remains inactive before penalizing nodes.")
   544  	flags.Int(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.AppSpecificScoreRegistryKey, p2pconfig.ScoreUpdateWorkerNumKey),
   545  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.AppSpecificScore.ScoreUpdateWorkerNum,
   546  		"number of workers for the app specific score update worker pool")
   547  	flags.Uint32(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.AppSpecificScoreRegistryKey, p2pconfig.ScoreUpdateRequestQueueSizeKey),
   548  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.AppSpecificScore.ScoreUpdateRequestQueueSize,
   549  		"size of the app specific score update worker pool queue")
   550  	flags.Uint32(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.AppSpecificScoreRegistryKey, p2pconfig.InvalidControlMessageNotificationQueueSizeKey),
   551  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.AppSpecificScore.InvalidControlMessageNotificationQueueSize,
   552  		"size of the queue for invalid control message notifications processing")
   553  	flags.Duration(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.AppSpecificScoreRegistryKey, p2pconfig.ScoreTTLKey),
   554  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.AppSpecificScore.ScoreTTL,
   555  		"time to live for app specific scores; when expired a new request will be sent to the score update worker pool; till then the expired score will be used")
   556  
   557  	flags.Uint32(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.CacheSizeKey),
   558  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.SpamRecordCache.CacheSize,
   559  		"size of the spam record cache, recommended size is 10x the number of authorized nodes")
   560  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.PenaltyDecaySlowdownThresholdKey),
   561  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.SpamRecordCache.Decay.PenaltyDecaySlowdownThreshold,
   562  		fmt.Sprintf("the penalty level at which the decay rate is reduced by --%s",
   563  			BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.DecayRateReductionFactorKey)))
   564  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.DecayRateReductionFactorKey),
   565  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.SpamRecordCache.Decay.DecayRateReductionFactor,
   566  		fmt.Sprintf("defines the value by which the decay rate is decreased every time the penalty is below the --%s",
   567  			BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.PenaltyDecaySlowdownThresholdKey)))
   568  	flags.Duration(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.PenaltyDecayEvaluationPeriodKey),
   569  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.SpamRecordCache.Decay.PenaltyDecayEvaluationPeriod,
   570  		"defines the period at which the decay for a spam record is okay to be adjusted.")
   571  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.MinimumSpamPenaltyDecayFactorKey),
   572  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.SpamRecordCache.Decay.MinimumSpamPenaltyDecayFactor,
   573  		"the minimum speed at which the spam penalty value of a peer is decayed")
   574  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.MaximumSpamPenaltyDecayFactorKey),
   575  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.SpamRecordCache.Decay.MaximumSpamPenaltyDecayFactor,
   576  		"the maximum rate at which the spam penalty value of a peer decays")
   577  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.SpamRecordCacheKey, p2pconfig.DecayKey, p2pconfig.SkipDecayThresholdKey),
   578  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.SpamRecordCache.Decay.SkipDecayThreshold,
   579  		"the threshold for which when the negative penalty is above this value, the decay function will not be called")
   580  
   581  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.GraftKey),
   582  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.MisbehaviourPenalties.GraftMisbehaviour,
   583  		"the penalty applied to the application specific penalty when a peer conducts a graft misbehaviour")
   584  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.PruneKey),
   585  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.MisbehaviourPenalties.PruneMisbehaviour,
   586  		"the penalty applied to the application specific penalty when a peer conducts a prune misbehaviour")
   587  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.IHaveKey),
   588  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.MisbehaviourPenalties.IHaveMisbehaviour,
   589  		"the penalty applied to the application specific penalty when a peer conducts a iHave misbehaviour")
   590  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.IWantKey),
   591  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.MisbehaviourPenalties.IWantMisbehaviour,
   592  		"the penalty applied to the application specific penalty when a peer conducts a iWant misbehaviour")
   593  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.PublishKey),
   594  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.MisbehaviourPenalties.PublishMisbehaviour,
   595  		"the penalty applied to the application specific penalty when a peer conducts a rpc publish message misbehaviour")
   596  	flags.Float64(BuildFlagName(gossipsubKey, p2pconfig.ScoreParamsKey, p2pconfig.ScoringRegistryKey, p2pconfig.MisbehaviourPenaltiesKey, p2pconfig.ClusterPrefixedReductionFactorKey),
   597  		config.GossipSub.ScoringParameters.ScoringRegistryParameters.MisbehaviourPenalties.ClusterPrefixedReductionFactor,
   598  		"the factor used to reduce the penalty for control message misbehaviours on cluster prefixed topics")
   599  
   600  }
   601  
   602  // LoadLibP2PResourceManagerFlags loads all CLI flags for the libp2p resource manager configuration on the provided pflag set.
   603  // Args:
   604  // *pflag.FlagSet: the pflag set of the Flow node.
   605  // *Config: the default network config used to set default values on the flags
   606  func LoadLibP2PResourceManagerFlags(flags *pflag.FlagSet, config *Config) {
   607  	flags.Float64(fmt.Sprintf("%s-%s", rootResourceManagerPrefix, fileDescriptorsRatioPrefix),
   608  		config.ResourceManager.FileDescriptorsRatio,
   609  		"ratio of available file descriptors to be used by libp2p (in (0,1])")
   610  	flags.Float64(fmt.Sprintf("%s-%s", rootResourceManagerPrefix, memoryLimitRatioPrefix),
   611  		config.ResourceManager.MemoryLimitRatio,
   612  		"ratio of available memory to be used by libp2p (in (0,1])")
   613  	loadLibP2PResourceManagerFlagsForScope(systemScope, flags, &config.ResourceManager.Override.System)
   614  	loadLibP2PResourceManagerFlagsForScope(transientScope, flags, &config.ResourceManager.Override.Transient)
   615  	loadLibP2PResourceManagerFlagsForScope(protocolScope, flags, &config.ResourceManager.Override.Protocol)
   616  	loadLibP2PResourceManagerFlagsForScope(peerScope, flags, &config.ResourceManager.Override.Peer)
   617  	loadLibP2PResourceManagerFlagsForScope(peerProtocolScope, flags, &config.ResourceManager.Override.PeerProtocol)
   618  }
   619  
   620  // loadLibP2PResourceManagerFlagsForScope loads all CLI flags for the libp2p resource manager configuration on the provided pflag set for the specific scope.
   621  // Args:
   622  // *p2pconf.ResourceScope: the resource scope to load flags for.
   623  // *pflag.FlagSet: the pflag set of the Flow node.
   624  // *Config: the default network config used to set default values on the flags.
   625  func loadLibP2PResourceManagerFlagsForScope(scope p2pconfig.ResourceScope, flags *pflag.FlagSet, override *p2pconfig.ResourceManagerOverrideLimit) {
   626  	flags.Int(fmt.Sprintf("%s-%s-%s-%s", rootResourceManagerPrefix, limitsOverridePrefix, scope, inboundStreamLimit),
   627  		override.StreamsInbound,
   628  		fmt.Sprintf("the limit on the number of inbound streams at %s scope, 0 means use the default value", scope))
   629  	flags.Int(fmt.Sprintf("%s-%s-%s-%s", rootResourceManagerPrefix, limitsOverridePrefix, scope, outboundStreamLimit),
   630  		override.StreamsOutbound,
   631  		fmt.Sprintf("the limit on the number of outbound streams at %s scope, 0 means use the default value", scope))
   632  	flags.Int(fmt.Sprintf("%s-%s-%s-%s", rootResourceManagerPrefix, limitsOverridePrefix, scope, inboundConnectionLimit),
   633  		override.ConnectionsInbound,
   634  		fmt.Sprintf("the limit on the number of inbound connections at %s scope, 0 means use the default value", scope))
   635  	flags.Int(fmt.Sprintf("%s-%s-%s-%s", rootResourceManagerPrefix, limitsOverridePrefix, scope, outboundConnectionLimit),
   636  		override.ConnectionsOutbound,
   637  		fmt.Sprintf("the limit on the number of outbound connections at %s scope, 0 means use the default value", scope))
   638  	flags.Int(fmt.Sprintf("%s-%s-%s-%s", rootResourceManagerPrefix, limitsOverridePrefix, scope, fileDescriptorsLimit),
   639  		override.FD,
   640  		fmt.Sprintf("the limit on the number of file descriptors at %s scope, 0 means use the default value", scope))
   641  	flags.Int(fmt.Sprintf("%s-%s-%s-%s", rootResourceManagerPrefix, limitsOverridePrefix, scope, memoryLimitBytes),
   642  		override.Memory,
   643  		fmt.Sprintf("the limit on the amount of memory (bytes) at %s scope, 0 means use the default value", scope))
   644  }
   645  
   646  // SetAliases this func sets an aliases for each CLI flag defined for network config overrides to it's corresponding
   647  // full key in the viper config store. This is required because in our p2pconfig.yml file all configuration values for the
   648  // Flow network are stored one level down on the network-config property. When the default config is bootstrapped viper will
   649  // store these values with the "network-p2pconfig." prefix on the config key, because we do not want to use CLI flags like --network-p2pconfig.networking-connection-pruning
   650  // to override default values we instead use cleans flags like --networking-connection-pruning and create an alias from networking-connection-pruning -> network-p2pconfig.networking-connection-pruning
   651  // to ensure overrides happen as expected.
   652  // Args:
   653  // *viper.Viper: instance of the viper store to register network config aliases on.
   654  // Returns:
   655  // error: if a flag does not have a corresponding key in the viper store; all returned errors are fatal.
   656  func SetAliases(conf *viper.Viper) error {
   657  	m := make(map[string]string)
   658  	// create map of key -> full pathkey
   659  	// ie: "networking-connection-pruning" -> "network-p2pconfig.networking-connection-pruning"
   660  	for _, key := range conf.AllKeys() {
   661  		s := strings.Split(key, ".")
   662  		// Each networking config has the format of network-p2pconfig.key1.key2.key3... in the config file
   663  		// which is translated to key1-key2-key3... in the CLI flags
   664  		// Hence, we map the CLI flag name to the full key in the config store
   665  		// TODO: all networking flags should also be prefixed with "network-config". Hence, this
   666  		// mapping should be from network-p2pconfig.key1.key2.key3... to network-config-key1-key2-key3...
   667  		m[strings.Join(s[1:], "-")] = key
   668  	}
   669  	// each flag name should correspond to exactly one key in our config store after it is loaded with the default config
   670  	for _, flagName := range AllFlagNames() {
   671  		fullKey, ok := m[flagName]
   672  		if !ok {
   673  			return fmt.Errorf("invalid network configuration missing configuration key flag name %s check config file and cli flags", flagName)
   674  		}
   675  
   676  		conf.RegisterAlias(fullKey, flagName)
   677  	}
   678  	return nil
   679  }
   680  
   681  func BuildFlagName(keys ...string) string {
   682  	return strings.Join(keys, "-")
   683  }