-
Notifications
You must be signed in to change notification settings - Fork 376
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
Serialize blinded Trampoline hops #3007
Serialize blinded Trampoline hops #3007
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3007 +/- ##
==========================================
+ Coverage 89.66% 90.89% +1.23%
==========================================
Files 126 127 +1
Lines 102676 115370 +12694
Branches 102676 115370 +12694
==========================================
+ Hits 92062 104864 +12802
+ Misses 7894 7854 -40
+ Partials 2720 2652 -68
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, why is this draft? What's it waiting on?
lightning/src/ln/msgs.rs
Outdated
@@ -1767,6 +1768,21 @@ mod fuzzy_internal_msgs { | |||
outgoing_cltv_value: u32, | |||
/// The node id to which the trampoline node must find a route | |||
outgoing_node_id: PublicKey, | |||
}, | |||
#[allow(unused)] | |||
BlindedForward { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get some docs, what does BlindedForward and BlindedReceive actually mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any update here?
67ecd63
to
4b631d6
Compare
CI is quite sad. |
e3c86f7
to
4c785b5
Compare
Feel free to squash before any reviewers take a big look. |
4c785b5
to
16d1ba1
Compare
lightning/src/ln/msgs.rs
Outdated
/// List of blinded path options the last trampoline hop may choose to route through. | ||
payment_paths: Vec<BlindedPath>, | ||
/// If applicable, features of the BOLT12 invoice being paid. | ||
invoice_features: Option<Bolt12InvoiceFeatures> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is supposed to be a Bolt12InvoiceFeatures
and not a BlindedPathFeatures
? I mean it makes sense just want to double-check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by BlindedPathFeatures
do you mean BlindedHopFeatures
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhhh...I guess?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, pretty sure invoice features are correct here
lightning/src/ln/msgs.rs
Outdated
@@ -1767,6 +1768,21 @@ mod fuzzy_internal_msgs { | |||
outgoing_cltv_value: u32, | |||
/// The node id to which the trampoline node must find a route | |||
outgoing_node_id: PublicKey, | |||
}, | |||
#[allow(unused)] | |||
BlindedForward { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any update here?
53b7f63
to
b9f002e
Compare
lightning/src/ln/msgs.rs
Outdated
p.inner_blinded_path().encode().into_iter().chain(p.payinfo.encode()).collect::<Vec<u8>>() | ||
}).collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're building multiple vecs here where I think we can get away with none. May need to support writing iterators over bytes, but that should be doable?
b9f002e
to
9d01751
Compare
lightning/src/ln/msgs.rs
Outdated
(2, HighZeroBytesDroppedBigSize(*amt_to_forward), required), | ||
(4, HighZeroBytesDroppedBigSize(*outgoing_cltv_value), required), | ||
(21, invoice_features.as_ref().map(|m| WithoutLength(m)), option) | ||
}, [&blinded_path_tlv]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we expand this to support writing Iterator<u8>
s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean such as in BlindedReceive, which allows passing custom TLVs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, like that.
9d01751
to
aa73fe2
Compare
lightning/src/ln/msgs.rs
Outdated
}).collect(); | ||
let blinded_path_tlv = (22, blinded_path_value); | ||
let custom_tlvs: Vec<&(u64, Vec<u8>)> = core::iter::once(blinded_path_tlv).collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you collecting into a vec and then iterating it? Let's avoid the allocation.
lightning/src/ln/msgs.rs
Outdated
}); | ||
}, | ||
Self::BlindedReceive { sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, encrypted_tlvs, intro_node_blinding_point, keysend_preimage, custom_tlvs } => { | ||
let keysend_tlv = keysend_preimage.map(|preimage| (5482373484, preimage.encode())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, is this defined in the BlindedReceive
proposed? And, if it is, can we swap it for a type in a sensible range so we can drop the collect + sort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the identical type ID we currently use in the non-Trampoline payload, but no, Eclair does not have a defined value for this in their code at this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's pick one that isn't in the experimental range and pressure them to use that instead :)
Looks like this needs rebase and CI was failing. |
017b9a7
to
d0363d5
Compare
lightning/src/ln/msgs.rs
Outdated
let blinded_path_value: Vec<u8> = payment_paths.iter().flat_map(|p| { | ||
p.inner_blinded_path().encode().into_iter().chain(p.payinfo.encode()) | ||
}).collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current logic here, for each blinded path, allocates two vecs, and then at the end we allocate another vec. Instead, we should allocate one vec (with_capacity
) and then write
all the fields we want into it, saving two allocations per path.
lightning/src/ln/msgs.rs
Outdated
}); | ||
}, | ||
Self::BlindedReceive { sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, encrypted_tlvs, intro_node_blinding_point, keysend_preimage, custom_tlvs } => { | ||
let keysend_tlv = keysend_preimage.map(|preimage| preimage.encode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't build a vec for 32 bytes. I'm kinda confused why we can't just write the keysend_preimage
directly?
d0363d5
to
589ef85
Compare
lightning/src/ln/msgs.rs
Outdated
current_payment_path.inner_blinded_path().write(&mut blinded_path_serialization)?; | ||
current_payment_path.payinfo.write(&mut blinded_path_serialization)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're gonna handle the error anyway lets just write into a fixed-length buffer on stack?
589ef85
to
3df5131
Compare
There was a problem hiding this comment.
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.
lightning/src/ln/msgs.rs
Outdated
current_payment_path.inner_blinded_path().write(&mut blinded_path_slice)?; | ||
current_payment_path.payinfo.write(&mut blinded_path_slice)?; | ||
} | ||
2048 - blinded_path_slice.len() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit
2048 - blinded_path_slice.len() | |
blinded_path_serialization.len - blinded_path_slice.len() |
bbf5d18
to
e11a5ab
Compare
e11a5ab
to
d111981
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty trivial, if there's any issues we'll find it when we go to use this stuff. Landing.
Add
BlindedForward
andBlindedReceive
variants toOutboundTrampolinePayload
.