Skip to content
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

[minor] Add Display to Payment ID types #2492

Merged
merged 4 commits into from
Aug 23, 2023

Conversation

optout21
Copy link
Contributor

@optout21 optout21 commented Aug 12, 2023

Minor convenience/housekeeping change:

  • Added Display trait to PaymentHash, PaymentId, PaymentPreimage
  • Reduced usage of log_bytes!()

Almost all remaining log_bytes! usage is for ChannelId, which is addressed in #2485 .
(The log_bytes! macro is OK, but its usage suggests non-type-safe usage, plus it reduces readablity a bit).

@optout21 optout21 marked this pull request as ready for review August 12, 2023 09:55
@codecov-commenter
Copy link

codecov-commenter commented Aug 12, 2023

Codecov Report

Patch coverage: 81.53% and project coverage change: -0.07% ⚠️

Comparison is base (8f02430) 90.59% compared to head (4146264) 90.53%.
Report is 33 commits behind head on main.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2492      +/-   ##
==========================================
- Coverage   90.59%   90.53%   -0.07%     
==========================================
  Files         106      107       +1     
  Lines       56525    56923     +398     
  Branches    56525    56923     +398     
==========================================
+ Hits        51207    51533     +326     
- Misses       5318     5390      +72     
Files Changed Coverage Δ
lightning/src/ln/inbound_payment.rs 91.72% <50.00%> (ø)
lightning/src/ln/outbound_payment.rs 89.74% <71.42%> (-0.12%) ⬇️
lightning/src/ln/channelmanager.rs 87.19% <77.77%> (+0.02%) ⬆️
lightning/src/ln/channel.rs 89.78% <87.50%> (-0.02%) ⬇️
lightning-invoice/src/utils.rs 97.67% <100.00%> (ø)
lightning/src/chain/channelmonitor.rs 94.72% <100.00%> (-0.05%) ⬇️
lightning/src/ln/mod.rs 96.15% <100.00%> (+1.15%) ⬆️
lightning/src/routing/gossip.rs 90.01% <100.00%> (+0.02%) ⬆️

... and 21 files with indirect coverage changes

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

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

LGTM, except the allocations.

lightning/src/ln/mod.rs Outdated Show resolved Hide resolved
@TheBlueMatt
Copy link
Collaborator

Feel free to squash the fixup commit down into the original commit to not have two commits back-to-back that edit the same code.

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

LGTM after squash.

@optout21
Copy link
Contributor Author

Rebased and reorganized commits, as suggested, to avoid touching the same code from multiple commits. Commits: add Display to PaymentHash (most frequently used), adapt logging, add Display to PaymentId and PaymentPreimage, adapt logging.
Please reconsider for review.

TheBlueMatt
TheBlueMatt previously approved these changes Aug 22, 2023
@valentinewallace
Copy link
Contributor

Missed a few in channelmanager:

diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index 51f9b7914..db8de796f 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -6331,10 +6331,10 @@ where
                                match monitor_event {
                                        MonitorEvent::HTLCEvent(htlc_update) => {
                                                if let Some(preimage) = htlc_update.payment_preimage {
-                                                       log_trace!(self.logger, "Claiming HTLC with preimage {} from our monitor", log_bytes!(preimage.0));
+                                                       log_trace!(self.logger, "Claiming HTLC with preimage {} from our monitor", preimage);
                                                        self.claim_funds_internal(htlc_update.source, preimage, htlc_update.htlc_value_satoshis.map(|v| v * 1000), true, funding_outpoint);
                                                } else {
-                                                       log_trace!(self.logger, "Failing HTLC with hash {} from our monitor", log_bytes!(htlc_update.payment_hash.0));
+                                                       log_trace!(self.logger, "Failing HTLC with hash {} from our monitor", htlc_update.payment_hash);
                                                        let receiver = HTLCDestination::NextHopChannel { node_id: counterparty_node_id, channel_id: funding_outpoint.to_channel_id() };
                                                        let reason = HTLCFailReason::from_failure_code(0x4000 | 8);
                                                        self.fail_htlc_backwards_internal(&htlc_update.source, &htlc_update.payment_hash, &reason, receiver);

@optout21
Copy link
Contributor Author

Missed a few in channelmanager:

Indeed, good catch! I've searched through all log_bytes! occurences, but apparently I've missed these two (maybe changed with last rebase). Fixed (included in same commit).

@jbesraa
Copy link
Contributor

jbesraa commented Aug 23, 2023

looks good!
feel free to squash "add" and "use" commits

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

LGTM

@valentinewallace valentinewallace merged commit 0c25046 into lightningdevkit:main Aug 23, 2023
14 checks passed
@optout21 optout21 deleted the payment-hash-display branch August 27, 2023 06:40
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.

None yet

6 participants