-
Notifications
You must be signed in to change notification settings - Fork 267
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 singleton actor AsyncPaymentTriggerer
to monitor when the receiver of an async payment reconnects
#2491
Conversation
4b286a2
to
a1bd1b4
Compare
Codecov Report
@@ Coverage Diff @@
## master #2491 +/- ##
==========================================
+ Coverage 85.11% 85.24% +0.12%
==========================================
Files 203 204 +1
Lines 16081 16107 +26
Branches 706 689 -17
==========================================
+ Hits 13688 13731 +43
+ Misses 2393 2376 -17
|
AsyncPaymentTrigger
to monitor when the receiver of an async payment reconnects AsyncPaymentTriggerer
to monitor when the receiver of an async payment reconnects
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.
Looks good to me, the design is clean and test coverage looks good.
I did some refactoring and renaming in ac5118b, let me know what you think.
I'll update #2464 to allow disabling the timeout, I think it's useful to have. I'll do it slightly differently than what you did, I think using an Option
is more explicit than an infinite duration.
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggererSpec.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala
Show resolved
Hide resolved
839f406
to
bfdb294
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, we should be able to integrate this once we integrate #2464, good job 👍
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/NodeRelay.scala
Outdated
Show resolved
Hide resolved
026ea4e
to
c72c6be
Compare
Do we need to add Otoh, we will need a way for a node that creates an async payment to cancel a pending payment queued by the trampoline node they designated to hold it. This will likely be accomplished with a custom onion message, but could also be a custom Lightning Message. |
I think you should indeed rollback 0c7b049 I think there is a confusion between the sender node and the relaying node here. Cancelling an async payment is done by the sender node telling the relaying node to abort the payment via a custom lightning message or an onion message. The API is for the relaying node operator, but it's not their decision to cancel async payments. I don't think you should add anything else to this PR, it's just making it harder to review. Follow-up work (e.g. adding the custom |
This reverts commit 0c7b049.
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/NodeRelay.scala
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala
Outdated
Show resolved
Hide resolved
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! This seems pretty robust and well tested now 👍
The new
AsyncPaymentTriggerer
singleton actor spawns only a singlePeerReadyNotifier
actor for each peer that is watched. This prevents multiple actors from redundantly polling for when the same peer reconnects.Each
Watcher
for a given peer triggers a specific async payment (managed by aNodeRelay
actor) and has a unique timeout (in block height). TheNodeRelay
actor will receive anAsyncPaymentTriggered
when the target peer reconnects, orAsyncPaymentTimeout
if the timeout block height is reached.This PR requires a change to allow
PeerReadyNotifier
to have an infinite timeout so thatAsyncPaymentTriggerer
can instead manage multiple timeouts for a given peer.The
AsyncPaymentTriggerer
singleton must be created before theRelayer
actor is created, but requires a reference to the singletonSwitchboard
actor to spawnPeerReadyNotifier
actors. Because the swtichboard is indirectly instantiated with theRelayer
reference (viaPeerFactory
andChannelFactory
), theAsyncPaymentTriggerer
actor must be further initialized by sending aStart
message with theSwitchboard
actor reference before being used.In the future the
AsyncPaymentTriggerer
actor can be extended to watch for onion messages from async payment receivers, instead of only watching for local peer re-connections. In the onion message case, thepaymentHash
will be used to identify whichWatcher
to trigger.