Skip to content

Commit 538f857

Browse files
committed
Add trampoline_hops field to Path
To specify Trampoline hops in Path instances, we need to introduce a third field to the struct, which is a vec of TrampolineHops defined in the previous commit.
1 parent 6e1fdc6 commit 538f857

File tree

14 files changed

+85
-40
lines changed

14 files changed

+85
-40
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ fn send_payment(
520520
cltv_expiry_delta: 200,
521521
maybe_announced_channel: true,
522522
}],
523+
trampoline_hops: vec![],
523524
blinded_tail: None,
524525
}],
525526
route_params: Some(route_params.clone()),
@@ -604,6 +605,7 @@ fn send_hop_payment(
604605
maybe_announced_channel: true,
605606
},
606607
],
608+
trampoline_hops: vec![],
607609
blinded_tail: None,
608610
}],
609611
route_params: Some(route_params.clone()),

lightning-background-processor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ mod tests {
25402540
fee_msat: 0,
25412541
cltv_expiry_delta: MIN_CLTV_EXPIRY_DELTA as u32,
25422542
maybe_announced_channel: true,
2543-
}], blinded_tail: None };
2543+
}], trampoline_hops: vec![], blinded_tail: None };
25442544

25452545
$nodes[0].scorer.write_lock().expect(TestResult::PaymentFailure { path: path.clone(), short_channel_id: scored_scid });
25462546
$nodes[0].node.push_pending_event(Event::PaymentPathFailed {

lightning/src/events/mod.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::types::payment::{PaymentPreimage, PaymentHash, PaymentSecret};
3030
use crate::offers::invoice::Bolt12Invoice;
3131
use crate::onion_message::messenger::Responder;
3232
use crate::routing::gossip::NetworkUpdate;
33-
use crate::routing::router::{BlindedTail, Path, RouteHop, RouteParameters};
33+
use crate::routing::router::{BlindedTail, Path, RouteHop, RouteParameters, TrampolineHop};
3434
use crate::sign::SpendableOutputDescriptor;
3535
use crate::util::errors::APIError;
3636
use crate::util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReadable, Readable, RequiredWrapper, UpgradableRequired, WithoutLength};
@@ -1190,12 +1190,12 @@ pub enum Event {
11901190
/// events generated or serialized by versions prior to 0.0.122.
11911191
next_user_channel_id: Option<u128>,
11921192
/// The node id of the previous node.
1193-
///
1193+
///
11941194
/// This is only `None` for HTLCs received prior to 0.1 or for events serialized by
11951195
/// versions prior to 0.1
11961196
prev_node_id: Option<PublicKey>,
11971197
/// The node id of the next node.
1198-
///
1198+
///
11991199
/// This is only `None` for HTLCs received prior to 0.1 or for events serialized by
12001200
/// versions prior to 0.1
12011201
next_node_id: Option<PublicKey>,
@@ -1574,6 +1574,7 @@ impl Writeable for Event {
15741574
(2, payment_failed_permanently, required),
15751575
(3, false, required), // all_paths_failed in LDK versions prior to 0.0.114
15761576
(4, path.blinded_tail, option),
1577+
(6, path.trampoline_hops, optional_vec),
15771578
(5, path.hops, required_vec),
15781579
(7, short_channel_id, option),
15791580
(9, None::<RouteParameters>, option), // retry in LDK versions prior to 0.0.115
@@ -1665,6 +1666,7 @@ impl Writeable for Event {
16651666
(2, payment_hash, option),
16661667
(4, path.hops, required_vec),
16671668
(6, path.blinded_tail, option),
1669+
(8, path.trampoline_hops, optional_vec),
16681670
})
16691671
},
16701672
&Event::PaymentFailed { ref payment_id, ref payment_hash, ref reason } => {
@@ -1729,6 +1731,7 @@ impl Writeable for Event {
17291731
(2, payment_hash, required),
17301732
(4, path.hops, required_vec),
17311733
(6, path.blinded_tail, option),
1734+
(8, path.trampoline_hops, optional_vec),
17321735
})
17331736
},
17341737
&Event::ProbeFailed { ref payment_id, ref payment_hash, ref path, ref short_channel_id } => {
@@ -1739,6 +1742,7 @@ impl Writeable for Event {
17391742
(4, path.hops, required_vec),
17401743
(6, short_channel_id, option),
17411744
(8, path.blinded_tail, option),
1745+
(10, path.trampoline_hops, optional_vec)
17421746
})
17431747
},
17441748
&Event::HTLCHandlingFailed { ref prev_channel_id, ref failed_next_destination } => {
@@ -1915,6 +1919,7 @@ impl MaybeReadable for Event {
19151919
let mut network_update = None;
19161920
let mut blinded_tail: Option<BlindedTail> = None;
19171921
let mut path: Option<Vec<RouteHop>> = Some(vec![]);
1922+
let mut trampoline_path: Option<Vec<TrampolineHop>> = Some(vec![]);
19181923
let mut short_channel_id = None;
19191924
let mut payment_id = None;
19201925
let mut failure_opt = None;
@@ -1923,6 +1928,7 @@ impl MaybeReadable for Event {
19231928
(1, network_update, upgradable_option),
19241929
(2, payment_failed_permanently, required),
19251930
(4, blinded_tail, option),
1931+
(6, trampoline_path, optional_vec),
19261932
// Added as a part of LDK 0.0.101 and always filled in since.
19271933
// Defaults to an empty Vec, though likely should have been `Option`al.
19281934
(5, path, optional_vec),
@@ -1936,7 +1942,7 @@ impl MaybeReadable for Event {
19361942
payment_hash,
19371943
payment_failed_permanently,
19381944
failure,
1939-
path: Path { hops: path.unwrap(), blinded_tail },
1945+
path: Path { hops: path.unwrap(), trampoline_hops: trampoline_path.unwrap_or(vec![]), blinded_tail },
19401946
short_channel_id,
19411947
#[cfg(test)]
19421948
error_code,
@@ -2077,11 +2083,12 @@ impl MaybeReadable for Event {
20772083
(2, payment_hash, option),
20782084
(4, path, required_vec),
20792085
(6, blinded_tail, option),
2086+
(8, trampoline_path, optional_vec),
20802087
});
20812088
Ok(Some(Event::PaymentPathSuccessful {
20822089
payment_id: payment_id.0.unwrap(),
20832090
payment_hash,
2084-
path: Path { hops: path, blinded_tail },
2091+
path: Path { hops: path, trampoline_hops: trampoline_path.unwrap_or(vec![]), blinded_tail },
20852092
}))
20862093
};
20872094
f()
@@ -2157,11 +2164,12 @@ impl MaybeReadable for Event {
21572164
(2, payment_hash, required),
21582165
(4, path, required_vec),
21592166
(6, blinded_tail, option),
2167+
(8, trampoline_path, optional_vec)
21602168
});
21612169
Ok(Some(Event::ProbeSuccessful {
21622170
payment_id: payment_id.0.unwrap(),
21632171
payment_hash: payment_hash.0.unwrap(),
2164-
path: Path { hops: path, blinded_tail },
2172+
path: Path { hops: path, trampoline_hops: trampoline_path.unwrap_or(vec![]), blinded_tail },
21652173
}))
21662174
};
21672175
f()
@@ -2174,11 +2182,12 @@ impl MaybeReadable for Event {
21742182
(4, path, required_vec),
21752183
(6, short_channel_id, option),
21762184
(8, blinded_tail, option),
2185+
(10, trampoline_path, optional_vec)
21772186
});
21782187
Ok(Some(Event::ProbeFailed {
21792188
payment_id: payment_id.0.unwrap(),
21802189
payment_hash: payment_hash.0.unwrap(),
2181-
path: Path { hops: path, blinded_tail },
2190+
path: Path { hops: path, trampoline_hops: trampoline_path.unwrap_or(vec![]), blinded_tail },
21822191
short_channel_id,
21832192
}))
21842193
};

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,7 @@ fn route_blinding_spec_test_vector() {
15041504
cltv_expiry_delta: 42,
15051505
maybe_announced_channel: false,
15061506
}],
1507+
trampoline_hops: vec![],
15071508
blinded_tail: Some(BlindedTail {
15081509
hops: blinded_hops,
15091510
blinding_point: bob_blinding_point,

lightning/src/ln/channel.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10666,7 +10666,7 @@ mod tests {
1066610666
cltv_expiry: 200000000,
1066710667
state: OutboundHTLCState::Committed,
1066810668
source: HTLCSource::OutboundRoute {
10669-
path: Path { hops: Vec::new(), blinded_tail: None },
10669+
path: Path { hops: Vec::new(), trampoline_hops: vec![], blinded_tail: None },
1067010670
session_priv: SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
1067110671
first_hop_htlc_msat: 548,
1067210672
payment_id: PaymentId([42; 32]),
@@ -11042,6 +11042,7 @@ mod tests {
1104211042
node_features: NodeFeatures::empty(), short_channel_id: 0, fee_msat: 0,
1104311043
cltv_expiry_delta: 0, maybe_announced_channel: false,
1104411044
}],
11045+
trampoline_hops: vec![],
1104511046
blinded_tail: None
1104611047
},
1104711048
session_priv: test_utils::privkey(42),

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ impl HTLCSource {
689689
pub fn dummy() -> Self {
690690
assert!(cfg!(not(feature = "grind_signatures")));
691691
HTLCSource::OutboundRoute {
692-
path: Path { hops: Vec::new(), blinded_tail: None },
692+
path: Path { hops: Vec::new(), trampoline_hops: Vec::new(), blinded_tail: None },
693693
session_priv: SecretKey::from_slice(&[1; 32]).unwrap(),
694694
first_hop_htlc_msat: 0,
695695
payment_id: PaymentId([2; 32]),
@@ -12618,7 +12618,7 @@ impl Readable for HTLCSource {
1261812618
// instead.
1261912619
payment_id = Some(PaymentId(*session_priv.0.unwrap().as_ref()));
1262012620
}
12621-
let path = Path { hops: path_hops, blinded_tail };
12621+
let path = Path { hops: path_hops, trampoline_hops: vec![], blinded_tail };
1262212622
if path.hops.len() == 0 {
1262312623
return Err(DecodeError::InvalidValue);
1262412624
}

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ fn fake_network_test() {
10881088
).with_bolt11_features(nodes[1].node.bolt11_invoice_features()).unwrap();
10891089
let route_params = RouteParameters::from_payment_params_and_value(payment_params, 1000000);
10901090
let payment_preimage_1 = send_along_route(&nodes[1],
1091-
Route { paths: vec![Path { hops, blinded_tail: None }], route_params: Some(route_params.clone()) },
1091+
Route { paths: vec![Path { hops, trampoline_hops: vec![], blinded_tail: None }], route_params: Some(route_params.clone()) },
10921092
&vec!(&nodes[2], &nodes[3], &nodes[1])[..], 1000000).0;
10931093

10941094
let mut hops = Vec::with_capacity(3);
@@ -1122,7 +1122,7 @@ fn fake_network_test() {
11221122
hops[1].fee_msat = chan_2.1.contents.fee_base_msat as u64 + chan_2.1.contents.fee_proportional_millionths as u64 * hops[2].fee_msat as u64 / 1000000;
11231123
hops[0].fee_msat = chan_3.1.contents.fee_base_msat as u64 + chan_3.1.contents.fee_proportional_millionths as u64 * hops[1].fee_msat as u64 / 1000000;
11241124
let payment_hash_2 = send_along_route(&nodes[1],
1125-
Route { paths: vec![Path { hops, blinded_tail: None }], route_params: Some(route_params) },
1125+
Route { paths: vec![Path { hops, trampoline_hops: vec![], blinded_tail: None }], route_params: Some(route_params) },
11261126
&vec!(&nodes[3], &nodes[2], &nodes[1])[..], 1000000).1;
11271127

11281128
// Claim the rebalances...

lightning/src/ln/onion_payment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ mod tests {
534534
// Ensure the onion will not fit all the payloads by adding a large custom TLV.
535535
recipient_onion.custom_tlvs.push((13377331, vec![0; 1156]));
536536

537-
let path = Path { hops, blinded_tail: None, };
537+
let path = Path { hops, trampoline_hops: vec![], blinded_tail: None, };
538538
let onion_keys = super::onion_utils::construct_onion_keys(&secp_ctx, &path, &session_priv).unwrap();
539539
let (onion_payloads, ..) = super::onion_utils::build_onion_payloads(
540540
&path, total_amt_msat, &recipient_onion, cur_height + 1, &Some(keysend_preimage), None
@@ -560,6 +560,7 @@ mod tests {
560560

561561
let path = Path {
562562
hops: hops,
563+
trampoline_hops: vec![],
563564
blinded_tail: None,
564565
};
565566

lightning/src/ln/onion_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ mod tests {
13501350
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
13511351
short_channel_id: 0, fee_msat: 0, cltv_expiry_delta: 0, maybe_announced_channel: true, // We fill in the payloads manually instead of generating them from RouteHops.
13521352
},
1353-
], blinded_tail: None }],
1353+
], trampoline_hops: vec![], blinded_tail: None }],
13541354
route_params: None,
13551355
};
13561356

lightning/src/ln/outbound_payment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2582,7 +2582,7 @@ mod tests {
25822582
fee_msat: 0,
25832583
cltv_expiry_delta: 0,
25842584
maybe_announced_channel: true,
2585-
}], blinded_tail: None }],
2585+
}], trampoline_hops: vec![], blinded_tail: None }],
25862586
route_params: Some(route_params.clone()),
25872587
};
25882588
router.expect_find_route(route_params.clone(), Ok(route.clone()));
@@ -2938,6 +2938,7 @@ mod tests {
29382938
maybe_announced_channel: true,
29392939
}
29402940
],
2941+
trampoline_hops: vec![],
29412942
blinded_tail: None,
29422943
}
29432944
],

