github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/netconf/config.go (about) 1 package netconf 2 3 import ( 4 "time" 5 6 p2pconfig "github.com/onflow/flow-go/network/p2p/config" 7 ) 8 9 const ( 10 gossipsubKey = "gossipsub" 11 unicastKey = "unicast" 12 connectionManagerKey = "connection-manager" 13 ) 14 15 // Config encapsulation of configuration structs for all components related to the Flow network. 16 type Config struct { 17 Unicast Unicast `mapstructure:"unicast"` 18 ResourceManager p2pconfig.ResourceManagerConfig `mapstructure:"libp2p-resource-manager"` 19 ConnectionManager ConnectionManager `mapstructure:"connection-manager"` 20 // GossipSub core gossipsub configuration. 21 GossipSub p2pconfig.GossipSubParameters `mapstructure:"gossipsub"` 22 AlspConfig `mapstructure:",squash"` 23 24 // NetworkConnectionPruning determines whether connections to nodes 25 // that are not part of protocol state should be trimmed 26 // TODO: solely a fallback mechanism, can be removed upon reliable behavior in production. 27 NetworkConnectionPruning bool `mapstructure:"networking-connection-pruning"` 28 // PreferredUnicastProtocols list of unicast protocols in preferred order 29 PreferredUnicastProtocols []string `mapstructure:"preferred-unicast-protocols"` 30 NetworkReceivedMessageCacheSize uint32 `validate:"gt=0" mapstructure:"received-message-cache-size"` 31 PeerUpdateInterval time.Duration `validate:"gt=0s" mapstructure:"peerupdate-interval"` 32 33 DNSCacheTTL time.Duration `validate:"gt=0s" mapstructure:"dns-cache-ttl"` 34 // DisallowListNotificationCacheSize size of the queue for notifications about new peers in the disallow list. 35 DisallowListNotificationCacheSize uint32 `validate:"gt=0" mapstructure:"disallow-list-notification-cache-size"` 36 } 37 38 // AlspConfig is the config for the Application Layer Spam Prevention (ALSP) protocol. 39 type AlspConfig struct { 40 // Size of the cache for spam records. There is at most one spam record per authorized (i.e., staked) node. 41 // Recommended size is 10 * number of authorized nodes to allow for churn. 42 SpamRecordCacheSize uint32 `mapstructure:"alsp-spam-record-cache-size"` 43 44 // SpamReportQueueSize is the size of the queue for spam records. The queue is used to store spam records 45 // temporarily till they are picked by the workers. When the queue is full, new spam records are dropped. 46 // Recommended size is 100 * number of authorized nodes to allow for churn. 47 SpamReportQueueSize uint32 `mapstructure:"alsp-spam-report-queue-size"` 48 49 // DisablePenalty indicates whether applying the penalty to the misbehaving node is disabled. 50 // When disabled, the ALSP module logs the misbehavior reports and updates the metrics, but does not apply the penalty. 51 // This is useful for managing production incidents. 52 // Note: under normal circumstances, the ALSP module should not be disabled. 53 DisablePenalty bool `mapstructure:"alsp-disable-penalty"` 54 55 // HeartBeatInterval is the interval between heartbeats sent by the ALSP module. The heartbeats are recurring 56 // events that are used to perform critical ALSP tasks, such as updating the spam records cache. 57 HearBeatInterval time.Duration `mapstructure:"alsp-heart-beat-interval"` 58 59 SyncEngine SyncEngineAlspConfig `mapstructure:",squash"` 60 } 61 62 // SyncEngineAlspConfig is the ALSP config for the SyncEngine. 63 type SyncEngineAlspConfig struct { 64 // BatchRequestBaseProb is the base probability in [0,1] that's used in creating the final probability of creating a 65 // misbehavior report for a BatchRequest message. This is why the word "base" is used in the name of this field, 66 // since it's not the final probability and there are other factors that determine the final probability. 67 // The reason for this is that we want to increase the probability of creating a misbehavior report for a large batch. 68 BatchRequestBaseProb float32 `validate:"gte=0,lte=1" mapstructure:"alsp-sync-engine-batch-request-base-prob"` 69 70 // RangeRequestBaseProb is the base probability in [0,1] that's used in creating the final probability of creating a 71 // misbehavior report for a RangeRequest message. This is why the word "base" is used in the name of this field, 72 // since it's not the final probability and there are other factors that determine the final probability. 73 // The reason for this is that we want to increase the probability of creating a misbehavior report for a large range. 74 RangeRequestBaseProb float32 `validate:"gte=0,lte=1" mapstructure:"alsp-sync-engine-range-request-base-prob"` 75 76 // SyncRequestProb is the probability in [0,1] of creating a misbehavior report for a SyncRequest message. 77 SyncRequestProb float32 `validate:"gte=0,lte=1" mapstructure:"alsp-sync-engine-sync-request-prob"` 78 }