-
Notifications
You must be signed in to change notification settings - Fork 378
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
Introduce capabilites #6482
Conversation
db70c20
to
bae4c2d
Compare
This adds configuration, settings and parser for capabilities.
f38e752
to
080a596
Compare
There was a problem hiding this 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.
As we discussed out-of-band, we do a mapping of |
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this 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
@ulope you wanted to discuss the serialization format of the capabilities, no? |
Add protocol capabilities to the transport handshake
Fixes: #3283
utils/capability.py
https://github.com/raiden-network/raiden/pull/6482/files#diff-f02562dc4c1065f371e6994f4ba7c2c2avatar_url
with capability strings of the format defined in Introduce protocol handshake #3283 (comment)constants.py
https://github.com/raiden-network/raiden/pull/6482/files#diff-fc15643f6fbeaa49665008430fe239bbR85-R94settings.py
https://github.com/raiden-network/raiden/pull/6482/files#diff-14a4915b775dfbab039e080a28553d78R130-R137login
ofmatrix/utils.py
https://github.com/raiden-network/raiden/pull/6482/files#diff-b10b960f92576b8e90998119485c75ebR704PeerCapabilities
are updated