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

fix default features leak #2314

Closed
wants to merge 3 commits into from
Closed

Conversation

name1e5s
Copy link

@name1e5s name1e5s commented Oct 28, 2021

The same as #1986
Fix some default features leaks.

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

I am a bit confused neither libp2p-mplex, libp2p-noise nor libp2p-request-response have any features. Can you explain what this change does?

@name1e5s
Copy link
Author

name1e5s commented Oct 29, 2021

I am a bit confused neither libp2p-mplex, libp2p-noise nor libp2p-request-response have any features. Can you explain what this change does?

Some features in libp2p-core can't turn off. For example, when we add the following code to Cargo.toml

libp2p = { version = "0.39", optional = true, default-features = false, features = [ "tcp-tokio", "noise", "mplex", "request-response" ] }

We can find that libp2p-core still have default features on, causing an unnecessary dependency libsecp256k1 being wrongly imported:

➜  sz git:(master) ✗ cargo tree -e features -i libp2p-core
libp2p-core v0.29.0
└── libp2p v0.39.1
    ├── libp2p feature "libp2p-mplex"
    │   └── libp2p feature "mplex"
    │       └── sz v0.1.0 (/Users/bytedance/Documents/Temp/sz)
    │           └── sz feature "default" (command-line)
    ├── libp2p feature "libp2p-noise"
    │   └── libp2p feature "noise"
    │       └── sz v0.1.0 (/Users/bytedance/Documents/Temp/sz) (*)
    ├── libp2p feature "libp2p-request-response"
    │   └── libp2p feature "request-response"
    │       └── sz v0.1.0 (/Users/bytedance/Documents/Temp/sz) (*)
    ├── libp2p feature "libp2p-tcp"
    │   └── libp2p feature "tcp-tokio"
    │       └── sz v0.1.0 (/Users/bytedance/Documents/Temp/sz) (*)
    ├── libp2p feature "mplex" (*)
    ├── libp2p feature "noise" (*)
    ├── libp2p feature "request-response" (*)
    └── libp2p feature "tcp-tokio" (*)
├── libp2p-core feature "default"
│   ├── libp2p-mplex v0.29.0
│   │   └── libp2p-mplex feature "default"
│   │       └── libp2p v0.39.1 (*)
│   ├── libp2p-noise v0.32.0
│   │   └── libp2p-noise feature "default"
│   │       └── libp2p v0.39.1 (*)
│   ├── libp2p-request-response v0.12.0
│   │   └── libp2p-request-response feature "default"
│   │       └── libp2p v0.39.1 (*)
│   ├── libp2p-swarm v0.30.0
│   │   └── libp2p-swarm feature "default"
│   │       ├── libp2p v0.39.1 (*)
│   │       └── libp2p-request-response v0.12.0 (*)
│   └── libp2p-tcp v0.29.0
│       └── libp2p v0.39.1 (*)
│       ├── libp2p-tcp feature "if-addrs"
│       │   └── libp2p-tcp feature "tokio"
│       │       └── libp2p feature "tcp-tokio" (*)
│       ├── libp2p-tcp feature "tokio" (*)
│       └── libp2p-tcp feature "tokio-crate"
│           └── libp2p-tcp feature "tokio" (*)
├── libp2p-core feature "libsecp256k1"
│   └── libp2p-core feature "secp256k1"
│       └── libp2p-core feature "default" (*)
└── libp2p-core feature "secp256k1" (*)

After this PR:

➜  sz git:(master) ✗ cargo tree -e features -i libp2p-core
libp2p-core v0.30.0-rc.2 (~/rust-libp2p/core)
├── libp2p v0.40.0-rc.3 (~/rust-libp2p)
│   ├── libp2p feature "libp2p-mplex"
│   │   └── libp2p feature "mplex"
│   │       └── sz v0.1.0 (/Users/bytedance/Documents/Temp/sz)
│   │           └── sz feature "default" (command-line)
│   ├── libp2p feature "libp2p-noise"
│   │   └── libp2p feature "noise"
│   │       └── sz v0.1.0 (/Users/bytedance/Documents/Temp/sz) (*)
│   ├── libp2p feature "libp2p-request-response"
│   │   └── libp2p feature "request-response"
│   │       └── sz v0.1.0 (/Users/bytedance/Documents/Temp/sz) (*)
│   ├── libp2p feature "libp2p-tcp"
│   │   └── libp2p feature "tcp-tokio"
│   │       └── sz v0.1.0 (/Users/bytedance/Documents/Temp/sz) (*)
│   ├── libp2p feature "mplex" (*)
│   ├── libp2p feature "noise" (*)
│   ├── libp2p feature "request-response" (*)
│   └── libp2p feature "tcp-tokio" (*)
├── libp2p-mplex v0.30.0-rc.1 (~/rust-libp2p/muxers/mplex)
│   └── libp2p v0.40.0-rc.3 (~/rust-libp2p) (*)
├── libp2p-noise v0.33.0-rc.1 (~/rust-libp2p/transports/noise)
│   └── libp2p v0.40.0-rc.3 (~/rust-libp2p) (*)
├── libp2p-request-response v0.13.0-rc.1 (~/rust-libp2p/protocols/request-response)
│   └── libp2p v0.40.0-rc.3 (~/rust-libp2p) (*)
├── libp2p-swarm v0.31.0-rc.2 (~/rust-libp2p/swarm)
│   └── libp2p-swarm feature "default"
│       ├── libp2p v0.40.0-rc.3 (~/rust-libp2p) (*)
│       └── libp2p-request-response v0.13.0-rc.1 (~/rust-libp2p/protocols/request-response) (*)
└── libp2p-tcp v0.30.0-rc.1 (~/rust-libp2p/transports/tcp)
    └── libp2p v0.40.0-rc.3 (~/rust-libp2p) (*)
    ├── libp2p-tcp feature "if-addrs"
    │   └── libp2p-tcp feature "tokio"
    │       └── libp2p feature "tcp-tokio" (*)
    ├── libp2p-tcp feature "tokio" (*)
    └── libp2p-tcp feature "tokio-crate"
        └── libp2p-tcp feature "tokio" (*)

@mxinden
Copy link
Member

mxinden commented Nov 14, 2021

Thanks for the additional info. I can reproduce it on https://github.com/mxinden/libp2p-lookup now.

This is puzzling. Have you been able to find a corresponding bug report on cargo by any chance @name1e5s?

@folex
Copy link
Contributor

folex commented Jan 14, 2022

#2437 is a fix for the features leak

@mxinden
Copy link
Member

mxinden commented Jun 27, 2022

Closing here since I am having difficulties reproducing it. @name1e5s please comment in case you are still facing this issue.

@mxinden mxinden closed this Jun 27, 2022
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