fix(core,chain): disable serde default features for no_std#2238
Open
ANAMASGARD wants to merge 2 commits into
Open
fix(core,chain): disable serde default features for no_std#2238ANAMASGARD wants to merge 2 commits into
ANAMASGARD wants to merge 2 commits into
Conversation
Serde's default `std` feature was leaking into downstream no_std builds via Cargo feature unification when `bdk_chain/serde` was enabled. Gate `serde/std` behind each crate's `std` feature instead, add the `alloc` feature (matching the `bitcoin` crate), and guard against regressions in CI with a feature-tree assertion plus a bare-metal target check. Fixes bitcoindevkit#2208
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #2208.
Both
bdk_coreandbdk_chaindeclared theirserdedependency withoutdefault-features = false. Since serde's default feature set includesstd, enablingbdk_chain/serde(orbdk_core/serde) in a downstreamno_stdcrate activatedserde/stdthrough Cargo's feature unification, breaking compilation on bare-metal targets wherestdis unavailable.This PR disables serde's default features in both crates and re-enables
serde/stdonly through each crate's ownstdfeature.Changes
bdk_core/bdk_chain:serde = { version = "1", optional = true, default-features = false, features = ["derive", "rc", "alloc"] }allocmirrors thebitcoincrate and is required forno_std + allocserializationrcis kept unchanged (existing behavior)serde/stdonly via each crate'sstdfeature usingserde?/stdcheck-no-stdjob): added acargo treefeature-graph assertion (--no-dev-dependencies) that fails ifserde/stdis pulled into ano_stdbuild, plus athumbv7em-none-eabihfbare-metalcargo checkNotes to the reviewers
cargo check --no-default-features --features serdeon the host passes even before this fix, because the host providesstd. The bug only surfaces on targets withoutstd, so verification usescargo tree -e features(dependency-graph proof) and a bare-metal target (compile proof).Verified locally:
no_std + serdeno longer pullsserde feature "std"forbdk_coreandbdk_chainstd + serdestill enablesserde/std(no behavior change for std users)bdk_core,bdk_chain,bdk_file_store,bdk_testenv,bdk_bitcoind_rpc,bdk_electrum,bdk_esploracargo clippy --all-features --all-targets -- -D warnings,cargo doc, andcargo +nightly fmt --all --checkall passFollow-up (out of scope): a
no_std + miniscript + serdecombination may still pullserde/stdvia upstreamminiscript's serde dependency, which does not disable its default features. That is a separate upstream concern and is not addressed here.Changelog notice
bdk_coreandbdk_chainincorrectly enablingserde/stdinno_stdbuilds when theserdefeature was enabled.Checklists
All Submissions:
Bugfixes: