Skip to content
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

Attributable errors 2025 #3611

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

joostjager
Copy link
Contributor

@joostjager joostjager commented Feb 21, 2025

Work PR for reviving #2256

@joostjager joostjager marked this pull request as draft February 21, 2025 13:39
@joostjager joostjager changed the title Attr errors 2025 Attributable errors 2025 Feb 21, 2025
@TheBlueMatt
Copy link
Collaborator

Okay, you got totally bitten by some really old serialization logic that was written when upgrade/downgrade support was...not super well thought-through (and which was not upgraded when we made the transition, sadly). Luckily there's fairly little of this code left, but you jumped right into an area where there's a good bit of it :(.

I went ahead and implemented the serialization logic at https://git.bitcoin.ninja/?p=rust-lightning;a=log;h=refs/heads/2025-02-3611-ser-impl note that the attribution_data field has to be optional in OnionErrorPacket to support upgrade. The middle commit I'll go ahead and upstream via a separate PR now.

@@ -9973,7 +9970,21 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
},
&InboundHTLCState::LocalRemoved(ref removal_reason) => {
4u8.write(writer)?;
removal_reason.write(writer)?;
match removal_reason {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pending htlc initiated the removal (send update fail back upstream) but no response yet from peer to lock into their commit tx. See InboundHTLCState docs.

This code needs to work because of resends. Fetch fail message but don't deliver. Then check if after restart message is identical. Other node just sends chan reestablish.

4 => InboundHTLCState::LocalRemoved(Readable::read(reader)?),
4 => {
let reason = match <u8 as Readable>::read(reader)? {
0 => InboundHTLCRemovalReason::FailRelay(msgs::OnionErrorPacket {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update in holding cell, still waiting for next round of commitment dance. Should be tests that test holding cell persistence.

Strategy: break main, see if tests fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

expect_pending_htlcs_forwardable!(nodes[1]); - in here let node 0 do something else like add another htlc, so that the failure gets into the holding cell

0u8.write(writer)?;
channel_id.write(writer)?;
htlc_id.write(writer)?;
reason.write(writer)?;
attribution_data.write(writer)?; // TODO: Make TLV?
Copy link
Contributor Author

@joostjager joostjager Feb 27, 2025

Choose a reason for hiding this comment

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

Try remove serialization logic, see where it used.

Look at call site, see what context is, and find how to add more data at a higher level (tlv?)

@@ -12881,6 +12887,7 @@ impl Readable for HTLCFailureMsg {
channel_id: Readable::read(reader)?,
htlc_id: Readable::read(reader)?,
reason: Readable::read(reader)?,
attribution_data: Readable::read(reader)?,
Copy link
Contributor Author

@joostjager joostjager Feb 27, 2025

Choose a reason for hiding this comment

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

change write side to use version 2/3 and it will have the length descriptor. can add additional content at the end.

maybe intro tlv stream here?

@joostjager joostjager force-pushed the attr-errors-2025 branch 2 times, most recently from 33c4368 to dc4b841 Compare March 4, 2025 11:56
@joostjager joostjager force-pushed the attr-errors-2025 branch 10 times, most recently from 636570a to 898cd51 Compare March 5, 2025 16:45
joostjager and others added 3 commits March 5, 2025 17:58
Prepares for extending OnionErrorPacket with attribution data.
Sign up for free to 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.

2 participants