') + ')', '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); } })(); })(); Fix `PaymentPathFailed::payment_failed_permanently` on blinded path fail by valentinewallace · Pull Request #2576 · lightningdevkit/rust-lightning · GitHub
Skip to content

Fix PaymentPathFailed::payment_failed_permanently on blinded path fail - #2576

Merged
TheBlueMatt merged 6 commits into
lightningdevkit:mainfrom
valentinewallace:2023-09-fix-outbound-bp-fail-ev
Sep 25, 2023
Merged

Fix PaymentPathFailed::payment_failed_permanently on blinded path fail#2576
TheBlueMatt merged 6 commits into
lightningdevkit:mainfrom
valentinewallace:2023-09-fix-outbound-bp-fail-ev

Conversation

@valentinewallace

@valentinewallacevalentinewallace commented Sep 14, 2023

Copy link
Copy Markdown
Contributor

Previously this value would be incorrectly set to true because we wouldn't
account for blinded hops when determining if we were processing the last hop's
failure packet.

This is tested in the follow-up. I'm not ready to update that PR yet because I'm still reworking the commit history, but I have a WIP branch if anyone wants to verify the test coverage.

Includes a few minor cleanups of onion_utils::process_onion_failure and friends.

Also closes#2532.

@valentinewallacevalentinewallace added this to the 0.0.117 milestone Sep 14, 2023
Comment threadlightning/src/ln/onion_utils.rs Outdated
@valentinewallacevalentinewallace mentioned this pull request Sep 13, 2023
60 tasks
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Since you're touching this code, can you also fix #2532?

@valentinewallace
valentinewallaceforce-pushed the 2023-09-fix-outbound-bp-fail-ev branch from 9bde6f2 to db052deCompareSeptember 15, 2023 21:01
@valentinewallace

Copy link
Copy Markdown
ContributorAuthor

Added a commit addressing #2532 and rebased in hopes of fixing CI.

@valentinewallace
valentinewallaceforce-pushed the 2023-09-fix-outbound-bp-fail-ev branch from db052de to 697150cCompareSeptember 15, 2023 21:02
@codecov-commenter

codecov-commenter commented Sep 15, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 82.53% and project coverage change: -1.82%⚠️

Comparison is base (89fb5a3) 90.63% compared to head (6299f7d) 88.81%.
Report is 52 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@ Coverage Diff @@## main #2576 +/- ##
==========================================
- Coverage 90.63% 88.81% -1.82% 
==========================================
Files 113 113 Lines 59054 84461 +25407 Branches 59054 84461 +25407 ==========================================
+ Hits 53522 75013 +21491 - Misses 5532 7243 +1711 - Partials 0 2205 +2205 
Files ChangedCoverage Δ
lightning/src/ln/onion_utils.rs91.49% <65.51%> (+0.52%)⬆️
lightning/src/ln/onion_route_tests.rs97.56% <96.42%> (-0.68%)⬇️
lightning/src/ln/outbound_payment.rs88.80% <100.00%> (-2.00%)⬇️

... and 110 files with indirect coverage changes

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

Comment threadlightning/src/ln/onion_utils.rs Outdated
short_channel_id = Some(failing_route_hop.short_channel_id);
network_update = Some(NetworkUpdate::ChannelFailure {
short_channel_id: route_hop.short_channel_id,
short_channel_id: failing_route_hop.short_channel_id,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should remove the network update entirely. Even with perm set to false this will still mark the channel disabled even though it isn't.

@valentinewallacevalentinewallaceSep 20, 2023

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We only mark the channel as disabled if is_permanent is set. It's nice to set it because then we can more easily keep the behavior of defaulting to NetworkUpdate::NodeFailure on a totally bogus channel update.

@valentinewallace
valentinewallaceforce-pushed the 2023-09-fix-outbound-bp-fail-ev branch from 697150c to 9e2f95eCompareSeptember 20, 2023 19:12
Comment threadlightning/src/ln/onion_utils.rs
Comment threadlightning/src/ln/onion_utils.rs
@valentinewallace
valentinewallaceforce-pushed the 2023-09-fix-outbound-bp-fail-ev branch 2 times, most recently from 1bdc2af to 0c62e8cCompareSeptember 21, 2023 15:08

@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.

LGTM. Feel free to squash.

This variable is ultimately for setting
PaymentPathFailed::payment_failed_permanently, so use this name rather than
flipping a bool back and forth.
Our ultimate goal with this field is to set
PaymentPathFailed::payment_failed_permanently, so use this name rather than
flipping a bool back and forth across methods.
We don't support sending to paths where we are the intro node yet, but may as
well set the failure correctly now.
Previously this value would be incorrectly set to true because we wouldn't
account for blinded hops when determining if we were processing the last hop's
failure packet.
We've run into this several times in the wild, likely due to
ElementsProject/lightning#6200 wherein a node on the
path will error with 0x1000 but not provide a channel update (a spec
violation).
Previously, we would blame the inbound edge even though the buggy peer wanted
us to blame the outbound edge. Since this issue seems to be recurring and our
blaming the inbound edge is causing us to punish innocent channels, trust the
peer that the outbound edge is the one to blame.
@valentinewallace
valentinewallaceforce-pushed the 2023-09-fix-outbound-bp-fail-ev branch from 0c62e8c to 6299f7dCompareSeptember 22, 2023 19:57
@TheBlueMatt
TheBlueMatt merged commit 0e83e91 into lightningdevkit:mainSep 25, 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.

Handle temporary_channel_failure missing update better

4 participants

@valentinewallace@TheBlueMatt@codecov-commenter@jkczyz