Skip to content

Do not always persist ChannelManager on channel_update messages #972

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

Conversation

TheBlueMatt
Copy link
Collaborator

Based on #965 as it fixes a bug which would make this PR useless.

If we receive a channel_update message for a channel unrelated to
our own, we shouldn't trigger a persistence of our
ChannelManager. This avoids significant persistence traffic during
initial node startup.

@TheBlueMatt TheBlueMatt added this to the 0.0.99 milestone Jun 28, 2021
@codecov
Copy link

codecov bot commented Jun 28, 2021

Codecov Report

Merging #972 (803da87) into main (f472907) will decrease coverage by 0.10%.
The diff coverage is 94.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #972      +/-   ##
==========================================
- Coverage   90.63%   90.52%   -0.11%     
==========================================
  Files          60       60              
  Lines       30538    30654     +116     
==========================================
+ Hits        27678    27750      +72     
- Misses       2860     2904      +44     
Impacted Files Coverage Δ
lightning/src/ln/peer_handler.rs 46.73% <ø> (ø)
lightning/src/ln/channelmanager.rs 84.69% <94.59%> (+0.79%) ⬆️
lightning/src/ln/channel.rs 88.51% <100.00%> (ø)
lightning/src/util/events.rs 15.15% <0.00%> (-2.15%) ⬇️
lightning/src/ln/functional_tests.rs 97.21% <0.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f472907...803da87. Read the comment docs.

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.

Unit test would be cool if it's easy, otherwise LGTM

let node_b_chan_info = nodes[1].node.list_channels()[0].clone();

// The first two nodes (which opened a channel) should now require fresh persistence
assert!(nodes[0].node.await_persistable_update_timeout(Duration::from_millis(1)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if by design, but don't think this test covers the DoPersist case: https://i.imgur.com/7fAhVOh.png

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 not sure what I'm looking at there, but if not that's a bug - await_persistable_update_timeout is supposed to return true only if we have a reason to persist.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just meant that the test doesn't cover the case where we do want to persist after handling a channel update

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, yes, sorry. As I was writing the test I found another bug, so the test is finished in the last commit at #949.

If we receive a `channel_update` message for a channel unrelated to
our own, we shouldn't trigger a persistence of our
`ChannelManager`. This avoids significant persistence traffic during
initial node startup.
@TheBlueMatt TheBlueMatt force-pushed the 2021-06-skip-notify-chansync branch from b7d249a to 803da87 Compare June 30, 2021 16:13
@TheBlueMatt
Copy link
Collaborator Author

Squashed without diff:

$ git diff-tree -U1 b7d249ab 803da875
$

@@ -288,7 +288,7 @@ impl HTLCCandidate {
}

/// Information needed for constructing an invoice route hint for this channel.
#[derive(Clone)]
#[derive(Clone, Debug, PartialEq)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of implementing PartialEq, test that fee_base_msat hasn't changed.

Copy link
Collaborator Author

@TheBlueMatt TheBlueMatt Jun 30, 2021

Choose a reason for hiding this comment

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

I think its generally a good thing to have either way - its a public struct and its reasonable for users to want to compare it? If you disagree we can change it in a followup.

@TheBlueMatt TheBlueMatt merged commit 57e813f into lightningdevkit:main Jun 30, 2021
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