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

Bring high level room joining logic into GMSL #372

Merged
merged 18 commits into from
Apr 27, 2023
Merged

Bring high level room joining logic into GMSL #372

merged 18 commits into from
Apr 27, 2023

Conversation

devonh
Copy link
Contributor

@devonh devonh commented Apr 24, 2023

No description provided.

@codecov
Copy link

codecov bot commented Apr 24, 2023

Codecov Report

Patch coverage: 55.30% and project coverage change: +1.59 🎉

Comparison is base (8daeaeb) 51.82% compared to head (c135a99) 53.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #372      +/-   ##
==========================================
+ Coverage   51.82%   53.41%   +1.59%     
==========================================
  Files          37       38       +1     
  Lines        5775     5996     +221     
==========================================
+ Hits         2993     3203     +210     
+ Misses       2491     2473      -18     
- Partials      291      320      +29     
Impacted Files Coverage Δ
errors.go 0.00% <0.00%> (ø)
fclient/federationclient.go 11.87% <0.00%> (-0.24%) ⬇️
fclient/federationtypes.go 25.34% <0.00%> (+0.71%) ⬆️
performjoin.go 60.00% <60.00%> (ø)
authchain.go 85.29% <100.00%> (ø)
authstate.go 45.56% <100.00%> (+20.25%) ⬆️
load.go 40.62% <100.00%> (ø)

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@kegsay kegsay left a comment

Choose a reason for hiding this comment

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

Some API changes would be good I think.

eventversion.go Outdated Show resolved Hide resolved
fclient/performjoin.go Outdated Show resolved Hide resolved
fclient/performjoin.go Outdated Show resolved Hide resolved
) {
event = remoteEvent
}
}
Copy link
Member

Choose a reason for hiding this comment

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

We seemingly continue blindly if the event is invalid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know what the logic should be if you receive a bad event inside a send_join response.
Synapse just accepts the event as is and doesn't seem to do any checks against it. So we differ from them in that regard.

At this point in the join dance, the resident server has already accepted that event into it's room graph and propagated it out to the other servers in the room. So for us to reject it leaves us in an awkward situation.

fclient/performjoin.go Outdated Show resolved Hide resolved
fclient/performjoin.go Outdated Show resolved Hide resolved
fclient/performjoin.go Outdated Show resolved Hide resolved
fclient/performjoin.go Outdated Show resolved Hide resolved
fclient/performjoin.go Outdated Show resolved Hide resolved
Copy link
Member

@kegsay kegsay left a comment

Choose a reason for hiding this comment

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

Overall LGTM!

fclient/federationclient.go Outdated Show resolved Hide resolved

type FederatedJoinClient interface {
MakeJoin(ctx context.Context, origin, s spec.ServerName, roomID, userID string) (res MakeJoinResponse, err error)
SendJoin(ctx context.Context, origin, s spec.ServerName, event *Event) (res SendJoinResponse, err error)
Copy link
Member

Choose a reason for hiding this comment

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

This is okay for now, but I'm wondering if we can be less specific long term. If we ever decide to change the flow here (removing make_join, adding a third stage) then everything needs to change which is unfortunate. It would be nice to hide this behind the room version PDU bits longer term I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. That might require some more extensive refactoring. This follows the same pattern as requests to /state. The problem is that Dendrite provides this to GMSL. So for current join flows GMSL requires something that can hit the /make_join and the /send_join endpoints.
If we instead just pass down the something that meets the entire FederationClient interface, then GMSL can more easily adapt it's flows. But by creating this sub-interface it is a little more perscriptive.

performjoin.go Outdated Show resolved Hide resolved
return nil, &FederationError{
ServerName: input.ServerName,
Transient: true,
Reachable: false,
Copy link
Member

Choose a reason for hiding this comment

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

This assumes a network error, but I'm fairly sure we will return an err on non-2xx as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. This keeps the behaviour the same as before the refactor. I tried to limit behaviour changes in this PR

if err != nil {
return nil, &FederationError{
ServerName: input.ServerName,
Transient: false,
Copy link
Member

Choose a reason for hiding this comment

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

Hard to say if this is transient as it may have failed due to failing to get server keys over the network.

@kegsay
Copy link
Member

kegsay commented Apr 26, 2023

Oh and please add tests for the main logic here. It should be easy now as we've interfaced up the fed client!

@devonh devonh merged commit 809b162 into main Apr 27, 2023
@devonh devonh deleted the devon/move-join branch April 27, 2023 00:23
devonh added a commit to matrix-org/dendrite that referenced this pull request Apr 27, 2023
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