Skip to content

fix(chain,core): prevent serde from implicitly leaking std into no_std environments#2227

Open
EliteCoder18 wants to merge 1 commit into
bitcoindevkit:masterfrom
EliteCoder18:fix/serde-no-std
Open

fix(chain,core): prevent serde from implicitly leaking std into no_std environments#2227
EliteCoder18 wants to merge 1 commit into
bitcoindevkit:masterfrom
EliteCoder18:fix/serde-no-std

Conversation

@EliteCoder18

Copy link
Copy Markdown

Description

Fix silent serde/std leak in bdk_core and bdk_chain both crates declared their serde optional dependency without default features = false, causing serde's std feature to activate unconditionally even in no_std builds.

  • bdk_core: added default-features = false + serde?/std in std feature.
  • Dropped rc the only two serde-derived types (BlockId, ConfirmationBlockTime) are pure scalars needing neither serde/rc nor serde/alloc.
  • bdk_chain: added default-features = false and explicitly enabledalloc and rc directly on the serde dep + serde?/std in std. Both are required because tx_graph::ChangeSet holds BTreeSet<Arc<Transaction>> and serde gates Arc<T>: Serialize behind all(feature = "rc", any(feature = "std", feature = "alloc")).

This fix was identified while working on (bitcoindevkit/bdk_wallet#494).

Notes to the reviewers

The alloc and rc features are placed on the serde dependency directly rather than behind a separate feature flag because bdk_chain unconditionally requires alloc anyway.

Changelog notice

  • bdk_core: serde dep was missing default-features = false, leaking serde/std into no_std builds and remove unnecessary rc feature .
  • bdk_chain: same leak fixed and serde/alloc and serde/rc now explicitly enabled on the dep .

Checklists

All Submissions:

@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.65%. Comparing base (6d03fc3) to head (29d1f5b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2227   +/-   ##
=======================================
  Coverage   78.65%   78.65%           
=======================================
  Files          30       30           
  Lines        5909     5909           
  Branches      279      279           
=======================================
  Hits         4648     4648           
  Misses       1185     1185           
  Partials       76       76           
Flag Coverage Δ
rust 78.65% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@notmandatory notmandatory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK cc4cef4

Good catch finding that rc isn't needed for bdk_core.

@oleonardolima oleonardolima added the bug Something isn't working label Jun 15, 2026
@oleonardolima oleonardolima moved this to Needs Review in BDK Chain Jun 15, 2026
@oleonardolima oleonardolima added this to the Chain 0.24.0 milestone Jun 15, 2026

@oleonardolima oleonardolima left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

utACK cc4cef4

I merged the update of rustc, so you'll need to rebase it run with the latest CI.

Comment thread crates/chain/Cargo.toml Outdated
[features]
default = ["std", "miniscript"]
std = ["bitcoin/std", "miniscript?/std", "bdk_core/std"]
std = ["bitcoin/std", "miniscript?/std", "bdk_core/std", "serde?/std"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: do we need this, as it's already being brought by bdk_core/std and bdk_core/serde below ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

You're right, removed. Since both crates are in the same repo the transitive path through bdk_core/std is guaranteed. Thanks!

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

Labels

bug Something isn't working

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

3 participants