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

Trampoline client to delegate payments to the LSP #475

Merged
merged 16 commits into from
Aug 12, 2024

Conversation

nepet
Copy link
Collaborator

@nepet nepet commented Jul 4, 2024

Adds a custom trampoline client to gl-plugin to enable custom trampoline payments via breez on greenlight. This covers basic functionality and basic tests.

This PR also resolves #470

@nepet nepet force-pushed the 202423-trampoline-client branch 4 times, most recently from 0c5646b to 3c91b2e Compare July 8, 2024 13:07
@nepet nepet force-pushed the 202423-trampoline-client branch 2 times, most recently from 09bb268 to de0a9f9 Compare July 8, 2024 16:18
@nepet nepet marked this pull request as ready for review July 9, 2024 10:08
@nepet nepet force-pushed the 202423-trampoline-client branch from b29397b to 26a4819 Compare July 9, 2024 10:55
@cdecker cdecker changed the title 202423 trampoline client Trampoline client to delegate payments to the LSP Jul 9, 2024
@nepet nepet force-pushed the 202423-trampoline-client branch from 26a4819 to cb2507f Compare July 9, 2024 12:12
cdecker
cdecker previously approved these changes Jul 9, 2024
Copy link
Collaborator

@cdecker cdecker left a comment

Choose a reason for hiding this comment

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

Very nice, I like the tests too, they cover quite a bit of surface 👍

libs/proto/glclient/greenlight.proto Outdated Show resolved Hide resolved
libs/proto/glclient/greenlight.proto Outdated Show resolved Hide resolved
libs/gl-plugin/build.rs Show resolved Hide resolved
libs/gl-plugin/src/tramp.rs Show resolved Hide resolved
libs/gl-plugin/src/tramp.rs Outdated Show resolved Hide resolved
libs/gl-plugin/src/tramp.rs Outdated Show resolved Hide resolved
libs/gl-plugin/src/tramp.rs Show resolved Hide resolved
libs/gl-plugin/src/node/mod.rs Show resolved Hide resolved
libs/gl-client-py/tests/plugins/trmp_htlc_hook.py Outdated Show resolved Hide resolved
libs/gl-client-py/tests/test_plugin.py Outdated Show resolved Hide resolved
@cdecker
Copy link
Collaborator

cdecker commented Jul 10, 2024

Now the linguist annotations work 👍

@nepet nepet force-pushed the 202423-trampoline-client branch from 07b7492 to 9b8603e Compare July 11, 2024 16:56
@nepet
Copy link
Collaborator Author

nepet commented Jul 11, 2024

Rebased on main and switched over to call_raw() for sendpay

@JssDWt
Copy link
Collaborator

JssDWt commented Jul 13, 2024

Documenting here that there is an issue where the breez sdk gets a transport error from the trampoline_pay call when the trampoline payment succeeds.

Other things I was wondering are:

  • does this function have the same checks as the pay command in terms of requests waiting for the node to be ready?

@nepet nepet force-pushed the 202423-trampoline-client branch 2 times, most recently from ec2d252 to 7977109 Compare July 25, 2024 11:42
libs/gl-client-py/glclient/glclient.pyi Show resolved Hide resolved
libs/gl-client-py/tests/test_plugin.py Outdated Show resolved Hide resolved
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SendpayRequest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm surprised this is necessary, shouldn't we have a Pay request like this already in cln-rpc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have this in cln-rpc but on 0.1.8 it does not include payment_metadata so I copied it and add the extra field.

@nepet
Copy link
Collaborator Author

nepet commented Jul 25, 2024

I squashed the two proto commits into one to be able to separately cherry-pick it.

nepet added 8 commits July 29, 2024 17:46
In the past we had problems with github showing copied files as changes.
This is somewhat annoying and we wan to skip those duplicate changes.
The attributes had been set already but github ignored them. Hopefully
these syntactical changes help github to understand the file.

Signed-off-by: Peter Neuroth <[email protected]>
We need to access the SerializedTlvStream also for the trampoline_pay
command in future commits. This commit moves the struct and all
associated commits and helper functions into their own module.

Signed-off-by: Peter Neuroth <[email protected]>
This commits enables trampoline pay on the signer. It teaches the signer
about the message and allows to call PreapproveInvoice during a
trampoline pay request. Calling PreapproveInvoice allows us to call
send_pay on the invoice in later commits.

Signed-off-by: Peter Neuroth <[email protected]>
This commit adds a derive to the TrampolinePayRequest in order to be
able to serialize and deserialize it via serde. This allows to use those
messages as json::Value's directly.

Signed-off-by: Peter Neuroth <[email protected]>
This commit adds a core-lightning rpc method for trampoline payments to
gl-plugin. This variant of trampoline payments works as follows: We hand
over one or many htlcs to a peer node that is a trampoline node. The htlcs have a
litte extra on the amount and the trampoline node can then search for a
route and complete the payment. Once the payment is completed the
trampoline node will resolve the pending htlcs. We use multiple htlcs if
the initiating node shares multiple channels with the trampoline node
and if the amount is bigger than what can be send through one channel.

Signed-off-by: Peter Neuroth <[email protected]>
This commit adds trampoline pay to the python library to allow for
testing of the implementation. We also add some basic checks.

Signed-off-by: Peter Neuroth <[email protected]>
nepet added 7 commits July 29, 2024 17:46
Instead of running trampoline_pay on the plugin and wire it up through a
custom rpc command we can actually just perform trampoline_pay directly.

Signed-off-by: Peter Neuroth <[email protected]>
Signed-off-by: Peter Neuroth <[email protected]>
We of course need to send the amount that is to be sent to the receiver not the amount including the overpayment for the trampoline node.

Signed-off-by: Peter Neuroth <[email protected]>
Signed-off-by: Peter Neuroth <[email protected]>
This commit adds `trampoline_pay_keepalive` to the greenlight grpc node
client. This version does exactly the same as `trampoline_pay` but
streams log messages from the node as long as `trampoline_pay` is
inflight, in order to keep the connection busy.

Signed-off-by: Peter Neuroth <[email protected]>
@nepet nepet force-pushed the 202423-trampoline-client branch from 1b14fe6 to 6606973 Compare July 29, 2024 15:47
Currently we can not handle custom errors returned by the server
directly as CLN does not understand the error codes (NODE|25, PERM|27)
that signal termporary and permanent failures on the trampoline server.

This is an internediate step where we at least pass down an error
message that reflects a server failure in the meantime.

Signed-off-by: Peter Neuroth <[email protected]>
@cdecker
Copy link
Collaborator

cdecker commented Aug 12, 2024

ACK 3cd3b50

@cdecker cdecker merged commit 43f0220 into main Aug 12, 2024
13 checks passed
@cdecker cdecker deleted the 202423-trampoline-client branch August 12, 2024 15:11
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.

misc: Mark the .proto files in .resources as derived
3 participants