feat: enable no_std compilation and check it in CI#93
feat: enable no_std compilation and check it in CI#93JoseSK999 wants to merge 3 commits intomit-dci:mainfrom
no_std compilation and check it in CI#93Conversation
| 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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
606db6e to
21ae740
Compare
|
Pushed 21ae740
And very important:
|
|
@JoseSK999 you could also add a |
I had extended the test:
cargo +nightly test --no-default-features
cargo +nightly test --all-features
cargo +stable test --no-default-features
cargo +stable test --all-featuresand use it in CI? (not sure) |
|
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 |
|
CI here uses |
|
I guess that |
21ae740 to
8101330
Compare
|
So I have made
|
src/accumulator/pollard.rs
Outdated
| //! Nodes are kept in memory, and they hold their hashes, a reference to their **aunt** (not | ||
| //! parent!), and their nieces (not children!). We do this to allow for proof generation, while | ||
| //! prunning as much as possible. In a merkle proof, we only need the sibling of the path to the | ||
| //! root, the parent is always computed on the fly as we walk up the tree. Some there's no need to |
There was a problem hiding this comment.
| //! root, the parent is always computed on the fly as we walk up the tree. Some there's no need to | |
| //! root, the parent is always computed on the fly as we walk up the tree. So, there's no need to |
8101330 to
a03cc61
Compare
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.
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.
a03cc61 to
4bd5934
Compare
| extern crate alloc; | ||
|
|
||
| #[cfg(not(feature = "std"))] | ||
| /// Re-exports `alloc`/`std` basics plus HashMap/HashSet and IO traits. |
There was a problem hiding this comment.
| /// Re-exports `alloc`/`std` basics plus HashMap/HashSet and IO traits. | |
| /// Re-exports `alloc` basics plus HashMap/HashSet and IO traits. |
| @@ -33,7 +48,7 @@ test-msrv: | |||
| cargo update -p serde_json --precise 1.0.81 | |||
| cargo update -p serde --precise 1.0.160 | |||
| cargo update -p half --precise 2.4.1 | |||
|
|
|||
|
|
|||
| cargo +1.74.0 test --no-default-features | |||
| cargo +1.74.0 test --all-features | |||
| rm Cargo.lock | |||
There was a problem hiding this comment.
nit: you could add a ci/pin-msrv.sh script to pin dependencies and have the justfile and CI run it so we have a single source of truth (see https://github.com/bitcoindevkit/bdk/blob/master/ci/pin-msrv.sh and https://github.com/bitcoindevkit/bdk/blob/master/.github/workflows/cont_integration.yml#L45-L47)
There was a problem hiding this comment.
@JoseSK999 you could also add a section to the README about building with MSRV:
Minimum Supported Rust Version
This library should compile with any combination of features with Rust 1.74.0.
To build with the MSRV you will need to pin dependencies:
bash ci/pin-msrv.sh
Description
This PR adds two new dependencies that are needed for
no_stdsupport:hashbrown(HashMapalternative) andbitcoin_io(iotrait and type replacements).The
AccumulatorHashtrait bounds depend on whether we usestdorno_stdnow.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
preludelist is fromfloresta-common, I think I can trim a couple of these imports.