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

Check peer features before attempting wake-up #2979

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented Jan 10, 2025

Before relaying a trampoline payment, we check if the next node is one of our direct peers. If that's the case, we check their features to see if they support waking up through notifications, in which case we go through the wake-up flow.

Note that we don't need this for channel relay, because:

  • if it is a Bolt 12 payment, the recipient will use a wallet_node_id to let us know that they support wake-up notifications
  • if it is a Bolt 11 payment, we use a custom short_channel_id for phoenix that also lets us know that they support wake-up notifications

@t-bast t-bast requested review from thomash-acinq and pm47 January 10, 2025 15:00
@thomash-acinq
Copy link
Member

Looks good, waiting for the rebase on #2978

@t-bast t-bast force-pushed the check-peer-features-before-wake-up branch from 9e98aa7 to 25d4cb6 Compare January 30, 2025 15:24
Before relaying a trampoline payment, we check if the next node is one
of our direct peers. If that's the case, we check their features to see
if they support waking up through notifications, in which case we go
through the wake-up flow.

Note that we don't need this for channel relay, because:

- if it is a Bolt 12 payment, the recipient will use a `wallet_node_id`
  to let us know that they support wake-up notifications
- if it is a Bolt 11 payment, we use a custom `short_channel_id` for
  phoenix that also lets us know that they support wake-up notifications
@t-bast t-bast force-pushed the check-peer-features-before-wake-up branch from 25d4cb6 to c193622 Compare February 12, 2025 13:43
@t-bast
Copy link
Member Author

t-bast commented Feb 12, 2025

Rebased now that #2978 has been merged!

case Some(walletNodeId) if nodeParams.peerWakeUpConfig.enabled => waitForPeerReady(upstream, walletNodeId, recipient, nextPayload, nextPacket_opt)
case walletNodeId_opt => relay(upstream, recipient, walletNodeId_opt, None, nextPayload, nextPacket_opt)
/** The next node may be a mobile wallet directly connected to us: in that case, we'll need to wake them up before relaying the payment. */
private def checkIfRecipientIsWallet(upstream: Upstream.Hot.Trampoline, recipient: Recipient, nextPayload: IntermediatePayload.NodeRelay, nextPacket_opt: Option[OnionRoutingPacket]): Behavior[Command] = {
Copy link
Member

Choose a reason for hiding this comment

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

It is currently not clear that checkIfRecipientIsWallet is actually checking preconditions for auto-wake up. I would also rename waitForPeerReady to attemptWakeUp.

Suggested change
private def checkIfRecipientIsWallet(upstream: Upstream.Hot.Trampoline, recipient: Recipient, nextPayload: IntermediatePayload.NodeRelay, nextPacket_opt: Option[OnionRoutingPacket]): Behavior[Command] = {
private def attemptWakeUpIfRecipientIsWallet(upstream: Upstream.Hot.Trampoline, recipient: Recipient, nextPayload: IntermediatePayload.NodeRelay, nextPacket_opt: Option[OnionRoutingPacket]): Behavior[Command] = {

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed in a50678e

@t-bast t-bast requested a review from pm47 February 12, 2025 14:45
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.

3 participants