Skip to content
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

swarm: make smart-dialing opt in #2340

Merged
merged 4 commits into from
Jun 8, 2023
Merged

Conversation

sukunrt
Copy link
Member

@sukunrt sukunrt commented Jun 6, 2023

No description provided.

@p-shahi p-shahi mentioned this pull request Jun 6, 2023
27 tasks
Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed my mind on this being a bool. We can just allow people to inject their own dial ranker. In this release, by default a nil dial ranker will be used, disabling smart dialing. In the next release, by default the DefaultDialRanker will be used, and to disable smart dialing, you'd pass in a nil dial ranker.

CHANGELOG.md Outdated Show resolved Hide resolved
defaults.go Outdated
@@ -135,6 +135,11 @@ var DefaultPrometheusRegisterer = func(cfg *Config) error {
return cfg.Apply(PrometheusRegisterer(prometheus.DefaultRegisterer))
}

// DefaultSmartDialing configures libp2p to disable smart dialing by default
var DefaultSmartDialing = func(cfg *Config) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need an option for that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this. This helps us flip the default option in a later release. Is there a way to do this without this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to explicitly define a type? Can’t we just apply the default if no dial ranker is set?

Copy link
Member Author

@sukunrt sukunrt Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear we are now discussion the config fields: DialRanker and DialRankerCustom.

If we don't have DialRankerCustom we cannot distinguish between cases where the user has not provided a value and where the user has explicitly provided nil to disable smart dialing. This is not an issue now but for the future release where we want to turn smart dialing on by default we will need to use swarm.DefaultDialRanker in such cases. I want to keep the behaviour that option DialRanker(nil) disables smart dialing in future releases.

Using a Default Option just felt cleaner. see DefaultEnableRelay

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about doing the thing we did for the rcmgr? Provide a NullDialRanker implementation. iiuc we already have that, the NoDelayDialRanker.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have strong opinions on this. Removed the field DialRankerCustom and the explicit default option. Now default is set here https://github.com/sukunrt/go-libp2p/blob/smart-dialing-optin/config/config.go#L180

config/config.go Outdated Show resolved Hide resolved
@sukunrt
Copy link
Member Author

sukunrt commented Jun 7, 2023

@marten-seemann ignoring the changelog, is this what you had in mind?

Update: removed changes to changelog in favour of #2342

@MarcoPolo
Copy link
Collaborator

No strong opinion, but I think it's a nicer api for the user to be able to enable/disable smart dialing with a boolean rather than having users know about dial rankers.

@sukunrt sukunrt merged commit 82e6227 into libp2p:master Jun 8, 2023
@sukunrt sukunrt deleted the smart-dialing-optin branch June 8, 2023 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants