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

Log cases where an onion failure cannot be attributed or interpreted #3629

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

Conversation

joostjager
Copy link
Contributor

@joostjager joostjager commented Feb 28, 2025

Create more visibility into these edge cases. The non-attributable failure in particular can be used to disrupt sender operation and it is therefore good to at least log these cases clearly.

Additionally a bug is fixed where an unreadable failure with valid hmac wasn't properly attributed to a node.

Ok(p) => p,
Err(_) => return,
};
let decrypt_result = decrypt_onion_error_packet(&mut encrypted_packet, shared_secret);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check hmac first to distinguish between unreadable failures and hmac mismatches.

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.17%. Comparing base (eaeed77) to head (1d40811).

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #3629    +/-   ##
========================================
  Coverage   89.16%   89.17%            
========================================
  Files         152      152            
  Lines      118791   118947   +156     
  Branches   118791   118947   +156     
========================================
+ Hits       105921   106068   +147     
- Misses      10312    10316     +4     
- Partials     2558     2563     +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joostjager
Copy link
Contributor Author

joostjager commented Feb 28, 2025

Coverage reports suggests more test coverage needed...

@joostjager joostjager force-pushed the log-attribution-failures branch 5 times, most recently from 56b0aa7 to 70c8e56 Compare February 28, 2025 13:16
is_permanent: true,
});
let short_channel_id = Some(route_hop.short_channel_id);
res = Some(FailureLearnings {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bug fix. Previously unreadable failures weren't attributable even though the hmac checked out.

@joostjager joostjager force-pushed the log-attribution-failures branch from 70c8e56 to 47caa1e Compare February 28, 2025 13:24
fn build_test_path() -> Path {
Path {
hops: vec![
RouteHop {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rustfmt wanted this

.unwrap(),
channel_features: ChannelFeatures::empty(),
node_features: NodeFeatures::empty(),
short_channel_id: 1,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is a move, but just these short_channel_id's made unique to make it easier to test things for attr errors

@joostjager
Copy link
Contributor Author

Tests added

@joostjager joostjager force-pushed the log-attribution-failures branch 2 times, most recently from 1d40811 to cdda315 Compare February 28, 2025 13:48
Create more visibility into these edge cases. The non-attributable
failure in particular can be used to disrupt sender operation and it is
therefore good to at least log these cases clearly.
This commit fixes a bug where a node penalty was not applied where it
should.
@joostjager joostjager force-pushed the log-attribution-failures branch from cdda315 to fc11fe4 Compare February 28, 2025 13:49
}

fn test_failure_attribution(packet: &[u8]) -> DecodedOnionFailure {
let logger: Arc<TestLogger> = Arc::new(TestLogger::new());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dunno if you wanna bother, but note that the TestLogger does allow you to inspect the things which were logged so you could check if the new logs were hit (though in general we try to avoid test-by-log-inspection where possible because they're just annoying to update when logs change and they tend to be more brittle...but for a unit test its more fine than a functional one).


let network_update = Some(NetworkUpdate::NodeFailure {
node_id: route_hop.pubkey,
is_permanent: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIRC is_permanent NodeFailures result in removing the node from the graph entirely, which seems a bit harsh, I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same was already done for a missing failure code, so it seemed reasonable to apply the same penalty for the more severe case where the message cannot even be decoded?

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