Control Tower: Sender-side checks for duplicate payments #2#1719
Conversation
c03cd00 to
f8b8f65
Compare
|
@vapopov rebased w/ split commits |
|
I've also added a In the future, we can default to the stricter state machine once we are confident that old payment states have been resolved/cleanedup. |
8bc06ae to
9e0ac3c
Compare
|
Correcting what I said earlier, I did end up making changes that inspect the circuit map and mark all locally sourced payment hashes as inflight |
0f00102 to
a1619cd
Compare
|
Noticed that the performance hit of doing serial state transitions caused the async_payment_benchmark to timeout. In response, three commits have been added, which:
|
a1619cd to
c86cc22
Compare
Roasbeef
left a comment
There was a problem hiding this comment.
Moving onto testing this as is locally (the latest set of the diff). Will do one final pass over the logic in the switch to ensure things are being updated properly in a few edge cases.
There was a problem hiding this comment.
Nice! I forget at times that we have the infra to test the pre and post migration state.
There was a problem hiding this comment.
Could use a comment here explaining what "strict" mode entails.
e2d9c36 to
c945002
Compare
for Settle/Fail responses.
by reading the payment hash from the circuit map.
in the circuit map are marked StatusInFlight. We also check that hashes contained in forwarded circuits are not updated.
This commit splits FetchPaymentStatus and UpdatePaymentStatus, such that they each invoke helper methods that can be composed into different db txns. This enables us to improve performance on send/receive, as we can remove the exclusive lock from the control tower, and allow concurrent calls to utilize Batch more effectively.
Composes the new payment status helper methods such that we only require one db txn per state transition. This also allows us to remove the exclusive lock from the control tower, and enable more concurrent requests.
c945002 to
0b6f8bb
Compare
This commit moves the logic handling responses to locally-initiated payments to be asynchronous. The reordering of operations into handleLocalDispatch brings a serious performance burden to the switch's main event loop. However, the at-most once semantics of circuit map and idempotency of cleanup methods allows concurrent operations to run in parallel. Prior to this commit, the async_payments_benchmark would timeout due to the forcibly serial nature of the prior design. With this change, there is no perceptible difference in the benchmark OMM, even though we've added two extra db calls.
0b6f8bb to
9c5c1d0
Compare
Roasbeef
left a comment
There was a problem hiding this comment.
LGTM 🎩
Tested on both mainnet and testnet!
| // If the provided payment is nil, we have discarded the error decryptor | ||
| // due to a restart. We'll return a fixed error and signal a temporary | ||
| // channel failure to the router. | ||
| case payment == nil: |
|
Great work on this @vapopov 🎉 |
This PR is an extension of #1070, mostly just touching up documentation. The only thing that is new in the PR is the reordering of logic w/in
handleLocalDispatch, which should result in better clean up of circuits and fwd references. This was going to be done in a separate PR, but the changes were overlapping enough that I made them here.FIxes #973.