Skip to content

Conversation

@JoseSK999
Copy link

@JoseSK999 JoseSK999 commented Feb 5, 2026

Description

This PR adds two new dependencies that are needed for no_std support: hashbrown (HashMap alternative) and bitcoin_io (io trait and type replacements).

The AccumulatorHash trait bounds depend on whether we use std or no_std now.

Note

This seems to work but perhaps we should add a feature powerset CI check to ensure all 4 combinations work fine for clippy and testing.

The prelude list is from floresta-common, I think I can trim a couple of these imports.

bitcoin_hashes = { version = "0.19", default-features = false }
hex-conservative = { version = "1.0.0", default-features = false }
serde = { version = "1.0", features = ["derive"], optional = true }
hashbrown = "0.16.1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to make sure: you can't disable a dependency if a feature is on, right? You can only enable them. Because now we have at least one non rust-bitcoin dependency that's not feature-gated. I guess it's ok, since hashbrown is super small and is the basis for std's hashmap implementation

Copy link
Author

Choose a reason for hiding this comment

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

Yes, sort of ugly. Otherwise we would have to create a no-std or hashbrown feature required for no-std.

But as you say, std::collections::HashMap is wrapping the hashbrown one: https://doc.rust-lang.org/src/std/collections/hash/map.rs.html

This commit adds two new dependencies that are needed for `no_std` support: `hashbrown` (`HashMap` alternative) and `bitcoin_io` (`io` trait and type replacements).

The `AccumulatorHash` trait bounds depend on whether we use `std` or `no_std` now.
@JoseSK999
Copy link
Author

Pushed 21ae740

  • Cleanup the prelude mod, now it's mostly exporting alloc items to mirror the std prelude, io and HashMap/HashSet
  • Imported some items

And very important:

  • Test and check rustreexo without the std feature (this catched doctest issues and a panic in tests)

@luisschwab
Copy link
Contributor

luisschwab commented Feb 5, 2026

@JoseSK999 you could also add a test-no-std recipe to the justfile and have CI run the recipe, so we can avoid duplication and have the justfile as the single source of truth for testing.

@JoseSK999
Copy link
Author

@JoseSK999 you could also add a test-no-std recipe to the justfile and have CI run the recipe, so we can avoid duplication and have the justfile as the single source of truth for testing.

I had extended the just test recipe to test no default features (i.e., no-std), I think better than a separate just test-no-std. But CI is not using just test. Should I make the recipe be

test:
    cargo +nightly test --no-default-features
    cargo +nightly test --all-features
    cargo +stable test --no-default-features
    cargo +stable test --all-features

and use it in CI? (not sure)

@luisschwab
Copy link
Contributor

Oh, I thought I had changed CI to use the justfile's recipes. I think that is a better approach (I do it on my own repos). Thoughts @Davidson-Souza

@JoseSK999
Copy link
Author

CI here uses just check and just test-msrv, but not just test

@luisschwab
Copy link
Contributor

I guess that just test and just test-msrv should be extended to check for no-std and have CI use those instead.

This ensures skipping the `std` feature works as expected even though some traits and types are from `hashbrown` and `bitcoin_io`. Also runs doctests and clippy.

Created `test-stable` and `test-nightly` recipes for use in CI.
@JoseSK999
Copy link
Author

JoseSK999 commented Feb 6, 2026

So I have made just test delegate to just test-stable and just test-nightly. In CI we now call these two 👺

just test-{stable/nightly/msrv} and just check are all now running with --no-default-features too

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