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

fix(sliding_sync): Add ignore_verification_requests method to SlidingSyncBuilder #4705

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

Conversation

jmartinesp
Copy link
Contributor

This can be used to ignore verification requests in this sliding sync instance, preventing issues found where several sliding sync instances with the same client process events simultaneously and re-process the same verification request events during their initial syncs.

This is a blocker for user verification on Android clients, since both the normal sync and the one initiated to get the event for a notification will process the same verification request events and end up with conflicts, making the verification flow fail most of the time.

  • Public API changes documented in changelogs (optional)

Signed-off-by:

…ingSyncBuilder`

This can be used to ignore verification requests in this sliding sync instance, preventing issues found where several sliding sync instances with the same client process events simultaneously and re-process the same verification request events during their initial syncs.
@jmartinesp jmartinesp requested a review from a team as a code owner February 21, 2025 09:22
@jmartinesp jmartinesp requested review from poljar and removed request for a team February 21, 2025 09:22
…en the `e2e-encryption` feature is disabled
…sts` when the `e2e-encryption` feature is disabled
…sts` when the `e2e-encryption` feature is disabled
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 60.86957% with 9 lines in your changes missing coverage. Please review.

Project coverage is 85.89%. Comparing base (2eb2ae7) to head (d53ddc1).
Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk-base/src/client.rs 0.00% 6 Missing ⚠️
crates/matrix-sdk/src/sliding_sync/client.rs 71.42% 2 Missing ⚠️
crates/matrix-sdk-base/src/sliding_sync.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4705      +/-   ##
==========================================
- Coverage   85.89%   85.89%   -0.01%     
==========================================
  Files         292      292              
  Lines       33912    33923      +11     
==========================================
+ Hits        29129    29138       +9     
- Misses       4783     4785       +2     

☔ 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.

This feels a bit like a hack, though sadly I don't have any better ideas how to deal with this problem.

I'm wondering if we should ignore all verification events. Additionally could you write a test that the notification client won't create Verification objects?

An integration test would probably be the easiest to write.

Comment on lines +501 to +504
if !ignore_verification_requests {
Box::pin(self.handle_verification_event(e, room.room_id()))
.await?;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we ignore all verification events? I guess the crypto crate already does so if it doesn't receive an m.key.verification.request event, but I think it'll log a bunch of warnings in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't that what I'm doing below? I'm not sure I fully understand the underlying logic, but I think this branch takes the verification requests and the one below any other verification event.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, how did I miss that one. You are indeed right.

Can we then rename the flag and setting? Since we indeed don't just ignore the requests ignore_verification_events might make more sense.

Box::pin(self.handle_verification_event(e, room.room_id()))
.await?;
if !ignore_verification_requests {
Box::pin(self.handle_verification_event(e, room.room_id()))
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we use this ignore_verification_requests inside the handle_verification_event method instead of here?

#[instrument(skip_all, level = "trace")]
pub async fn process_sliding_sync<PEP: PreviousEventsProvider>(
&self,
response: &http::Response,
previous_events_provider: &PEP,
ignore_verification_requests: bool,
Copy link
Member

Choose a reason for hiding this comment

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

Can't we get this information from the BaseClient instead of passing an argument everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BaseClient doesn't hold this parameter, and it makes sense that it doesn't AFAICT, since this is something only the sliding sync should know, since it can (and will in Android) wrap an existing client that wants to process the verification requests.

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.

3 participants