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

Add HTLCHandlingFailed event #1403

Merged

Conversation

jurvis
Copy link
Contributor

@jurvis jurvis commented Apr 2, 2022

Addresses #1392

When forward_htlcs is empty, forward_event does not get set, so I assume that means that represents an instance where forwarding has failed since we have no HTLCs to forward (?). may be completely off here.

if possible, I will like some help finding the test where this event is suppose to be called 😄 thanks!

edit: functional_tests helped me find those failing tests 😅 will fix

@jurvis
Copy link
Contributor Author

jurvis commented Apr 3, 2022

hey @TheBlueMatt, some of the tests affected by this change use the expect_pending_htlcs_forwardable_ignore! macro that hardcodes a count of events it expects to 1.

this makes sense; since we only send the PendingHTLCsForwardable event once when we fail backward. however, we probably need a new macro for expecting potentially the additional count of PaymentForwardingFailed events. Before I work on this change, I just wanted to ask and see if you may be aware of a better way of doing this + if the place in ChannelManager where I push PaymentForwardedFailed even makes sense at this current moment.

thanks!

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.

As for the test macros/updates, yes, this kind of change tends to end up with a ton of test changes spewn throughout. Hopefully my comment below may make it simplier (actually just update the expect_pending_htlcs_forwardable_ignore/expect_pending_htlcs_forwardable macro(s) to detect the new event, with either a new argument to indicate at the test-sites if its required or something like PaymentFailedConditions to set a list of conditions and pass that in.

lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
@jurvis
Copy link
Contributor Author

jurvis commented Apr 3, 2022

@TheBlueMatt got it! thanks for the guidance 😄

@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch from 2b96fe0 to d16f1aa Compare April 7, 2022 05:53
@codecov-commenter
Copy link

codecov-commenter commented Apr 7, 2022

Codecov Report

Merging #1403 (6c5af58) into main (5cca9a0) will increase coverage by 0.90%.
The diff coverage is 92.24%.

❗ Current head 6c5af58 differs from pull request most recent head 8f0d9b0. Consider uploading reports for the commit 8f0d9b0 to get more accurate results

@@            Coverage Diff             @@
##             main    #1403      +/-   ##
==========================================
+ Coverage   90.87%   91.77%   +0.90%     
==========================================
  Files          80       80              
  Lines       44645    49595    +4950     
  Branches    44645    49595    +4950     
==========================================
+ Hits        40569    45518    +4949     
- Misses       4076     4077       +1     
Impacted Files Coverage Δ
lightning/src/chain/mod.rs 68.18% <ø> (ø)
lightning/src/util/events.rs 39.50% <46.15%> (-0.04%) ⬇️
lightning/src/ln/channelmanager.rs 87.99% <83.92%> (+2.90%) ⬆️
lightning/src/ln/functional_tests.rs 98.30% <97.70%> (+1.20%) ⬆️
lightning/src/chain/chainmonitor.rs 97.97% <100.00%> (+0.01%) ⬆️
lightning/src/chain/channelmonitor.rs 90.97% <100.00%> (+0.01%) ⬆️
lightning/src/ln/chanmon_update_fail_tests.rs 97.71% <100.00%> (ø)
lightning/src/ln/channel.rs 88.78% <100.00%> (+0.03%) ⬆️
lightning/src/ln/functional_test_utils.rs 96.78% <100.00%> (+1.54%) ⬆️
lightning/src/ln/monitor_tests.rs 100.00% <100.00%> (ø)
... and 14 more

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 5cca9a0...8f0d9b0. Read the comment docs.

Copy link
Contributor Author

@jurvis jurvis left a comment

Choose a reason for hiding this comment

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

I think I have implemented this PR to the fullest of my knowledge of how things work... I added some comments in places I want to call out because I'm not 100% confident of them.

Also need some help in places, specifically with identifying when to not send our node_id as the sink_node_id

lightning/src/ln/functional_test_utils.rs 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_tests.rs Show resolved Hide resolved
lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
@jurvis jurvis marked this pull request as ready for review April 10, 2022 16:08
@jurvis
Copy link
Contributor Author

jurvis commented Apr 14, 2022

update: still working on this PR. stepping away to catch up with some other deadlines. hope to make my next iteration by end of the week :)

@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch 2 times, most recently from a5a23df to bb6d9bd Compare April 20, 2022 14:59
@TheBlueMatt
Copy link
Collaborator

Looks like this is starting to shape up! Let me know when you want another round of review on this.

@jurvis
Copy link
Contributor Author

jurvis commented Apr 23, 2022

@TheBlueMatt yeah I just got a little stuck finding the counterparty_node_id at some of the fail_htlc_backwards_internal call-sites and had a question in an old comment thread: #1403 (comment)

@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch 2 times, most recently from 0c07c76 to 6bb663f Compare May 7, 2022 23:10
@jurvis
Copy link
Contributor Author

jurvis commented May 7, 2022

@TheBlueMatt not a PR I have super high confidence about getting right the first time, but will like to see how I can improve :D

@jurvis jurvis requested a review from TheBlueMatt May 7, 2022 23:59
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.

A number of comments about data provided and structure before I jump into reviewing all the creation sites for correctness.

lightning/src/util/events.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channel.rs Outdated Show resolved Hide resolved
lightning/src/ln/channelmanager.rs Outdated Show resolved Hide resolved
@jkczyz jkczyz self-requested a review May 17, 2022 14:49
@TheBlueMatt
Copy link
Collaborator

Looks like this needs rebase.

@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch 4 times, most recently from 3b6131d to 7b52102 Compare June 3, 2022 02:30
@jurvis
Copy link
Contributor Author

jurvis commented Jul 15, 2022

Please don't rebase PRs unless there's a conflict, it makes it very difficult to track changes to the PR vs upstream.

oops, sorry. thought I was being helpful, lol.

@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch from 8e21ce2 to d6e0d0e Compare July 17, 2022 05:25
@jurvis
Copy link
Contributor Author

jurvis commented Jul 17, 2022

@TheBlueMatt I saw your comment in my email notifications but can't find it on GitHub for this line

you said:

Rather than asserting that the destination is in the expected set, lets assert that the destination is exactly the last entry in the destination vec, and remove it from the vec.

I'm looking to correct this, but when you say that "the destination is exactly the last entry in the destination vec," is this what you mean?:

$crate::util::events::Event::HTLCHandlingFailed { ref failed_next_destination, .. } => {
	let destination = destinations.pop().unwrap();
	assert_eq!(&destination, failed_next_destination);
},

because that seems to imply that the event order when calling get_and_clear_pending_events() is in reverse chronological order, but I don't think that's how it is right now 🤔 or am I misunderstanding something?

@TheBlueMatt
Copy link
Collaborator

Yea, sorry, I deleted that comment because I'm not sure we need/want tests to assert on a precise event ordering given a set of HTLCs get failed at the same time. In general we do want to avoid tests that just check that each of a series of events is in some set - we want to make sure all of the set get returned - but we don't want to be overly prescriptive in event ordering in case we change it in the future.

@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch from d6e0d0e to 145e500 Compare July 18, 2022 02:36
TheBlueMatt
TheBlueMatt previously approved these changes Jul 18, 2022
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.

Code changes look good. Please make sure to wrap your commit messages (including descriptions) at 70-80 lines long.

lightning/src/util/events.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

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

Largely looks good. Just a bunch of nits.

lightning/src/util/events.rs Outdated Show resolved Hide resolved
lightning/src/util/events.rs Outdated Show resolved Hide resolved
lightning/src/util/events.rs Outdated Show resolved Hide resolved
lightning/src/util/events.rs Outdated Show resolved Hide resolved
lightning/src/util/events.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
lightning/src/ln/functional_test_utils.rs Outdated Show resolved Hide resolved
lightning/src/chain/chainmonitor.rs Outdated Show resolved Hide resolved
lightning/src/ln/functional_test_utils.rs Outdated Show resolved Hide resolved
@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch from 9f5b999 to 62c907f Compare July 19, 2022 17:37
@TheBlueMatt TheBlueMatt self-assigned this Jul 19, 2022
@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch from 62c907f to 6c5af58 Compare July 19, 2022 23:21
@jurvis
Copy link
Contributor Author

jurvis commented Jul 19, 2022

cleaned up commit messages

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.

Code LGTM, some doc notes but this should be basically ready.

lightning/src/util/events.rs Show resolved Hide resolved
lightning/src/util/events.rs Outdated Show resolved Hide resolved
lightning/src/util/events.rs Outdated Show resolved Hide resolved
lightning/src/util/events.rs Outdated Show resolved Hide resolved
@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch from 6c5af58 to 5410e4a Compare July 22, 2022 00:38
@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch from 5410e4a to 205aef4 Compare July 22, 2022 20:43
lightning/src/util/events.rs Outdated Show resolved Hide resolved
lightning/src/util/events.rs Outdated Show resolved Hide resolved
lightning/src/util/events.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
Adds a HTLCHandlingFailed that expresses failure by our node to process
a specific HTLC. A HTLCDestination enum is defined to express the
possible cases that causes the handling to fail.
@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch from 205aef4 to 8f0d9b0 Compare July 25, 2022 17:23
We add `HTLCHandlingFailedConditions` to express the failure parameters,
that will be enforced by a new macro, `expect_pending_htlcs_forwardable_conditions`.
@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch from 8f0d9b0 to 3a7844a Compare July 25, 2022 17:29
In `ChannelManager::fail_htlc_backwards_internal`, we push a `HTLCHandlingFailed`
containing some information about the HTLC
@jurvis jurvis force-pushed the jurvis/add-paymentforwardingfailed-event branch from 3a7844a to ac842ed Compare July 25, 2022 18:29
@jkczyz jkczyz merged commit f0b8189 into lightningdevkit:main Jul 26, 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.

None yet

5 participants