lightning/src/ln/payment_tests.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,7 +2454,7 @@ fn auto_retry_partial_failure() {
24542454
fee_msat: amt_msat / 2,
24552455
cltv_expiry_delta: 100,
24562456
maybe_announced_channel: true,
2457-
}], blinded_tail: None },
2457+
}], trampoline_hops: vec![], blinded_tail: None },
24582458
Path { hops: vec![RouteHop {
24592459
pubkey: nodes[1].node.get_our_node_id(),
24602460
node_features: nodes[1].node.node_features(),
@@ -2463,7 +2463,7 @@ fn auto_retry_partial_failure() {
24632463
fee_msat: amt_msat / 2,
24642464
cltv_expiry_delta: 100,
24652465
maybe_announced_channel: true,
2466-
}], blinded_tail: None },
2466+
}], trampoline_hops: vec![], blinded_tail: None },
24672467
],
24682468
route_params: Some(route_params.clone()),
24692469
};
@@ -2485,7 +2485,7 @@ fn auto_retry_partial_failure() {
24852485
fee_msat: amt_msat / 4,
24862486
cltv_expiry_delta: 100,
24872487
maybe_announced_channel: true,
2488-
}], blinded_tail: None },
2488+
}], trampoline_hops: vec![], blinded_tail: None },
24892489
Path { hops: vec![RouteHop {
24902490
pubkey: nodes[1].node.get_our_node_id(),
24912491
node_features: nodes[1].node.node_features(),
@@ -2494,7 +2494,7 @@ fn auto_retry_partial_failure() {
24942494
fee_msat: amt_msat / 4,
24952495
cltv_expiry_delta: 100,
24962496
maybe_announced_channel: true,
2497-
}], blinded_tail: None },
2497+
}], trampoline_hops: vec![], blinded_tail: None },
24982498
],
24992499
route_params: Some(retry_1_params.clone()),
25002500
};
@@ -2516,7 +2516,7 @@ fn auto_retry_partial_failure() {
25162516
fee_msat: amt_msat / 4,
25172517
cltv_expiry_delta: 100,
25182518
maybe_announced_channel: true,
2519-
}], blinded_tail: None },
2519+
}], trampoline_hops: vec![], blinded_tail: None },
25202520
],
25212521
route_params: Some(retry_2_params.clone()),
25222522
};
@@ -2661,7 +2661,7 @@ fn auto_retry_zero_attempts_send_error() {
26612661
fee_msat: amt_msat,
26622662
cltv_expiry_delta: 100,
26632663
maybe_announced_channel: true,
2664-
}], blinded_tail: None },
2664+
}], trampoline_hops: vec![], blinded_tail: None },
26652665
],
26662666
route_params: Some(route_params.clone()),
26672667
};
@@ -2759,7 +2759,7 @@ fn retry_multi_path_single_failed_payment() {
27592759
fee_msat: 10_000,
27602760
cltv_expiry_delta: 100,
27612761
maybe_announced_channel: true,
2762-
}], blinded_tail: None },
2762+
}], trampoline_hops: vec![], blinded_tail: None },
27632763
Path { hops: vec![RouteHop {
27642764
pubkey: nodes[1].node.get_our_node_id(),
27652765
node_features: nodes[1].node.node_features(),
@@ -2768,7 +2768,7 @@ fn retry_multi_path_single_failed_payment() {
27682768
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
27692769
cltv_expiry_delta: 100,
27702770
maybe_announced_channel: true,
2771-
}], blinded_tail: None },
2771+
}], trampoline_hops: vec![], blinded_tail: None },
27722772
],
27732773
route_params: Some(route_params.clone()),
27742774
};
@@ -2850,7 +2850,7 @@ fn immediate_retry_on_failure() {
28502850
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
28512851
cltv_expiry_delta: 100,
28522852
maybe_announced_channel: true,
2853-
}], blinded_tail: None },
2853+
}], trampoline_hops: vec![], blinded_tail: None },
28542854
],
28552855
route_params: Some(route_params.clone()),
28562856
};
@@ -2946,7 +2946,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29462946
fee_msat: 100_000_000,
29472947
cltv_expiry_delta: 100,
29482948
maybe_announced_channel: true,
2949-
}], blinded_tail: None },
2949+
}], trampoline_hops: vec![], blinded_tail: None },
29502950
Path { hops: vec![RouteHop {
29512951
pubkey: nodes[1].node.get_our_node_id(),
29522952
node_features: nodes[1].node.node_features(),
@@ -2963,7 +2963,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29632963
fee_msat: 100_000_000,
29642964
cltv_expiry_delta: 100,
29652965
maybe_announced_channel: true,
2966-
}], blinded_tail: None }
2966+
}], trampoline_hops: vec![], blinded_tail: None }
29672967
],
29682968
route_params: Some(route_params.clone()),
29692969
};
@@ -3149,7 +3149,7 @@ fn test_simple_partial_retry() {
31493149
fee_msat: 100_000_000,
31503150
cltv_expiry_delta: 100,
31513151
maybe_announced_channel: true,
3152-
}], blinded_tail: None },
3152+
}], trampoline_hops: vec![], blinded_tail: None },
31533153
Path { hops: vec![RouteHop {
31543154
pubkey: nodes[1].node.get_our_node_id(),
31553155
node_features: nodes[1].node.node_features(),
@@ -3166,7 +3166,7 @@ fn test_simple_partial_retry() {
31663166
fee_msat: 100_000_000,
31673167
cltv_expiry_delta: 100,
31683168
maybe_announced_channel: true,
3169-
}], blinded_tail: None }
3169+
}], trampoline_hops: vec![], blinded_tail: None }
31703170
],
31713171
route_params: Some(route_params.clone()),
31723172
};
@@ -3331,7 +3331,7 @@ fn test_threaded_payment_retries() {
33313331
fee_msat: amt_msat / 1000,
33323332
cltv_expiry_delta: 100,
33333333
maybe_announced_channel: true,
3334-
}], blinded_tail: None },
3334+
}], trampoline_hops: vec![], blinded_tail: None },
33353335
Path { hops: vec![RouteHop {
33363336
pubkey: nodes[2].node.get_our_node_id(),
33373337
node_features: nodes[2].node.node_features(),
@@ -3348,7 +3348,7 @@ fn test_threaded_payment_retries() {
33483348
fee_msat: amt_msat - amt_msat / 1000,
33493349
cltv_expiry_delta: 100,
33503350
maybe_announced_channel: true,
3351-
}], blinded_tail: None }
3351+
}], trampoline_hops: vec![], blinded_tail: None }
33523352
],
33533353
route_params: Some(route_params.clone()),
33543354
};

0 commit comments

Comments
 (0)