-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
moved ConnectionWatcherType from p2p.toml to prefs.toml #4299
moved ConnectionWatcherType from p2p.toml to prefs.toml #4299
Conversation
Codecov Report
@@ Coverage Diff @@
## rc/2022-july #4299 +/- ##
===============================================
Coverage ? 73.67%
===============================================
Files ? 662
Lines ? 86132
Branches ? 0
===============================================
Hits ? 63458
Misses ? 17917
Partials ? 4757 Continue to review full report at Codecov.
|
PreferredPeersHolder: disabled.NewPreferredPeersHolder(), | ||
NodeOperationMode: p2p.NormalOperation, | ||
PeersRatingHandler: disabled.NewDisabledPeersRatingHandler(), | ||
ConnectionWatcherType: "disabled", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that flag hasn't been altered in the previous code. also, might use constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seednode will not work with ConnectionWatcherType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one more config for the seednode :(
Since it won't work on the seednode binary anyway, I suggest to leave it as a const.
@@ -13,4 +13,5 @@ type PreferencesConfig struct { | |||
RedundancyLevel int64 | |||
PreferredConnections []string | |||
FullArchive bool | |||
ConnectionWatcherType string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please leave FullArchive bool
the last one due to memory alignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved up one position
@@ -52,6 +52,7 @@ func CreateDefaultConfig() *config.Configs { | |||
|
|||
p2pConfig.KadDhtPeerDiscovery.Enabled = false | |||
prefsConfig.Preferences.DestinationShardAsObserver = "0" | |||
prefsConfig.Preferences.ConnectionWatcherType = "print" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please define constants somewhere for these values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added them to p2p (ConnectionWatcherType interface is declared here) constants and used them everywhere
const printConnectionsWatcher = "print" | ||
const disabledConnectionsWatcher = "disabled" | ||
const ( | ||
printConnectionsWatcher = "print" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move them in a new package and export them & use everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why exported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added them to p2p and used everywhere
|
||
// NewConnectionsWatcher creates a new ConnectionWatcher instance based on the input parameters | ||
func NewConnectionsWatcher(connectionsWatcherType string, timeToLive time.Duration) (p2p.ConnectionsWatcher, error) { | ||
switch connectionsWatcherType { | ||
case printConnectionsWatcher: | ||
return metrics.NewPrintConnectionsWatcher(timeToLive) | ||
case disabledConnectionsWatcher: | ||
case disabledConnectionsWatcher, emptyConnectionsWatcher: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might use a new case for emptyConnectionsWatcher
because it can only be empty due to bad configuration. therefore, we'd want to see a log warn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree to be left as it is now: the config misconfiguration will be hit because the prefs.toml is not overwritten on upgrade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the idea to add the emptyConnectionsWatcher without any error is that the prefs.toml is not overwritten and has to be added manually. Update log.Trace to log.Debug on the connectionsWatcherTypeFactory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor stuff 👍
const printConnectionsWatcher = "print" | ||
const disabledConnectionsWatcher = "disabled" | ||
const ( | ||
printConnectionsWatcher = "print" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why exported?
|
||
// NewConnectionsWatcher creates a new ConnectionWatcher instance based on the input parameters | ||
func NewConnectionsWatcher(connectionsWatcherType string, timeToLive time.Duration) (p2p.ConnectionsWatcher, error) { | ||
switch connectionsWatcherType { | ||
case printConnectionsWatcher: | ||
return metrics.NewPrintConnectionsWatcher(timeToLive) | ||
case disabledConnectionsWatcher: | ||
case disabledConnectionsWatcher, emptyConnectionsWatcher: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree to be left as it is now: the config misconfiguration will be hit because the prefs.toml is not overwritten on upgrade.
p2p/libp2p/netMessenger.go
Outdated
@@ -182,7 +183,8 @@ func constructNode( | |||
return nil, err | |||
} | |||
|
|||
connWatcher, err := metricsFactory.NewConnectionsWatcher(args.P2pConfig.Node.ConnectionWatcherType, ttlConnectionsWatcher) | |||
log.Trace("connectionWatcherType", "type", args.ConnectionWatcherType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be log.Debug as it is a one-time print
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to Debug
p2p/libp2p/netMessenger_test.go
Outdated
SyncTimer: &libp2p.LocalSyncTimer{}, | ||
PreferredPeersHolder: &p2pmocks.PeersHolderStub{}, | ||
PeersRatingHandler: &p2pmocks.PeersRatingHandlerStub{}, | ||
ConnectionWatcherType: "print", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be an exported const in export_test.go that will be equal to the unexported const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added to p2p as constant (where ConnectionWatcherType interface is declared) and used everywhere
…ype-prefs.toml' into EN-12618-move-connectionWatcherType-prefs.toml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ Log scanner @@
EN-12618-move-connectionWatcherType-prefs.toml##
================================================================================
- Known Warnings 22
- New Warnings 0
- Known Errors 0
- New Errors 2
- Panics 0
================================================================================
the ConnectionWatcherType was overwritten on upgrade and so was moved to prefs.toml
added emptyConnectionsWatcher const so that if the ConnectionWatcherType is not set, there should be no need to add it to the prefs.toml