Skip to content

Commit 8f25de0

Browse files
authored
Merge pull request #9023 from ellemouton/testHTLCPersistenceAcrossRestart
lnwallet: correctly set UpdateAddHTLC.BlindingPoint on reload from disk
2 parents 8d5f66b + e99b09d commit 8f25de0

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed

docs/release-notes/release-notes-0.18.3.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ commitment when the channel was force closed.
5959

6060
* We'll now always send [channel updates to our remote peer for open
6161
channels](https://github.com/lightningnetwork/lnd/pull/8963).
62-
62+
63+
* [Fix a bug](https://github.com/lightningnetwork/lnd/pull/9023) that would
64+
cause UpdateAddHTLC message with blinding point fields to not be re-forwarded
65+
correctly on restart.
66+
6367
# New Features
6468
## Functional Enhancements
6569
## RPC Additions

itest/list_on_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ var allTestCases = []*lntest.TestCase{
578578
Name: "update pending open channels",
579579
TestFunc: testUpdateOnPendingOpenChannels,
580580
},
581+
{
582+
Name: "blinded payment htlc re-forward",
583+
TestFunc: testBlindedPaymentHTLCReForward,
584+
},
581585
{
582586
Name: "query blinded route",
583587
TestFunc: testQueryBlindedRoutes,

itest/lnd_route_blinding_test.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,3 +1424,68 @@ func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) {
14241424
ht.AssertNumWaitingClose(hn, 0)
14251425
}
14261426
}
1427+
1428+
// testBlindedPaymentHTLCReForward tests that an UpdateAddHTLC message is
1429+
// correctly persisted, reloaded and resent to the next peer on restart in the
1430+
// case where the sending peer does not get a chance to send the message before
1431+
// restarting. This test specifically tests that this is done correctly for
1432+
// a blinded path payment since this adds a new blinding point field to
1433+
// UpdateAddHTLC which we need to ensure gets included in the message on
1434+
// restart.
1435+
func testBlindedPaymentHTLCReForward(ht *lntest.HarnessTest) {
1436+
// Setup a test case.
1437+
ctx, testCase := newBlindedForwardTest(ht)
1438+
defer testCase.cleanup()
1439+
1440+
// Set up network with carol interceptor.
1441+
testCase.setupNetwork(ctx, true)
1442+
1443+
// Let dave create invoice.
1444+
blindedPaymentPath := testCase.buildBlindedPath()
1445+
route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath)
1446+
1447+
// Once our interceptor is set up, we can send the blinded payment.
1448+
hash := sha256.Sum256(testCase.preimage[:])
1449+
sendReq := &routerrpc.SendToRouteRequest{
1450+
PaymentHash: hash[:],
1451+
Route: route,
1452+
}
1453+
1454+
// In a goroutine, we let Alice pay the invoice from dave.
1455+
done := make(chan struct{})
1456+
go func() {
1457+
defer close(done)
1458+
1459+
htlcAttempt, err := testCase.ht.Alice.RPC.Router.SendToRouteV2(
1460+
ctx, sendReq,
1461+
)
1462+
require.NoError(testCase.ht, err)
1463+
require.Equal(
1464+
testCase.ht, lnrpc.HTLCAttempt_SUCCEEDED,
1465+
htlcAttempt.Status,
1466+
)
1467+
}()
1468+
1469+
// Wait for the HTLC to be active on Alice and Bob's channels.
1470+
ht.AssertOutgoingHTLCActive(ht.Alice, testCase.channels[0], hash[:])
1471+
ht.AssertOutgoingHTLCActive(ht.Bob, testCase.channels[1], hash[:])
1472+
1473+
// Intercept the forward on Carol's link. At this point, we know she
1474+
// has received the HTLC and so will persist this packet.
1475+
_, err := testCase.carolInterceptor.Recv()
1476+
require.NoError(ht, err)
1477+
1478+
// Now, restart Carol. This time, don't require an interceptor. This
1479+
// means that Carol should load up any previously persisted
1480+
// UpdateAddHTLC messages and continue the processing of them.
1481+
ht.RestartNodeWithExtraArgs(
1482+
testCase.carol, []string{"--bitcoin.timelockdelta=18"},
1483+
)
1484+
1485+
// Now, wait for the payment to complete.
1486+
select {
1487+
case <-done:
1488+
case <-time.After(defaultTimeout):
1489+
require.Fail(ht, "timeout waiting for sending payment")
1490+
}
1491+
}

lnwallet/channel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func PayDescsFromRemoteLogUpdates(chanID lnwire.ShortChannelID, height uint64,
205205
Height: height,
206206
Index: uint16(i),
207207
},
208-
BlindingPoint: pd.BlindingPoint,
208+
BlindingPoint: wireMsg.BlindingPoint,
209209
}
210210
pd.OnionBlob = make([]byte, len(wireMsg.OnionBlob))
211211
copy(pd.OnionBlob[:], wireMsg.OnionBlob[:])

0 commit comments

Comments
 (0)