Skip to content

Commit 545b037

Browse files
committed
Drop no-std feature
We drop the `lightning/no-std` feature and just take `hashbrown`,`possiblyrandom` and `libm` as required dependencies.
1 parent a06e7b9 commit 545b037

File tree

30 files changed

+110
-164
lines changed

30 files changed

+110
-164
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,11 @@ jobs:
149149
run: |
150150
cd lightning
151151
RUSTFLAGS="--cfg=require_route_graph_test" cargo test
152-
RUSTFLAGS="--cfg=require_route_graph_test" cargo test --features hashbrown
153152
cd ..
154153
- name: Run benchmarks on Rust ${{ matrix.toolchain }}
155154
run: |
156155
cd bench
157156
RUSTFLAGS="--cfg=ldk_bench --cfg=require_route_graph_test" cargo bench
158-
- name: Run benchmarks with hashbrown on Rust ${{ matrix.toolchain }}
159-
run: |
160-
cd bench
161-
RUSTFLAGS="--cfg=ldk_bench --cfg=require_route_graph_test" cargo bench --features hashbrown
162157
163158
check_commits:
164159
runs-on: ubuntu-latest
@@ -199,15 +194,15 @@ jobs:
199194
- name: Run cargo check for release build.
200195
run: |
201196
cargo check --release
202-
cargo check --no-default-features --features=no-std --release
203197
cargo check --no-default-features --features=futures,std --release
204198
cargo doc --release
205199
- name: Run cargo check for Taproot build.
206200
run: |
207201
cargo check --release
208-
cargo check --no-default-features --features=no-std --release
202+
cargo check --no-default-features --release
209203
cargo check --no-default-features --features=futures,std --release
210204
cargo doc --release
205+
cargo doc --no-default-features --release
211206
env:
212207
RUSTFLAGS: '--cfg=taproot'
213208
RUSTDOCFLAGS: '--cfg=taproot'

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[workspace]
22
resolver = "2"
33

4+
# When the workspace members change, make sure to update the list here as well
5+
# as in `ci/ci-tests.sh`.
46
members = [
57
"lightning",
68
"lightning-types",

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Crates
2727
-----------
2828
1. [lightning](./lightning)
2929
The core of the LDK library, implements the Lightning protocol, channel state machine,
30-
and on-chain logic. Supports `no-std` and exposes only relatively low-level interfaces.
30+
and on-chain logic. Supports `no_std` and exposes only relatively low-level interfaces.
3131
2. [lightning-background-processor](./lightning-background-processor)
3232
Utilities to perform required background tasks for Rust Lightning.
3333
3. [lightning-block-sync](./lightning-block-sync)

bench/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ edition = "2021"
88
name = "bench"
99
harness = false
1010

11-
[features]
12-
hashbrown = ["lightning/hashbrown"]
13-
1411
[dependencies]
1512
lightning = { path = "../lightning", features = ["_test_utils", "criterion"] }
1613
lightning-persister = { path = "../lightning-persister", features = ["criterion"] }

bench/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
This crate uses criterion to benchmark various LDK functions.
22

33
It can be run as `RUSTFLAGS=--cfg=ldk_bench cargo bench`.
4-
5-
For routing or other HashMap-bottlenecked functions, the `hashbrown` feature
6-
should also be benchmarked.

ci/check-compiles.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ cargo check
66
cargo doc
77
cargo doc --document-private-items
88
cd fuzz && RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz" cargo check --features=stdin_fuzz
9-
cd ../lightning && cargo check --no-default-features --features=no-std
9+
cd ../lightning && cargo check --no-default-features
1010
cd .. && RUSTC_BOOTSTRAP=1 RUSTFLAGS="--cfg=c_bindings" cargo check -Z avoid-dev-deps

ci/ci-tests.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export RUST_BACKTRACE=1
3333
echo -e "\n\nChecking the full workspace."
3434
cargo check --verbose --color always
3535

36+
# When the workspace members change, make sure to update the list here as well
37+
# as in `Cargo.toml`.
3638
WORKSPACE_MEMBERS=(
3739
lightning
3840
lightning-types
@@ -100,38 +102,36 @@ grep '^max_level_' lightning/Cargo.toml | awk '{ print $1 }'| while read -r FEAT
100102
RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check -p lightning --verbose --color always --features "$FEATURE"
101103
done
102104

103-
echo -e "\n\nTesting no-std builds"
105+
echo -e "\n\nTesting no_std builds"
104106
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
105107
cargo test -p $DIR --verbose --color always --no-default-features
106108
done
107109

108-
cargo test -p lightning --verbose --color always --no-default-features --features no-std
109-
# check if there is a conflict between no-std and the default std feature
110-
cargo test -p lightning --verbose --color always --features no-std
110+
cargo test -p lightning --verbose --color always --no-default-features
111111

112112
echo -e "\n\nTesting c_bindings builds"
113113
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
114114
# disable doctests in `c_bindings` so we skip doctests entirely here.
115115
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always --lib --bins --tests
116116

117117
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
118-
# check if there is a conflict between no-std and the c_bindings cfg
118+
# check if there is a conflict between no_std and the c_bindings cfg
119119
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features
120120
done
121121

122122
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
123123
# disable doctests in `c_bindings` so we skip doctests entirely here.
124124
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning-background-processor --verbose --color always --features futures --no-default-features --lib --bins --tests
125-
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --verbose --color always --no-default-features --features=no-std --lib --bins --tests
125+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --verbose --color always --no-default-features --lib --bins --tests
126126

127127
echo -e "\n\nTesting other crate-specific builds"
128128
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
129129
RUSTFLAGS="$RUSTFLAGS --cfg=ldk_test_vectors" cargo test -p lightning --verbose --color always --no-default-features --features=std
130130
# This one only works for lightning-invoice
131-
# check that compile with no-std and serde works in lightning-invoice
131+
# check that compile with no_std and serde works in lightning-invoice
132132
cargo test -p lightning-invoice --verbose --color always --no-default-features --features serde
133133

134-
echo -e "\n\nTesting no-std build on a downstream no-std crate"
134+
echo -e "\n\nTesting no_std build on a downstream no-std crate"
135135
# check no-std compatibility across dependencies
136136
pushd no-std-check
137137
cargo check --verbose --color always --features lightning-transaction-sync

fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ libfuzzer_fuzz = ["libfuzzer-sys"]
1818
stdin_fuzz = []
1919

2020
[dependencies]
21-
lightning = { path = "../lightning", features = ["regex", "hashbrown", "_test_utils"] }
21+
lightning = { path = "../lightning", features = ["regex", "_test_utils"] }
2222
lightning-invoice = { path = "../lightning-invoice" }
2323
lightning-rapid-gossip-sync = { path = "../lightning-rapid-gossip-sync" }
2424
bech32 = "0.9.1"

lightning-background-processor/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Utilities that take care of tasks that (1) need to happen periodically to keep Rust-Lightning
2-
//! running properly, and (2) either can or should be run in the background. See docs for
3-
//! [`BackgroundProcessor`] for more details on the nitty-gritty.
4-
2+
//! running properly, and (2) either can or should be run in the background.
3+
#![cfg_attr(feature = "std", doc = "See docs for [`BackgroundProcessor`] for more details.")]
54
#![deny(rustdoc::broken_intra_doc_links)]
65
#![deny(rustdoc::private_intra_doc_links)]
76
#![deny(missing_docs)]

lightning-rapid-gossip-sync/src/lib.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,15 @@
3535
//! Note that the first ever rapid sync should use `0` for `last_sync_timestamp`.
3636
//!
3737
//! After the gossip data snapshot has been downloaded, one of the client's graph processing
38-
//! functions needs to be called. In this example, we process the update by reading its contents
39-
//! from disk, which we do by calling [`RapidGossipSync::update_network_graph`]:
38+
//! functions needs to be called.
39+
#![cfg_attr(
40+
feature = "std",
41+
doc = "In this example, we process the update by reading its contents from disk, which we do by calling [`RapidGossipSync::update_network_graph`]:"
42+
)]
43+
#![cfg_attr(
44+
not(feature = "std"),
45+
doc = "In this example, we process the update by reading its contents from disk, which we do by calling [`RapidGossipSync::update_network_graph_no_std`]:"
46+
)]
4047
//!
4148
//! ```
4249
//! use bitcoin::constants::genesis_block;
@@ -54,10 +61,17 @@
5461
//! let network_graph = NetworkGraph::new(Network::Bitcoin, &logger);
5562
//! let rapid_sync = RapidGossipSync::new(&network_graph, &logger);
5663
//! let snapshot_contents: &[u8] = &[0; 0];
57-
//! // In no-std you need to provide the current time in unix epoch seconds
58-
//! // otherwise you can use update_network_graph
59-
//! let current_time_unix = 0;
60-
//! let new_last_sync_timestamp_result = rapid_sync.update_network_graph_no_std(snapshot_contents, Some(current_time_unix));
64+
//! // In non-`std` environments you need to provide the current time in unix epoch seconds
65+
//! // otherwise you can use `update_network_graph`:
66+
#![cfg_attr(
67+
feature = "std",
68+
doc = "let new_last_sync_timestamp_result = rapid_sync.update_network_graph(snapshot_contents);"
69+
)]
70+
#![cfg_attr(not(feature = "std"), doc = "let current_time_unix = 0;")]
71+
#![cfg_attr(
72+
not(feature = "std"),
73+
doc = "let new_last_sync_timestamp_result = rapid_sync.update_network_graph_no_std(snapshot_contents, Some(current_time_unix));"
74+
)]
6175
//! ```
6276
6377
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]

0 commit comments

Comments
 (0)