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

crypto: Add more logs when sharing keys #3274

Closed
wants to merge 1 commit into from

Conversation

BillCarsonFr
Copy link
Member

I have been investigating some rageshakes recently, and often we don't have enough log history to see when/if a key was correctly distributed to another device.

This is an attempt to not only log to whom a key is shared in the current round, but also to log the other devices that we already tried to distribute too.
It might be a bit verbose? Let me know what you think.

The log look like that:

2024-03-22T10:13:02.688119Z DEBUG matrix_sdk_crypto::session_manager::group_sessions: Keys already shared or 
withheld to the following devices. sharing_full_log=[("@vXXXXXX:matrix.org", "MTQYWIFEPO", "Shared(0)"), 
("@vXXXXX:matrix.org", "FJVZCJJRRU", "Shared(3)"), ("@xxxx:yyyyyy.net", "YDCXXXXZB", " withheld: m.no_olm")
  • Public API changes documented in changelogs (optional)

Signed-off-by:

@BillCarsonFr BillCarsonFr requested a review from a team as a code owner March 25, 2024 13:53
@BillCarsonFr BillCarsonFr requested review from poljar and removed request for a team March 25, 2024 13:53
Copy link

codecov bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.64%. Comparing base (95a471b) to head (cdf5dfa).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3274      +/-   ##
==========================================
+ Coverage   83.62%   83.64%   +0.01%     
==========================================
  Files         239      239              
  Lines       24705    24725      +20     
==========================================
+ Hits        20660    20680      +20     
  Misses       4045     4045              

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

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

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

Looks good, left some nits to make it a bit neater, also please address the CI issues.

&self,
already_shared_devices: &Vec<(ReadOnlyDevice, ShareState)>,
withthelds: &Vec<(ReadOnlyDevice, WithheldCode)>,
) -> Vec<(String, String, String)> {
Copy link
Contributor

Choose a reason for hiding this comment

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

A Vec<(String, String, String)> is quite the handful. Can we add a type with the desired Debug implementation instead? Then The split_devices() method can return that directly.

devices: BTreeMap<OwnedUserId, Vec<ReadOnlyDevice>>,
outbound: &OutboundGroupSession,
) -> (Vec<ReadOnlyDevice>, Vec<(ReadOnlyDevice, ShareState)>) {
let split: (Vec<(ReadOnlyDevice, ShareState)>, Vec<(ReadOnlyDevice, ShareState)>) = devices
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let split: (Vec<(ReadOnlyDevice, ShareState)>, Vec<(ReadOnlyDevice, ShareState)>) = devices
let (to_share_with, shared_with): (_, Vec<_>) = devices

})
.partition(|(_, state)| matches!(state, ShareState::NotShared));

(split.0.into_iter().map(|(d, _)| d).collect(), split.1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(split.0.into_iter().map(|(d, _)| d).collect(), split.1)
(to_share_with.into_iter().map(|(d, _)| d).collect(), shared_with)

@@ -810,6 +806,13 @@ impl GroupSessionManager {
let unable_to_encrypt_devices =
self.encrypt_for_devices(devices, &outbound, &mut changes).await?;

// This could be verbose, but usefull to debug why a room key wasn't shared.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// This could be verbose, but usefull to debug why a room key wasn't shared.
// This could be verbose, but useful to debug why a room key wasn't shared.

@poljar
Copy link
Contributor

poljar commented May 30, 2024

This is now months old without any comment. If you want to move this along, please reopen.

@poljar poljar closed this May 30, 2024
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.

None yet

2 participants