Skip to content

Run rustfmt on chain/transaction, chain/chaininterface, max_payment_path_len_tests, and chanmon_update_fail_tests #3783

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 12 commits into from
Jun 12, 2025

Conversation

TheBlueMatt
Copy link
Collaborator

This formats ~36% of the remaining lines in */_tests.rs

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented May 18, 2025

👋 Thanks for assigning @joostjager as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@TheBlueMatt TheBlueMatt requested a review from joostjager May 18, 2025 21:37
joostjager
joostjager previously approved these changes May 19, 2025
Copy link
Contributor

@joostjager joostjager left a comment

Choose a reason for hiding this comment

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

Ack, though I'd say that these PRs carry some risk, and the potential benefits may not justify the costs.

.unwrap_err();
assert_eq!(err, RetryableSendFailure::RouteNotFound);

// If our payment_metadata contains 1 additional byte, we'll fail prior to pathfinding.
let mut recipient_onion_too_large_md = recipient_onion_max_md_size.clone();
recipient_onion_too_large_md.payment_metadata.as_mut().map(|mut md| md.push(42));
let err = nodes[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

For these formatting PRs, I think it is better to keep the formatting strictly separate from any other change. So that reviewers know what to look for in a commit.

This send_payment call is moved down, but as a reviewer I question myself whether it is just formatting or also something that changed functionally. I see it is now called with payment_hash_2 rather than payment_hash.

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'm confused, the commit "Run rustfmt on max_payment_path_len_tests.rs" only formats the file, changes happen in a separate commit.

Copy link
Contributor

@joostjager joostjager Jun 12, 2025

Choose a reason for hiding this comment

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

I understand the confusion. Rustfmt is indeed separate and fine.

The comment was directly specifically at the clean up in this commit. Most of the changes are variable extractions for which it is easy to see that nothing changed functionally.

The change here is also moving things around. To review that, a more careful look is needed. Can't just look at the lines touched, but also need the context around it.

My point is that it could be helpful for reviewers to separate those two types of changes.

route_params.clone(),
Retry::Attempts(0),
)
.send_payment(payment_hash, max_sized_onion.clone(), id, route_params.clone(), no_retry)
Copy link
Contributor

Choose a reason for hiding this comment

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

My opinion remains unchanged that this isn't necessary to reformat.

@@ -48,6 +48,9 @@ fn test_monitor_and_persister_update_fail() {
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);

let node_a_id = nodes[0].node.get_our_node_id();
Copy link
Contributor

@joostjager joostjager May 19, 2025

Choose a reason for hiding this comment

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

This commit, I think the change isn't worth it. A lot of manual checking for a modest reduction of lines of code (less than 10% on this file) and with changes that not everyone may agree benefit readability.

I've only spot-checked this commit. It looks fine, but we need to be aware that it carries some risk. If I had to produce a change like this I'd probably use search/replace/regex and then adding vars where the compiler complains. This may be easier than reviewing all of the 650 lines in this commit that have near-identical changes.

Not that reviewing needs to be easier than authoring necessarily, but it does raise a flag for me whether we should do it at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, it should be doable to validate the commit by running a regex to replace the new variables with the original copy then running a regex to remove the (correct) initialization lines (eg `s/let nodes[0].node.get_our_node_id() = nodes[0].node.get_our_node_id();$//' assuming the first regex replaced the variable name) and then check that the remaining commit is empty. Should be pretty easy to validate, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Reverse-engineering the replace doesn't sound particularly attractive to me. Then I'd much rather have commits that isolate search/replaces, with the actual commands in the commit message.

@@ -38,6 +38,13 @@ use crate::prelude::*;
use crate::sync::{Arc, Mutex};
use bitcoin::hashes::Hash;

fn get_latest_mon_update_id<'a, 'b, 'c>(
Copy link
Contributor

Choose a reason for hiding this comment

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

NIce one

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

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.

This needs a rebase it seems

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.

Also, seems fuzz is failing with:

thread '<unnamed>' panicked at /home/tnull/workspace/rust-lightning/lightning/src/chain/channelmonitor.rs:4439:7:
An unmature HTLC transaction conflicts with a maturing one; failed to call either transaction_unconfirmed for the conflicting transaction or block_disconnected for a block containing it.

@TheBlueMatt
Copy link
Collaborator Author

Apologies for the delay, rebased. The fuzz failure is #3756

Copy link
Contributor

@joostjager joostjager left a comment

Choose a reason for hiding this comment

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

LGTM with the side note that I only spot checked the mass edits. Assuming these were done mechanically and this is "just" test code, it might be sufficient?

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

I went through the edit commits and verified that the rustfmt commits didn't introduce any unexpected changes. I have to say the sheer size of the diff made this one somewhat tedious and painful to review (and I hope I didn't overlook anything).

IMO it would be preferable to go with the function-level rustfmt::skip approach for the remainder of the codebase, and make some more fine-grained progress over time before we bite the bullet and remove all remaining skips at some point.

Going ahead and landing this in-before it might get stale again.

)
.unwrap();
let init_msg = msgs::Init {
features: nodes[1].node.init_features(),
Copy link
Contributor

@tnull tnull Jun 12, 2025

Choose a reason for hiding this comment

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

This now reuses the nodes[1].init_features for both connections. Though, I assume this behavior change was introduced on pupose (also in a few other places).

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, was careful to only do it in cases where the configs for both nodes are identical.

@tnull tnull merged commit 217a5b0 into lightningdevkit:main Jun 12, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants