Skip to content

Introduce capabilites #6482

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

Merged

Conversation

konradkonrad
Copy link
Contributor

@konradkonrad konradkonrad commented Aug 25, 2020

Add protocol capabilities to the transport handshake

Fixes: #3283

@konradkonrad konradkonrad force-pushed the introduce_capabilites branch 2 times, most recently from db70c20 to bae4c2d Compare August 31, 2020 09:10
@konradkonrad konradkonrad force-pushed the introduce_capabilites branch from f38e752 to 080a596 Compare August 31, 2020 12:16
Copy link
Contributor

@fredo fredo left a comment

Choose a reason for hiding this comment

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

Over all looks very good to me. I commented some nitpicks/questions.

One topic I'd like to clarify before approve:

I wonder if the capabilities should be mapped to a user_id or an address. I noticed that question because some variables seem a bit confusing to me. While for reachability we usually use the prefix user_ or address_, when it comes to capabilities we have peer_, address_to_ and in the fixtures user_- capabilities.

Is there any rationale behind or rather what do you think to what the capabilites should be mapped to? And if there is a clear answer, a consistent naming would probably avoid confusion in the future.

@konradkonrad
Copy link
Contributor Author

Over all looks very good to me. I commented some nitpicks/questions.

One topic I'd like to clarify before approve:

I wonder if the capabilities should be mapped to a user_id or an address. I noticed that question because some variables seem a bit confusing to me. While for reachability we usually use the prefix user_ or address_, when it comes to capabilities we have peer_, address_to_ and in the fixtures user_- capabilities.

Is there any rationale behind or rather what do you think to what the capabilites should be mapped to? And if there is a clear answer, a consistent naming would probably avoid confusion in the future.

As we discussed out-of-band, we do a mapping of address <-> capabilities now. We re-query the capabilities only on reachability changes, for the "best reachable" user_id, see https://github.com/raiden-network/raiden/pull/6482/files#diff-b10b960f92576b8e90998119485c75ebR366-R406

@konradkonrad konradkonrad marked this pull request as ready for review September 1, 2020 12:44
@@ -347,11 +366,12 @@ def get_reachability_from_matrix(self, user_ids: Iterable[str]) -> AddressReacha
def _maybe_address_reachability_changed(self, address: Address) -> None:
# A Raiden node may have multiple Matrix users, this happens when
# Raiden roams from a Matrix server to another. This loop goes over all
# these users and uses the "best" presence. IOW, if there is a single
# these users and uses the "best" presence. IOW, if there is at least one
Copy link
Contributor

Choose a reason for hiding this comment

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

I just had a discussion with @ulope about the feasability of allowing multiple users of the same address online. This should actually be forbidden per definition because it would imply multiple usage of the same keystore. A raiden node could prevent starting if a user for the same address is found online.

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 comment change was only to reflect the current code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then we should ask us if we should change the code. Why should we handle multiple users being online if this should be prevented anyway?
But on the other hand this could also be implemented in a different PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should create a follow up issue to discuss this:

  • for a canonical client, we can definitely try to forbid multiple logins
  • for the peer handling side (such as here), we have to deal with the possibility of multiple logins
  • I don't know how roaming user ids behave, when it comes to login/logout. We need to clarify if there are interleaved states, where the old user_id still appears online, while the new user_id already came up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. A user is set to be offline by the server whenever he did not longpoll sync() for 30s. This definitely leaves the possibility open to appear online with 2 user ids for the same address.

# Matrix user that is reachable, then the Raiden node is considered
# reachable.
userids = self._address_to_userids[address].copy()
composite_presence = {self._userid_to_presence.get(uid) for uid in userids}
presence_to_uid = {self._userid_to_presence.get(uid): uid for uid in userids}
composite_presence = set(presence_to_uid.keys())
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference here to the old code?

Copy link
Contributor Author

@konradkonrad konradkonrad Sep 1, 2020

Choose a reason for hiding this comment

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

We preserve the mapping presence <-> user_id in order to pull the avatar_url for a user_id that has the new_presence.

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 old code was only concerned with ordering presences.

Copy link
Contributor

@fredo fredo left a comment

Choose a reason for hiding this comment

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

thanks for the changes! lgtm

@konradkonrad konradkonrad changed the title [WIP] Introduce capabilites Introduce capabilites Sep 2, 2020
@konradkonrad
Copy link
Contributor Author

konradkonrad commented Sep 2, 2020

@ulope you wanted to discuss the serialization format of the capabilities, no?

@konradkonrad konradkonrad merged commit dad9c59 into raiden-network:develop Sep 2, 2020
@konradkonrad konradkonrad deleted the introduce_capabilites branch September 2, 2020 12:16
karlb pushed a commit that referenced this pull request Oct 9, 2020
This ports protocol handshake (#3283 / #6503) capabilities from #6482 / #6572
back to the release branch.
fredo added a commit that referenced this pull request Nov 6, 2020
Changelog for Capabilities
karlb pushed a commit that referenced this pull request Nov 6, 2020
Changelog for Capabilities
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.

Introduce protocol handshake
2 participants