-
Notifications
You must be signed in to change notification settings - Fork 411
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
Run rustfmt on chain/transaction
, chain/chaininterface
, max_payment_path_len_tests
, and chanmon_update_fail_tests
#3783
Conversation
👋 Thanks for assigning @joostjager as a reviewer! |
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.
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] |
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.
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
.
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'm confused, the commit "Run rustfmt
on max_payment_path_len_tests.rs
" only formats the file, changes happen in a separate commit.
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 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) |
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.
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(); |
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.
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.
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.
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?
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.
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>( |
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.
NIce one
👋 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. |
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.
This needs a rebase it seems
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.
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.
`assert_eq` is generally much better than `assert` for equality tests as it provides debug output of `a` and `b`.
1c48bf0
to
b9d0d60
Compare
Apologies for the delay, rebased. The fuzz failure is #3756 |
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 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?
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
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 skip
s 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(), |
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.
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).
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.
Yea, was careful to only do it in cases where the configs for both nodes are identical.
This formats ~36% of the remaining lines in
*/_tests.rs