Introduce Rust features - #1061
Conversation
|
👋 Thanks for assigning @benthecarman as a reviewer! |
9b4022f to
7f339e5
Compare
benthecarman
left a comment
There was a problem hiding this comment.
Would be good to have CI cover the missed feature configs that claude caught
| feature = "chain-electrum", | ||
| feature = "chain-bitcoind" | ||
| )))] | ||
| compile_error!("at least one chain source feature must be enabled"); |
There was a problem hiding this comment.
should do same with db
There was a problem hiding this comment.
We can't do it exactly the same as we also support supplying a custom store via build_with_store, so can't enforce at compile time.
Allow integration runs to constrain randomized chain sources through the LDK_NODE_TEST_CHAIN_SOURCES environment variable. This makes backend-specific feature builds deterministic while preserving all-backend randomization by default. Co-Authored-By: HAL 9000
Let tests with custom node construction reuse the common chain source configuration. Co-Authored-By: HAL 9000
Exercise PostgreSQL-backed nodes with the configured or randomly selected chain backend instead of always using Esplora. Co-Authored-By: HAL 9000
Keep filesystem-specific code together so generic storage utilities can compile without that backend. This commit only relocates the existing migration behavior and tests. Co-Authored-By: HAL 9000
Hide the concrete Bitcoin Core gossip verifier behind the LDK UTXO lookup trait. This lets common gossip types compile independently of the Bitcoin Core backend without changing verification behavior. Co-Authored-By: HAL 9000
Keep human-readable-name resolution beside the unified payment code that consumes it. This commit only relocates the existing resolver and updates its internal import paths. Co-Authored-By: HAL 9000
Define the cfg-selected Builder name next to the implementation it represents. Feature-specific binding exports can now live there without changing the native and lock-wrapped builder APIs. Co-Authored-By: HAL 9000
7f339e5 to
3185f51
Compare
|
Rebased to address minor conflicts, let me know if I can squash fixups. |
benthecarman
left a comment
There was a problem hiding this comment.
mostly small things otherwise looks good
3185f51 to
7b144ab
Compare
|
Added fixups to address comments, let me know if good for squashing. |
7b144ab to
76e826a
Compare
Squashed without furhter changes. |
76e826a to
d5a6554
Compare
|
Amended with fixes for CI. |
Keep the native defaults while letting applications select only required chain sources, storage backends, and unified payment support. At least one chain source remains mandatory. PostgreSQL now has a storage-prefixed feature name. Co-Authored-By: HAL 9000
Separate backend-specific binding methods into cfg-gated implementation blocks. Method bodies and availability remain unchanged, making later conditional exports easier to review. Co-Authored-By: HAL 9000
Keep binding signatures and documentation next to their Rust implementations. Leave only the UDL object declaration so backend features can add methods without failure stubs. Co-Authored-By: HAL 9000
Build published bindings with uniffi-default and without native default features. Let local builds add backend features through LDK_NODE_EXTRA_FEATURES. Co-Authored-By: HAL 9000
Build and test UniFFI with its lean preset so excluded backends stay excluded. Check all features and test targets to catch incompatible optional dependencies without running the suite twice. Co-Authored-By: HAL 9000
List each chain, storage, payment, and binding feature and explain the unchanged native defaults. Show both lean and custom binding builds so optional backend dependencies can be selected deliberately. Co-Authored-By: HAL 9000
Avoid allocating paths before filesystem operations that only need borrowed paths. Co-Authored-By: HAL 9000
d5a6554 to
1c1063b
Compare
|
Amended once more to include guidance on Postgres prerequisites, and add a new vendored-tls feature: > git diff-tree -U2 d5a65547 1c1063bd
diff --git a/Cargo.toml b/Cargo.toml
index 6770fea2..0110c027 100755
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,5 +14,5 @@ categories = ["cryptography::cryptocurrencies"]
[package.metadata.docs.rs]
-features = ["storage-postgres", "native-tls/vendored"]
+features = ["storage-postgres-vendored-tls"]
rustdoc-args = ["--cfg", "docsrs"]
@@ -57,4 +57,5 @@ storage-filesystem = ["dep:lightning-persister"]
storage-vss = ["dep:vss-client", "dep:prost"]
storage-postgres = ["dep:tokio-postgres", "dep:native-tls", "dep:postgres-native-tls"]
+storage-postgres-vendored-tls = ["storage-postgres", "native-tls/vendored"]
unified-payments = [
"dep:bip21",
diff --git a/README.md b/README.md
index 55c0f56e..ec9de516 100644
--- a/README.md
+++ b/README.md
@@ -82,4 +82,5 @@ LDK Node's optional dependencies are grouped by the functionality they provide:
| `storage-vss` | Versioned Storage Service storage |
| `storage-postgres` | PostgreSQL storage |
+| `storage-postgres-vendored-tls` | PostgreSQL storage with vendored OpenSSL |
| `unified-payments` | BIP 21 and human-readable-name payment support |
| `uniffi` | UniFFI language bindings |
@@ -90,4 +91,8 @@ chain sources, SQLite, filesystem and VSS storage, and unified payments. Postgre
remain opt-in. Every build must enable at least one chain source feature.
+On Linux, `storage-postgres` uses the system OpenSSL installation and requires the OpenSSL
+development headers and `pkg-config`. Enable `storage-postgres-vendored-tls` instead to build
+OpenSSL from source. Vendored builds require a C compiler, `make`, and Perl.
+
Disable the default features to select only the functionality and dependencies an application
needs. For example: |
Closes #900
Previously, we omitted making use of Rust features to dis-/enable specific functionality, with the exception of
uniffiand most recently adding a tentativepostgresfeature.Here we finally change that and allow users to selectively disable and enable specific parts of the code base, hence also reducing their dependency tree.