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

send warning when we receive a old commitment transaction #1430

Conversation

vincenzopalazzo
Copy link
Contributor

@vincenzopalazzo vincenzopalazzo commented Apr 18, 2022

During a channel_reestablish now we send a warning message when we receive an old commitment transaction.

Fixes #1207 with the following consideration lightning/bolts#934 (comment)

@vincenzopalazzo vincenzopalazzo force-pushed the macros/channel_reestablish_v2 branch 5 times, most recently from 7ae6fdc to fc33225 Compare April 22, 2022 10:15
@vincenzopalazzo vincenzopalazzo changed the title send warning when we have a old commitment transaction send warning when we receive a old commitment transaction Apr 22, 2022
@vincenzopalazzo vincenzopalazzo force-pushed the macros/channel_reestablish_v2 branch 2 times, most recently from c70e6d3 to d04ca27 Compare April 22, 2022 11:10
@codecov-commenter
Copy link

codecov-commenter commented Apr 22, 2022

Codecov Report

Merging #1430 (e6300da) into main (171dfee) will increase coverage by 0.46%.
The diff coverage is 88.57%.

@@            Coverage Diff             @@
##             main    #1430      +/-   ##
==========================================
+ Coverage   90.89%   91.36%   +0.46%     
==========================================
  Files          75       75              
  Lines       41657    43716    +2059     
  Branches    41657    43716    +2059     
==========================================
+ Hits        37866    39941    +2075     
+ Misses       3791     3775      -16     
Impacted Files Coverage Δ
lightning/src/ln/channel.rs 92.57% <75.00%> (+4.18%) ⬆️
lightning/src/ln/functional_tests.rs 97.40% <92.59%> (+0.22%) ⬆️
lightning/src/ln/reorg_tests.rs 100.00% <0.00%> (ø)
lightning/src/util/config.rs 48.35% <0.00%> (+3.45%) ⬆️

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 171dfee...e6300da. Read the comment docs.

@vincenzopalazzo vincenzopalazzo marked this pull request as ready for review April 22, 2022 11:51
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
Copy link
Contributor Author

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

OK! I tried to make a little bit of refactoring and applied the changes that you suggested.

The only think that is unclear to me right now, is this case

https://github.com/lightningdevkit/rust-lightning/blob/main/lightning/src/ln/channel.rs#L3708-L3712

Why in this case there is a CloseDelayBroadcast why does mean? i was not able to find some comments about the meaning, and I didn't check if the spec has some info about this case!

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.

Sorry for the delay in reviewing this!

lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_test_utils.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_test_utils.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_test_utils.rs Outdated Show resolved Hide resolved
@vincenzopalazzo
Copy link
Contributor Author

Rebased on master, I reorganized the test in a more clean way where the different cases are executed at the end of the function. In this way, it is cleaner to the reader what we are trying to do!

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.

Awesome! One note - we don't like having intermediate commits that fail tests. We don't test for it in CI (only that it compiles), but if at all possible try to make sure each individual commit passes tests as well, ensuring we can git bisect easily.

lightning/src/ln/functional_test_utils.rs Outdated Show resolved Hide resolved
@vincenzopalazzo vincenzopalazzo force-pushed the macros/channel_reestablish_v2 branch 2 times, most recently from 53d7cda to 8931516 Compare April 28, 2022 15:49
@vincenzopalazzo
Copy link
Contributor Author

we don't like having intermediate commits that fail tests. We don't test for it in CI (only that it compiles), but if at all possible try to make sure each individual commit passes tests as well, ensuring we can git bisect easily.

Sorry! I rebased and squash the commit in a single one!

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.

Basically looks good, one comment on the second branch of the test.

lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
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!

lightning/src/ln/functional_tests.rs Show resolved Hide resolved
lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
@vincenzopalazzo vincenzopalazzo force-pushed the macros/channel_reestablish_v2 branch 2 times, most recently from d3651e1 to 833a74e Compare May 3, 2022 12:58
@TheBlueMatt
Copy link
Collaborator

Hmm, was there a conflict? In general please avoid rebase'ing unless there's a conflict with the current upstream git.

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.

Basically LGTM, lets get another reviewer.

lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_tests.rs Outdated Show resolved Hide resolved
@vincenzopalazzo
Copy link
Contributor Author

I clean up the code and remove the enum. thanks, @valentinewallace to point me on this, and also for the grammar mistake!

I also rebased on top of the last master!

@TheBlueMatt
Copy link
Collaborator

I also rebased on top of the last master!

Generally please avoid this unless there is a conflict. Rebases make it harder to diff-tree and see changes to a PR, range-diff can be a bit more finicky and hard to read.

@vincenzopalazzo
Copy link
Contributor Author

Ops! sorry @TheBlueMatt

@vincenzopalazzo vincenzopalazzo force-pushed the macros/channel_reestablish_v2 branch 2 times, most recently from 6ecb4d6 to 040b3cd Compare May 3, 2022 23:01
During a `channel_reestablish` now we send a warning message when we receive a old commitment transaction from the peer.

In addition, this commit include the update of functional test to make sure that the receiver will generate warn messages.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
@TheBlueMatt TheBlueMatt merged commit 9fbafd4 into lightningdevkit:main May 4, 2022
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.

Don'e force-close if a peer is behind our latest state on reestablish
4 participants