Skip to content

Misc (mostly-)feature cleanups #3250

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

Merged
merged 5 commits into from
Aug 21, 2024

Conversation

TheBlueMatt
Copy link
Collaborator

Built on #3249, random stuff I came across while writing that.

@TheBlueMatt TheBlueMatt force-pushed the 2024-08-feature-cleanup branch from 468d088 to d27e098 Compare August 17, 2024 22:25
Copy link

codecov bot commented Aug 17, 2024

Codecov Report

Attention: Patch coverage is 93.93939% with 4 lines in your changes missing coverage. Please review.

Project coverage is 89.81%. Comparing base (bbfa15e) to head (11ab302).
Report is 8 commits behind head on main.

Files Patch % Lines
lightning/src/onion_message/functional_tests.rs 50.00% 2 Missing ⚠️
lightning/src/ln/functional_test_utils.rs 94.73% 1 Missing ⚠️
lightning/src/ln/outbound_payment.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3250      +/-   ##
==========================================
- Coverage   89.82%   89.81%   -0.01%     
==========================================
  Files         125      125              
  Lines      102867   102798      -69     
  Branches   102867   102798      -69     
==========================================
- Hits        92398    92327      -71     
- Misses       7753     7756       +3     
+ Partials     2716     2715       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheBlueMatt TheBlueMatt force-pushed the 2024-08-feature-cleanup branch from d27e098 to 5b615fe Compare August 18, 2024 15:35
@arik-so
Copy link
Contributor

arik-so commented Aug 19, 2024

Needs a rebase.

In 81389de we removed a note about
mixing the `std` and `no-std` feature when de/serializing
`ProbabilisticScorer`s but forgot to note that there was a second
copy of that note in the module documentation.

This removes that note.
To handle `std` and `no-std` concepts of time in scoring, we'd
originally written a generic `Time` trait which we could use to
fetch the current time, observe real (not wall-clock) elapsed time,
and serialize the time.

Eventually, scoring stopped using this `Time` trait but outbound
payment retry expiry started using it instead to mock time in
tests.

Since scoring no longer uses the full features which required the
`Time` trait, we can substantially simplify by just having the
mocking option.
Not sure why we ever really had this, no one really ever bounds
anything on `std::Error` and its kinda a dead type, so there's no
need for us to `impl` it for our types.
Fewer feature flags makes for more readable code, so we opt for
that over very marginally more effecient code here.
We never actually build with `#![no_std]` in tests as Rust does
not support it. Thus, many tests have spurious `std` feature gates
when they run just fine without them. Here we remove those gates,
though note that tests that depend on behavior elsewhere in the
codebase which is `std`-gated obviously need to retain their
feature gates.
@TheBlueMatt TheBlueMatt force-pushed the 2024-08-feature-cleanup branch from 5b615fe to 11ab302 Compare August 21, 2024 14:11
@TheBlueMatt
Copy link
Collaborator Author

Rebased.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

Love to see it
Screenshot 2024-08-21 at 11 38 24 AM

/// Returns true when a full routing table sync should be performed with a peer.
fn should_request_full_sync(&self, _node_id: &PublicKey) -> bool {
//TODO: Determine whether to request a full sync based on the network map.
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to remove this todo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea, I don't think we will/can ever make such a decision - instead we need the spec to include a set reconciliation protocol.

Comment on lines +618 to +619
#[allow(unused)]
let should_sync = self.should_request_full_sync();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I don't see why this got moved and allow(unused)'d?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed the std bounds on should_request_full_sync, and in order to make it not-unused, I moved this out of the std block below. But that also means that in no-std builds this value is unused. In theory we should keep the bounds as they were, but I liked the diff stats 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, I had a similar issue once. Hate this aspect of conditional compilation

Copy link
Contributor

@arik-so arik-so left a comment

Choose a reason for hiding this comment

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

Looks good, with the same questions that @valentinewallace raised.

@TheBlueMatt TheBlueMatt merged commit 3111508 into lightningdevkit:main Aug 21, 2024
19 of 21 checks passed
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