Uh oh!
There was an error while loading. Please reload this page.
Introduce RouteParametersConfig - #3342
Conversation
shaavan
commented
Sep 26, 2024
Hey @TheBlueMatt@tnull, A gentle ping! Would love to get your feedback or approach ACK before moving forward with testing and applying a similar approach on the BOLT11 side. Thanks a lot! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #3342 +/- ##
==========================================
- Coverage 88.61% 88.58% -0.03%
==========================================
Files 149 149 Lines 116877 116931 +54 Branches 116877 116931 +54 ==========================================
+ Hits 103568 103586 +18 - Misses 10802 10833 +31 - Partials 2507 2512 +5 ☔ View full report in Codecov by Sentry. |
vincenzopalazzo
left a comment
There was a problem hiding this comment.
LGTM overall.
However I am not the right person to judge if the PR is what the ldk team is looking for.
For instance the following is confusing me :) but I think this is a discussion to be done inside the issue
They also don't really make sense in a BOLT 11 world if we pass a Bolt11Invoice directly to ChannelManager (which we should do now that lightning depends on lightning-invoice).
BTW Nice git history!
P.S: I left some API idea comment in some commit review, idk if they are useful or not. probably they will remove a lot of map(_ {}) code, but I had to write the code to confirm
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| payer_note: Option<String>, payment_id: PaymentId, retry_strategy: Retry, | ||
| max_total_routing_fee_msat: Option<u64> | ||
| manual_routing_params: Option<ManualRoutingParameters> | ||
| ) -> Result<(), Bolt12SemanticError> { |
There was a problem hiding this comment.
OK no needed option here but: what do you think about having the function call like pay_for_offer(offer, OfferParams::default()) where OfferParams is something like that
structOfferParams{quantity:Option<u64>,amount_msats:Option<u64>,manual_routing_params:Option<ManualRoutingParameters>,}I think is a lot of more verbose in this way, but I also this that this will be a lot of cleaner.
Now I do not think this will fit well in this PR maybe can be a followup one, but with this patter, it is possible to hide future updates to offers (e.g: recurrence or market place feature) without breaking too much the code
There was a problem hiding this comment.
I think this is a great improvement! It will help keep the function signature cleaner while remaining maintainable for future parameter increases.
Maybe we can take this in a follow-up. @TheBlueMatt, what do you think?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
TheBlueMatt
left a comment
There was a problem hiding this comment.
High-level design looks right to me.
| payer_note: Option<String>, payment_id: PaymentId, retry_strategy: Retry, | ||
| max_total_routing_fee_msat: Option<u64> | ||
| manual_routing_params: Option<ManualRoutingParameters> | ||
| ) -> Result<(), Bolt12SemanticError> { |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
shaavan
commented
Oct 13, 2024
shaavan
commented
Oct 13, 2024
Updated from pr3342.02 to pr3342.03 (diff): Changes:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| // Deprecated: Retained for backward compatibility. | ||
| // If set during read, this field overrides `RouteParameters::max_total_routing_fee_msat` | ||
| // instead of `RouteParametersOverride::max_total_routing_fee_msat`. | ||
| max_total_routing_fee_msat: Option<u64>, |
There was a problem hiding this comment.
Ugh, I really prefer to handle this kind of thing at the serialization layer rather than in our logic. It'll be pretty annoying to break out impl_writeable_tlv_based_enum_upgradable! here, though....I wonder if we shouldn't try to (yet again) expand the featureset of our enum-deser logic. Lets get this PR ready in every other way and then I can play with it, maybe in a followup.
TheBlueMatt
commented
Oct 16, 2024
Looks like most of my previous comments went unaddressed? Just checking cause I interpreted your comment as you addressing them. |
7cdb03f to
63b08a4Compareshaavan
commented
Oct 18, 2024
Updated from pr3342.03 to pr3342.04 (diff): Changes: Update Role of RouteParamsOverride:
Cleanups:
|
shaavan
commented
Oct 18, 2024
Hey Matt, I’m really sorry for missing your previous comments – not sure how that slipped through! I've gone through everything now and made sure to address them all in the latest update. Thanks so much for your patience! 🌟 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
TheBlueMatt
commented
Oct 22, 2024
Okay, I probably spent a bit too long on it, but #3378 should let us drop the legacy fields in |
shaavan
commented
Oct 22, 2024
shaavan
commented
Oct 22, 2024
Updated from pr3342.05 to pr3342.06 (diff): Changes:
|
TheBlueMatt
commented
Oct 22, 2024
Lets get a review pass or two on #3378 and see if we want to move forward with it. If we do, we should rebase this on that and do the conversion in |
TheBlueMatt
commented
Dec 8, 2024
While it would be very nice to have this in 0.1, we kinda lost track of 3378 and thus I don't think its realistic to get this in in time. IIRC ldk-node wanted it, so we can certainly do an 0.2 not too long after 0.1, but I don't really think that this is worth holding up 0.1 for. |
Discussed offline. Just needed to remove the |
TheBlueMatt
commented
Feb 11, 2025
Hmm, that's weird, legacy writes are supposed to be |
jkczyz
commented
Feb 11, 2025
Problem was Something like: {let value:Option<$fieldty> = $write($($self)?); value } |
shaavan
commented
Feb 11, 2025
Yep! I believe that's working perfectly. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
shaavan
commented
Feb 17, 2025
Updated from pr3342.09 to pr3342.10 (diff): Changes:
|
shaavan
commented
Feb 17, 2025
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jkczyz
commented
Feb 19, 2025
LGTM. For the first commit's message, you can remove the "f: " prefix since it isn't a fixup (i.e., won't be squashed). @TheBlueMatt I'm happy to have the fixups squashed if you are. |
TheBlueMatt
left a comment
There was a problem hiding this comment.
One comment on the last commit, but please do squash the fixups and clean up the history, I think this is basically there.
| } | ||
| } | ||
| /// Update the parameters with the configuration provided by user. |
There was a problem hiding this comment.
This reads like a comment rather than documentation. Should read something like "Update the parameters with the given configuration". This also needs to mention that we do not apply the max_total_routing_fee_msat here, which is quite a potential footgun, so honestly I think maybe we should make this pub(crate) and even maybe call it with_user_config_ignoring_fee_limit.
There was a problem hiding this comment.
Thanks for the pointer! Addressed in pr3342.13
I updated the naming and change the function to pub(crate) to make it explicit that max_total_routing_fee_msat is not applied here, and prevent potential footgunning.
Also, I added an explicit line of documentation to make it clearer.
Let me know if it looks good now! Thanks!
With the current architecture, Bolt12 payers & builders only allows setting `max_total_routing_fee_msat` as a route parameter. However, it doesn't provide users the flexibility to set other important parameters. This commit introduces a new struct, `RouteParametersConfig`, that optionally allows users to set additional routing parameters. In later commits, this struct will be utilized when paying BOLT12 invoices.
…sConfig` When Bolt12 payers & builders are called, they creates a new `PendingOutboundPayment` entry with relevant values that will be used when the corresponding invoice is received. This update modifies `AwaitingInvoice` & `AwaitingOffer` to include the entire `RouteParametersConfig` struct instead of just `max_total_routing_fee_msat`. This change ensures all manual routing parameters are available when finding payment routes. Decisions & Reasoning: **Introduction of `route_params_config` in `InvoiceReceived`:** This was added for the same reason that `max_total_routing_fee_msat` was originally introduced in PR lightningdevkit#2417. The documentation has been updated to reflect this, based on [this comment](lightningdevkit@d7e2ff6#r1334619765).
This update allows users to call `pay_for_offer`, `pay_for_offer_from_human_readable` and `create_refund_builder` with a set of parameters they wish to manually set for routing the corresponding invoice. By accepting `RouteParametersConfig`, users gain greater control over the routing process.
- This finally allow overriding the {Route, Payment} parameters with the
RouteParametersConfig value provided by the user.shaavan
commented
Feb 25, 2025
Updated from pr3342.12 to pr3342.13 (diff): Changes:
|
| amt, | ||
| payment_id, | ||
| retry, | ||
| RouteParametersConfig::default(), |
There was a problem hiding this comment.
nit: For stuff like this where rustfmt requires we blow up our code to cover 20 lines we should really create intermediate variables to see if we can avoid it.
TheBlueMatt
commented
Feb 25, 2025
Landing as the full diff since @jkczyz's "LGTM" is only $ git diff-tree -U1 d9d73ead1f7fd65342f483d00686ccc845b40c59 78f6ccb5ca06f4f290ee46e2e9b945d47e38de53
diff --git a/lightning/src/ln/outbound_payment.rs b/lightning/src/ln/outbound_payment.rs
index a6c0cc1ff..f56795cf5 100644
--- a/lightning/src/ln/outbound_payment.rs+++ b/lightning/src/ln/outbound_payment.rs@@ -893,3 +893,4 @@ impl OutboundPayments {
let mut route_params = RouteParameters::from_payment_params_and_value(
- PaymentParameters::from_bolt12_invoice(&invoice).with_user_config(params_config), invoice.amount_msats()+ PaymentParameters::from_bolt12_invoice(&invoice)+ .with_user_config_ignoring_fee_limit(params_config), invoice.amount_msats()
);
@@ -1068,3 +1069,4 @@ impl OutboundPayments {
let payment_hash = PaymentHash(Sha256::hash(&keysend_preimage.0).to_byte_array());
- let pay_params = PaymentParameters::from_static_invoice(invoice).with_user_config(*route_params_config);+ let pay_params = PaymentParameters::from_static_invoice(invoice)+ .with_user_config_ignoring_fee_limit(*route_params_config);
let mut route_params = RouteParameters::from_payment_params_and_value(pay_params, amount_msat);
diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs
index e68322294..017496f26 100644
--- a/lightning/src/routing/router.rs+++ b/lightning/src/routing/router.rs@@ -945,4 +945,9 @@ impl PaymentParameters {
- /// Update the parameters with the configuration provided by user.- pub fn with_user_config(self, params_config: RouteParametersConfig) -> Self {+ /// Updates the parameters with the given route parameters configuration.+ ///+ /// Note:+ /// We *do not* apply `max_total_routing_fee_msat` here, as it is unique to each route.+ /// Instead, we apply only the parameters that are common across multiple route-finding sessions+ /// for a payment across retries.+ pub(crate) fn with_user_config_ignoring_fee_limit(self, params_config: RouteParametersConfig) -> Self {
Self { |
Partially addresses #3262
Blocked on #3378