-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
htlcswitch: sync local payment hand-off to link #4183
htlcswitch: sync local payment hand-off to link #4183
Conversation
Faulty analysis. Nothing wrong with calculating the balance, I just printed the wrong number. |
b7be1bb
to
86a7a48
Compare
No attention paid to unit tests and itests yet. Looking for a concept ack. |
Wondering if there is a good reason to pass local sends through the event loop? |
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.
Of the options in # #4181, I prefer synchronous handoff to creating some workaround which tries to track pending balance deltas; that feels messy. There are always tradeoffs when making changes in the switch of course, but I think this change moves in the direction of less complexity, which I like a lot.
Not critical, but might also be worth thinking about how this would interact with an interceptor (eg #4018), since that is on the table for 0.11, if we do go ahead with this approach.
86a7a48
to
ab0cb46
Compare
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 changes, concept ACK from me. Should be gg after addressing carla's comments
htlcswitch/link.go
Outdated
hodlQueue: queue.NewConcurrentQueue(10), | ||
log: build.NewPrefixLog(logPrefix, log), | ||
quit: make(chan struct{}), | ||
downstreamIn: make(chan *downstreamMsg), |
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.
group with other downstream chnanel
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.
the other downstream chan isn't initialized here
Solid set of changes, the way you changed the switch was straightforward and actually reduced complexity. Before I read through the changes, I was worried there would be more complexity. LGTM upon travis pass |
2726fcd
to
38e1a94
Compare
Todo: itest fails because link does not cancel back local htlcs when commitment is full |
itest is now stuck on Makes sense because it relies on the mailbox to simulate resending of a packet. Maybe it is an option to modify the test to use three hops. Anyone suggestions on more direct ways to force a replay? |
Move creation of the goroutine as a preparation for sync local routing
4893eca
to
ab2bb78
Compare
Integration test fixed |
l.log.Tracef("received switch packet outkey=%v", pkt.outKey()) | ||
|
||
// Create a buffered result channel to prevent the link from blocking. | ||
errChan := make(chan error, 1) |
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.
Are we buffering this to account for the case where the link gets a shutdown instruction and stops listening, or to account for the time between this function sending and starting to listen?
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.
Yes, the former. If this function HandleLocalAddPacket
quits, the link event loop can't deliver the message anymore.
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 📊
ab2bb78
to
fe96330
Compare
Previously the forward(...) method was used in forwarding tests, while that code path isn't used for forwards in reality.
Embed forward method into SendHTLC and remove redundant type check.
There is no concurrent access in this code path, so there is no need to pass the call through the main event loop.
Deduplicate code and prepare for further split of handleDownstreamPkt.
Unroll common code to allow splitting in separate handlers per message type.
To be able to call just the UpdateAdd logic for synchronously handled local adds in a later commit.
This commit extends the link with a new synchronous delivery point for local UpdateAddHTLC messages. The switch method SendHTLC is updated to use this delivery point and thereby becomes a synchronous call. For MPP payments, synchronous hand-off is important. Otherwise the next pathfinding round could start without the channel balance updated yet.
Fixes a pre-existing issue where nil was returned when a failure had occurred during commiting of the circuit.
Align function name with the contained logic.
fe96330
to
8119dc7
Compare
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! Nice to see those refactors bundled in here that make the logic overall more readable 🔥
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.
Great change, really improves readability of this area. LGTM!
Potential unintended consequence of this change: #6485 |
This PR converts the switch and link to synchronous hand-off of local payments.
Tried it out on the mpp send payment itest. To make sure that the async hand-off would lead to an extra payment attempt, I added a 100 ms sleep in the link before adding the htlc to the channel.
This is the original timing diagram, which shows the temp. chan failure originating from ourselves (@ 0)
With sync hand-off, it looks like this:
Fixes #4181