Skip to content

Simplify cargo features#182

Open
ValuedMammal wants to merge 8 commits intobitcoindevkit:masterfrom
ValuedMammal:build/feature_proxy
Open

Simplify cargo features#182
ValuedMammal wants to merge 8 commits intobitcoindevkit:masterfrom
ValuedMammal:build/feature_proxy

Conversation

@ValuedMammal
Copy link
Contributor

@ValuedMammal ValuedMammal commented Oct 31, 2025

Description

This PR is meant to streamline the handling of feature flags in the library, in particular by removing the Client's dependency on the proxy feature and overall simplifying the feature gating logic. Additionally, we move away from the old use-* feature naming convention by introducing simpler feature names, remove the unused minimal feature, and get rid of conditional compilation for debug-calls while retaining the ability to atomically count calls made.

fixes #91
fixes #42

@ValuedMammal ValuedMammal changed the title wip: Clean up "proxy" feature Clean up proxy feature Nov 5, 2025
@ValuedMammal ValuedMammal marked this pull request as ready for review November 8, 2025 17:27
Copy link
Contributor

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

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

utACK 51cfd77

@oleonardolima oleonardolima added the api API breaking change label Nov 18, 2025
@oleonardolima oleonardolima moved this to Needs Review in BDK Chain Nov 18, 2025
Copy link
Contributor

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

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

I've tested it a bit with the examples we have in the repository, see the comment above.

The same problem above occurs when trying to use proxy feature to connect via tor to a tcp:// server

Also, I wasn't able to use the proxy via Tor with TLS, still unsure if it's related to mempool.space server though.

As a general comment, we don't have any integration test or CI for the proxy feature (besides the ones in socks module), I think it's a good idea add it in the future.

run: cargo test -- --ignored test_local_timeout
- run: cargo check --verbose --features=use-openssl
- run: cargo check --verbose --no-default-features --features=proxy
- run: cargo check --verbose --no-default-features --features=minimal
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it could be addressed in a follow-up, but I think we should take advantage of a matrix strategy here, instead of having each combination written down.

src/lib.rs Outdated
all(feature = "proxy", feature = "use-rustls"),
all(feature = "proxy", feature = "use-rustls-ring")
))]
#[cfg(any(feature = "openssl", feature = "rustls", feature = "rustls-ring"))]
Copy link
Contributor

Choose a reason for hiding this comment

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

I was trying to test the client usage through plaintext (with --no-default-features), but it's not possible due to the way we have these features here.

It wasn't even working on master, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a commit c2976cf to address this.

@oleonardolima
Copy link
Contributor

@ValuedMammal Are you still looking to move this one forward ?

@ValuedMammal
Copy link
Contributor Author

Sure I can rebase it. If you like I can implement a matrix strategy in CI to check the different feature configurations, and update the justfile to do the same.

@ValuedMammal ValuedMammal force-pushed the build/feature_proxy branch 2 times, most recently from 8f8d863 to e48f646 Compare February 11, 2026 18:20
@ValuedMammal
Copy link
Contributor Author

I left the test job the same in that the tests are run using --all-features, then added a separate check job that only does cargo check. Let me know if you had something different in mind.

@ValuedMammal ValuedMammal changed the title Clean up proxy feature Simplify cargo features Feb 11, 2026
Before, the `client` module was gated on the `proxy` feature,
which caused unnecessary coupling since proxy is only
required for the Socks5 client type.

This change removes the client module's dependency on the `proxy`
feature in favor of more precise feature gating of the Socks5 client
type and related functions calling into the `socks` module.

Note that `Client` still requires a TLS backend to be enabled
by one of `use-openssl`, `use-rustls` or `use-rustls-ring`.
The `default` feature argument is redundant and
unclear, as it requires the developer to know
which aspects of the default features apply to a
particular cfg attribute. This change simplifies
feature gating logic by only requiring the features
necessary to build with a given feature set.
Introduce simpler feature names `openssl`, `rustls`,
and `rustls-ring`. The original `use-` style names
are still available for backwards compatibility.
Previously the `client` module required one of `openssl`, `rustls`,
or `rustls-ring` to be enabled, which prevented the use of
`ClientType::TCP` when `--no-default-features` was set.

To fix it, we instead use conditional compilation for `ClientType::SSL`
so that `Client` may be used over a plaintext TcpStream.

`ClientType::from_config` will now error if the url starts with
"ssl://" but none of the SSL-related features are enabled.
Removes conditional compilation of `ElectrumApi::calls_made`
so that we always increment `RawClient::calls` after each
call made. As a result the `debug-calls` feature flag can
be removed.
@oleonardolima
Copy link
Contributor

I left the test job the same in that the tests are run using --all-features, then added a separate check job that only does cargo check. Let me know if you had something different in mind.

Alright, thanks! I'm going over it right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api API breaking change

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

Client is only exported when proxy feature is enabled. Rename use-rustls and use-openssl features

2 participants