-
Notifications
You must be signed in to change notification settings - Fork 418
Trampoline forwarding [2]: HTLCSource variant refactors #4027
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
base: main
Are you sure you want to change the base?
Trampoline forwarding [2]: HTLCSource variant refactors #4027
Conversation
👋 Hi! I see this is a draft PR. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4027 +/- ##
==========================================
- Coverage 88.94% 88.72% -0.22%
==========================================
Files 174 175 +1
Lines 124575 128464 +3889
Branches 124575 128464 +3889
==========================================
+ Hits 110797 113979 +3182
- Misses 11278 11919 +641
- Partials 2500 2566 +66
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This simplifies the code and makes it more straightforward to test unblinded trampoline receives where we need to compute the trampoline session_priv when manually creating the inner onion. (The trampoline onion needs to be manually created because LDK does not natively support sending to unblinded trampolines, just receiving.)
No need to construct unused blinded hop data or hardcode session privs/prng seeds.
Previously, this test purported to test for a successful and a failing payment to a single-hop blinded path containing one trampoline node. However, to induce the failure the test was manually reconstructing the trampoline onion in a complicated way that encoded the final onion payload as a receive, when for its purposes it would be simplier for the recipient to just fail the payment backwards. In order to not regress in test coverage, the failure method the test was previously using is re-added in the next commit as a dedicated test. XXX this new test surfaced a bug that needs to be fixed
This re-adds test coverage for a case that was removed in the previous commit.
This commit adds three new local htlc failure error reasons: `TemporaryTrampolineFailure`, `TrampolineFeeOrExpiryInsufficient`, and `UnknownNextTrampoline` for trampoline payment forwarding failures.
We add a `check_trampoline_constraints` similar to `check_blinded_path_constraints` that compares the Trampoline onion's amount and CLTV values to the limitations imposed by the outer onion. Also, we add and modify the following tests: - Modified the unblinded receive to validate when receiving amount less than expected. - Modified test with wrong CLTV parameters that now fails with new enforcement of CLTV limits. - Add unblinded and blinded receive tests that forces trampoline onion's CLTV to be greater than the outer onion packet. Note that there are some TODOs to be fixed in following commits as we need the full trampoline forwarding feature to effectively test all cases. Co-authored-by: Arik Sosman <[email protected]>
Add new HTLCSource::TrampolineForward variant to track trampoline routing information. Implement hash trait and serialization for the new variant.
In order to reduce code duplication for trampoline routing support, this commit extracts the following heper methods. - `get_htlc_failure_from_blinded_failure_forward`: builds htlc forward info with error details. - `fail_htlc_backwards_from_forward`: handles failure propagation.
Move `HTLCSource::PreviousHopData` claiming logic into `claim_funds_from_previous_hop_internal` to prepare for trampoline routing reuse.
Implement failure propagation for `HTLCSource::TrampolineForward` by iterating through previous hop data and failing each HTLC with `TemporaryTrampolineFailure`. Note that testing should be implemented when trampoline forward is completed.
Implement payment claiming for `HTLCSource::TrampolineForward` by iterating through previous hop data and claiming funds for each HTLC. Note that testing should be implemented when trampoline forwarding is completed.
Move recovery logic for `HTLCSource::PreviousHopData` into `channel_monitor_recovery_internal` to prepare for trampoline forward reuse.
Implement channel monitor recovery for trampoline forwards iterating over all hop data and updating pending forwards.
The previously existing `HTLCDestination` do not map nicely to the failure vent of a Trampoline forward, so we introduce a new variant to fill the gap. Co-authored-by: Arik Sosman <[email protected]>
9268af2
to
04d9053
Compare
This PR is on top of #3983 is part of the split-up of #3976
Main focus of this PR is to add a
TrampolineForward
variant toHTLCSource
enum, then we extract most logic to be re-used and then implement the places where we require it.After this PR only left is the implementation of finding path and forward the HTLCs and adding tests for all reamaining "to do" statements