') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Have `get_route` and `Route` take `RouteParameters` by tnull · Pull Request #2555 · lightningdevkit/rust-lightning · GitHub
Skip to content

Have get_route and Route take RouteParameters - #2555

Merged
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
tnull:2023-08-have-get-route-take-params
Sep 6, 2023
Merged

Have get_route and Route take RouteParameters#2555
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
tnull:2023-08-have-get-route-take-params

Conversation

@tnull

@tnulltnull commented Sep 6, 2023

Copy link
Copy Markdown
Contributor

These are the first few commits of #2417 split out to it's own PR in order to avoid having too many rebase conflicts.

@tnull
tnullforce-pushed the 2023-08-have-get-route-take-params branch 3 times, most recently from e0c032e to b092157CompareSeptember 6, 2023 09:30
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Patch coverage: 96.16% and project coverage change: +0.55% 🎉

Comparison is base (073f078) 90.59% compared to head (b092157) 91.15%.
Report is 10 commits behind head on main.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more.

Additional details and impacted files
@@ Coverage Diff @@## main #2555 +/- ##
==========================================
+ Coverage 90.59% 91.15% +0.55% 
==========================================
Files 110 110 Lines 57509 61782 +4273 Branches 57509 61782 +4273 ==========================================
+ Hits 52101 56315 +4214 - Misses 5408 5467 +59 
Files ChangedCoverage Δ
lightning/src/ln/onion_route_tests.rs98.23% <ø> (-0.12%)⬇️
lightning/src/ln/onion_utils.rs91.78% <ø> (ø)
lightning/src/ln/functional_test_utils.rs92.75% <87.50%> (+3.76%)⬆️
lightning/src/routing/router.rs94.33% <95.21%> (+0.12%)⬆️
lightning-invoice/src/utils.rs97.85% <100.00%> (+0.18%)⬆️
lightning/src/ln/channelmanager.rs89.70% <100.00%> (+2.50%)⬆️
lightning/src/ln/functional_tests.rs98.30% <100.00%> (+0.12%)⬆️
lightning/src/ln/outbound_payment.rs89.55% <100.00%> (-0.19%)⬇️
lightning/src/ln/payment_tests.rs97.45% <100.00%> (-0.06%)⬇️
lightning/src/ln/shutdown_tests.rs98.53% <100.00%> (+<0.01%)⬆️

... and 5 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

TheBlueMatt
TheBlueMatt previously approved these changes Sep 6, 2023
Comment threadlightning/src/ln/functional_test_utils.rs Outdated
Comment threadlightning/src/routing/router.rs
Comment threadlightning/src/routing/router.rs
Comment threadlightning/src/routing/router.rs Outdated
Comment threadlightning/src/routing/router.rs Outdated
Comment threadlightning/src/routing/router.rs Outdated
valentinewallace
valentinewallace previously approved these changes Sep 6, 2023

@valentinewallacevalentinewallace left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nothing blocking, thanks for undertaking this annoying sidequest 😛

jkczyz
jkczyz previously approved these changes Sep 6, 2023

@jkczyzjkczyz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also nothing worth blocking.

Comment threadlightning/src/routing/router.rs
Comment threadlightning/src/routing/router.rs Outdated
Comment threadlightning/src/routing/router.rs
Comment threadlightning/src/routing/router.rs Outdated
Comment threadlightning/src/routing/router.rs
@tnull
tnullforce-pushed the 2023-08-have-get-route-take-params branch from b092157 to 543674fCompareSeptember 6, 2023 17:35
@tnull

tnull commented Sep 6, 2023

Copy link
Copy Markdown
ContributorAuthor

Addressed feedback and force-pushed with the following changes:

> git diff-tree -U2 b0921575 543674f1diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs
index 16e05db6..a43cfae9 100644
--- a/lightning/src/ln/functional_test_utils.rs+++ b/lightning/src/ln/functional_test_utils.rs@@ -1856,6 +1856,6 @@ pub fn get_route(send_node: &Node, route_params: &RouteParameters) -> Result<Rou
macro_rules! get_route {
($send_node: expr, $payment_params: expr, $recv_value: expr) => {{
- let route_params = $crate::routing::router::RouteParameters::from_payment_params_and_value($payment_params, $recv_value);- $crate::ln::functional_test_utils::get_route(&$send_node, &route_params)+ let route_params = $crate::routing::router::RouteParameters::from_payment_params_and_value($payment_params, $recv_value);+ $crate::ln::functional_test_utils::get_route(&$send_node, &route_params)
}}
}
diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs
index 63b2238d..9c5fe8e1 100644
--- a/lightning/src/routing/router.rs+++ b/lightning/src/routing/router.rs@@ -338,7 +338,9 @@ pub struct Route {
/// the same.
pub paths: Vec<Path>,
- /// The `route_params` parameter passed [`find_route`].+ /// The `route_params` parameter passed to [`find_route`].
///
/// This is used by `ChannelManager` to track information which may be required for retries.
+ ///+ /// Will be `None` for objects serialized with LDK versions prior to 0.0.117.
pub route_params: Option<RouteParameters>,
}
@@ -349,5 +351,5 @@ impl Route {
/// For objects serialized with LDK 0.0.117 and after, this includes any extra payment made to
/// the recipient, which can happen in excess of the amount passed to [`find_route`] via
- /// [`RouteParameters::final_value_msat`], if we had to reach the [`htlc_minimum_msat`] limit.+ /// [`RouteParameters::final_value_msat`], if we had to reach the [`htlc_minimum_msat`] limits.
///
/// [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
@@ -361,5 +363,5 @@ impl Route {
///
/// Might be more than requested as part of the given [`RouteParameters::final_value_msat`] if
- /// we had to reach the [`htlc_minimum_msat`] limit.+ /// we had to reach the [`htlc_minimum_msat`] limits.
///
/// [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
@@ -393,7 +395,7 @@ impl Writeable for Route {
}
write_tlv_fields!(writer, {
- // For compatibility with LDK versions prior to 0.0.117, we the individual+ // For compatibility with LDK versions prior to 0.0.117, we take the individual
// RouteParameters' fields and reconstruct them on read.
- (1, self.route_params.as_ref().map(|p| p.payment_params.clone()), option),+ (1, self.route_params.as_ref().map(|p| &p.payment_params), option),
(2, blinded_tails, optional_vec),
(3, self.route_params.as_ref().map(|p| p.final_value_msat), option),
@@ -434,5 +436,5 @@ impl Readable for Route {
}
- // If we previously wrote, the corresponding fields, reconstruct RouteParameters.+ // If we previously wrote the corresponding fields, reconstruct RouteParameters.
let route_params = match (payment_params, final_value_msat) {
(Some(payment_params), Some(final_value_msat)) => {
diff --git a/pending_changelog/routes_route_params.txt b/pending_changelog/routes_route_params.txt
new file mode 100644
index 00000000..e88a1c78
--- /dev/null+++ b/pending_changelog/routes_route_params.txt@@ -0,0 +1,3 @@+# Backwards Compatibility++- `Route` objects written with LDK versions prior to 0.0.117 won't be retryable after being deserialized with LDK 0.0.117 or above.

@TheBlueMatt
TheBlueMatt merged commit 072a6ff into lightningdevkit:mainSep 6, 2023
Sign up for freeto 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.

5 participants

@tnull@codecov-commenter@TheBlueMatt@jkczyz@valentinewallace