-
Notifications
You must be signed in to change notification settings - Fork 116
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
rfq: creation initial version of RFQ last-mile negotiation module #683
Comments
TODOs
|
User StoryDiscussed deliverables with ffranr a bit Toying around with the idea that the architecture of the rfq manager might be coordinating many lnd node instances in which specifying a node identifier with the SCID. |
Negotiator subsystem (takes quote and ACK or NACK price) will need to extend
|
Let's shape the price oracle service here: #777 |
Overview
This is a master tracking issue towards the design and implementation of the
rfq
module withtapd
. Therqc
module will implement the abstract RFQ invoice last-mile invoice negotiation protocol outlined in the tap bLIP: lightning/blips#29. This section in particular outlines the current protocol flow draft: https://github.com/lightning/blips/blob/f60cfb7bdd6fa266f88b80f0f65a5d5541862ad6/blip-tap.md#rfq-negotiation.We can track this independently of any of the refactoring in
lnd
needed to expose hooks to modify the tapscript tree in each output as this module is nearly 100% independent of any of that logic.The bLIP defines 4 new messages:
tap_rfq
,tap_req_accept
, andtap_rfq_reject
. We can uselnd
's support for the sending+receiving custom messages to have this information be routed totapd
. By intercepting and sending these messages, twotapd
instances connected via an active p2p connection can exchange the information needed to agree upon a rate for sending/receiving payments.When it comes down to actually sending/receiving these HTLCs, we're able to once again re-use the existing RPCs that
lnd
offers.For receiving, we'll need to take the
rfq_id
value generated, map that to arfq_scid
then use that as thescid
for any created invoices. A set of new RPCs that give a caller more control over the active/sentscid
aliases will need to be created. Such RPCs and the invoice creation hook are out of the scope of this tracking issue.For sending, the very fist onion hop needs to add in a new custom TLV to inform the first hop node how to translate the incoming HTLC amt to the outgoing HTLC amount. The forwarding node can catch such HTLCs with the existing HTLC interceptor APIs. The sending node will need a new modified API that allows them to specify a custom TLV value for the first hop. This can already be done with the
BuiltRoute
andSendToRoute
API calls, but we'll want an easy way to just hook this into the normalSendPaymentV2
RPC calls. Tracking this unit of work is also outside of the scope of this tracking issue.Implementation
At a high level, the implementation will have the following components (not exhaustive, names to be considered place holders):
rfq
message stream. This will pass off the messages to the central control module. We'll call this theRfqStream
.HtlcInterceptor
logic to reject incoming HTLCs that don't match one of the quotes, or don't adhere to the quote exactly (under pays, etc). We'll call this theRfqOrderManager
.PriceOracle
for guidance on if it should be accepted or rejected. We may also want a hook before that that'll decide if things should even be forwarded or not. We'll call this theRfqNegotiator
.RfqStream
This module will use the
SendCustomMessage
andSubscribeCustomMessages
RPC calls to funnel the RFQ messages (which use the custom message range) to theRfqNegotiator
. It should maintain book keeping to keep track of theRfqNegotiator
instance for all the active assets the daemon cares about at the time. It'll also need to properly map the requests to responses as well (see therfq_id
value in teh messages).RfqOrderManager
This module will manage the accepted set of RFQ bundles. Using the
HtlcInterceptor
RPC call, it'll attempt to interecept any HTLCs that have anscid
that matches the set of activerfq_scid
. The set of activerfq_scid
will need to be persisted to disk in a reliable manner. In addition to using the interceptor to reject HTLCs that match therfq_scid
but don't adhere to the accepted terms, we'll also need a background routine that removes expired quotes (all quotes expire after a period of time).We'll also want a set of RPCs to introspect into this state, and potentially modify, or expire the set of accepted quotes early.
RfqNegotiator
This is the module that handles the actual negotiation. Given an offer (expressed in the
tick
unit, see the bLIP) it'll consult thePriceOracle
for that given pair. For thePriceOracle
we can either assume some set REST API to hit to obtain the price in a standard manner, or create a streaming RPC version of thePriceOracle
. The operators of edge nodes would then use that RPC to feed in custom prices into their node. These RFQ messages are also forward-able, so operators may farm them off to various other sources to be able to take advantage of larger pools of liquidity.The text was updated successfully, but these errors were encountered: