-
Notifications
You must be signed in to change notification settings - Fork 407
Document lightning
crate features
#1478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lightning
crate features
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this one!
lightning/src/lib.rs
Outdated
//! | ||
//! Some of the features include: | ||
//! | ||
//! 1. Internal test utilities exposed to other repo crates: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should document this - no one but us should ever use it, and we just use it for other creates in the same repo.
lightning/src/lib.rs
Outdated
//! max_level_trace = [] | ||
//! ``` | ||
//! | ||
//! 3. Allow signing of local transactions that may have been revoked or will be revoked, for functional testing (e.g. justice tx handling). This is unsafe to use in production because it may result in the counterparty publishing taking our funds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets not document "unsafe in production" stuff :)
lightning/src/lib.rs
Outdated
//! unsafe_revoked_tx_signing = [] | ||
//! _bench_unstable = [] | ||
//! | ||
//! no-std = ["hashbrown", "bitcoin/no-std", "core2/alloc"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add comments for no-std
and std
saying, well, "std
enables things which require std
, including std::io
trait implementations and things which utilize time" and "no-std
exposes write trait implementations from the core2
crate"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for having look!
So far I think you're mostly stating what the features are, but not what they do. It's probably best to keep it brief, but it would still be highly appreciated if you could at least roughly describe why a user would want to enable/disable a particular feature.
lightning/src/lib.rs
Outdated
//! std = ["bitcoin/std"] | ||
//! ``` | ||
//! | ||
//! 4. Generate low-r bitcoin signatures, which saves 1 byte in 50% of the cases: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mh, from/for what does it save 1 byte in 50%? Could you explain what the feature does and maybe supply a reference for further reading, e.g., bitcoin/bitcoin#13666 or https://bitcoin.stackexchange.com/questions/111660/what-is-signature-grinding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheBlueMatt @tnull thank you for your comments and suggestions! I made the recommend changes!
lightning/src/lib.rs
Outdated
//! | ||
//! 2. Allow signing of local transactions that may have been revoked or will be revoked, | ||
//! for functional testing (e.g. justice tx handling): | ||
//! * `unsafe_revoked_tx_signing` - allows unsafe signing in dev code, such as functional testing of justice transactions outside our crate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets not document test-only features like unsafe_revoked_tx_signing
and _bench_unstable
.
lightning/src/lib.rs
Outdated
//! for functional testing (e.g. justice tx handling): | ||
//! * `unsafe_revoked_tx_signing` - allows unsafe signing in dev code, such as functional testing of justice transactions outside our crate | ||
//! * `_bench_unstable` - allows test features for benching | ||
//! * `no-std ` - exposes write trait implementations from the `core2` crate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not listed (ie with a 2. in front)?
lightning/src/lib.rs
Outdated
//! `default` features are: | ||
//! | ||
//! * `std` - enables things which require `std`, including `std::io` trait implementations and things which utilize time | ||
//! * `grind_signatures` - enables generation of [low-r bitcoin signatures](https://bitcoin.stackexchange.com/questions/111660/what-is-signature-grinding), which saves 1 byte per signature in 50% of the cases (see [bitcoin PR #13666](https://github.com/bitcoin/bitcoin/pull/13666)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just move these to the list above and then list default features separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheBlueMatt what other features are in default
apart from std
and grind_signatures
? I just see those two in Cargo.toml
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just meant that we should maybe document std
and grind_signatures
in the same section as everything else, and then separately mention that default
includes those two, rather than documenting them in a separate section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see will do - thanks for the clarification!
lightning/src/lib.rs
Outdated
//! | ||
//! `default` features are: | ||
//! | ||
//! * `std` - enables things which require `std`, including `std::io` trait implementations and things which utilize time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "things" is a bit unspecific/casual here. Maybe "functionalities", avoiding the obvious "features"?
lightning/src/lib.rs
Outdated
//! | ||
//! Available features are: | ||
//! | ||
//! 1. Skip logging of messages at levels below the given log level: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can switch the order here, so that the arguably more important (default) features are described up top, and the logging/debugging things are listed beneath?
Codecov Report
@@ Coverage Diff @@
## main #1478 +/- ##
==========================================
- Coverage 90.93% 90.93% -0.01%
==========================================
Files 77 77
Lines 42394 42394
Branches 42394 42394
==========================================
- Hits 38553 38550 -3
- Misses 3841 3844 +3
Continue to review full report at Codecov.
|
@TheBlueMatt @tnull made the recommended changes! Thanks for your continued reviews! |
lightning/src/lib.rs
Outdated
//! * `std` | ||
//! * `grind_signatures` | ||
//! * `no-std ` - exposes write trait implementations from the `core2` crate | ||
//! * `justice_tx_handling` - allows signing of local transactions that may have been revoked or will be revoked for functional testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we ever want anyone using this - its basically a debug feature to enable unsafe behavior during testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good - I will remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Can you rebase to clean up the git history (rather than merging in upstream changes, there shouldn't generally be any reason to do that) and we can land it? 🚀
lightning/src/lib.rs
Outdated
//! | ||
//! * `std` | ||
//! * `grind_signatures` | ||
//! * `no-std ` - exposes write trait implementations from the `core2` crate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe say "at least one of no-std or std are required"
@@ -17,6 +17,24 @@ | |||
//! figure out how best to make networking happen/timers fire/things get written to disk/keys get | |||
//! generated/etc. This makes it a good candidate for tight integration into an existing wallet | |||
//! instead of having a rather-separate lightning appendage to a wallet. | |||
//! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: a number of lines here have whitespace at EOL, would be nice to remove that.
Rebased! Let me know if you want me to make any more changes :) |
Looks like there's still three commits? Can you squash down the fixup commits into a consistent git history that doesn't contain fixes for earlier commits in later ones. |
e95e8c0
to
b68ad7a
Compare
Not sure how I missed that - thanks for the heads up! |
Can you reword the commit from "Removed justice_tx_handling" to something about documenting features? |
Yup! Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though it looks like there's still EOL whitespace on a few lines. Also, if you fix that can you break lines at around 100 chars long?
Please don't push merge commits to PRs, please rebase instead. |
87b346f
to
c741044
Compare
Sorry I am having a hard time rebasing properly - any good guides to read? |
Would I be able to delete this PR and create a new one? It has become very messy and I don't want to make it a headache for you. |
Not sure about a guide right now, but you basically just want to use You may also want to have a look at the Since I find that I almost always want to rebase instead of merge, I set
in my
Don't worry! You're almost there, please don't give up now! :) |
I generally point people to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits |
@TheBlueMatt @tnull Thank you for your support! I think I managed to clean things up with your help :) |
@tnull can you please re-approve this PR? |
I already did, but I think we need to get another person that has merge rights to do that. |
Thanks for letting me know! @TheBlueMatt is there anything I should do at this point in time with regards to this PR? |
Closes #1462.
Issue: We have a few features defined in Cargo.toml with comments describing their use, but we don't expose them in the crate-level lib.rs documentation, making docs pretty much invisible. We should copy the text over, expand it, and clarify it so that you can see the features on docs.rs.
Changes: I have added the features defined in Cargo.toml (with comments) into the crate-level lib.rs documentation - please let me know if you want more comprehensive descriptions and/or if the structure of the documentation should change. I am new to Rust and happy to learn :)