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

Add spec for the contact request refactor #154

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

Conversation

jrainville
Copy link
Member

Specs Contacts, the contact requests and the way to persist them on the network.

Copy link
Contributor

@cammellos cammellos left a comment

Choose a reason for hiding this comment

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

Overall looks good, nice work and thanks for writing this up!
I have some questions/comments about the ContactUpdate section.

The spec is a bit implementation heavy (we probably don't want to talk about tables etc, as clients might use different databases for example), but rather just behaviors.

@@ -275,6 +288,16 @@ Messages with a `clock` less than `120` seconds under the Whisper/Waku timestamp

The node uses `clock` value for the message ordering. The algorithm used, and the distributed nature of the system produces casual ordering, which might produce counter-intuitive results in some edge cases. For example, when a user joins a public chat and sends a message before receiving the exist messages, their message `clock` value might be lower and the message will end up in the past when the historical messages are fetched.

#### Signature
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to define what the signature is composed of.

Basically we need to prove that a user really wanted to add another user to contacts.
So something like Sign(Keccak256(PK1 + PK2 + some custom bytes to make sure the signature can't be reused for a differet purpose)

Also probably we should name the field something a bit more meaningful

| Field | Name | Type | Description |
| ----- | ---- | ---- | ---- |
| 1 | id | `string` | ID of the contact. Hex-encoded public key (prefixed with 0x). |
| 2 | address | `string` | Ethereum address of the contact |
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a legacy field, we used to have it once wallet was derived by the public key, but in case pk is enough.

| 3 | name | `string` | Contact's ENS name |
| 4 | ensVerified | `bool` | Whether the name of the contact is verified |
| 5 | alias | `string` | Contact's generated username |
| 6 | identicon | `string` | Identicon generated from public key |
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to send this over, as it can be generated by the pk

| 9 | added | `bool` | Whether the contact is added |
| 10 | requestReceived | `bool` | Whether the contact requested us to add them |
| 11 | mutualContact | `bool` | Whether the contact is mutual |
| 12 | deviceInfo | `[]ContactDeviceInfo` | |
Copy link
Contributor

Choose a reason for hiding this comment

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

This might also be legacy and not used anymore

| 2 | address | `string` | Ethereum address of the contact |
| 3 | name | `string` | Contact's ENS name |
| 4 | ensVerified | `bool` | Whether the name of the contact is verified |
| 5 | alias | `string` | Contact's generated username |
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to send this over as generated by the pk

`Contact` is a representation of other accounts encountered on the app. They are added through `ContactUpdate`s propagated.
A `Contact` does not mean a "friend". Any account from which we receive a `ContactUpdate` is added to the table.

Users are considered "Friends" when they are **mutual** contacts, meaning that both of them have the `added` and `requestReceived` boolean set as `true`, which then triggers setting `mutualContact` to `true`. This is done through `ContactRequest`s.
Copy link
Contributor

Choose a reason for hiding this comment

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

When is this sent exactly?
the payload below looks ok if it's to be sent to your devices for syncing contacts, but otherwise is too many info for sending to other users.

@jakubgs
Copy link
Member

jakubgs commented Sep 13, 2021

Is this PR dead?

@cammellos cammellos force-pushed the feature/contact-requests branch 2 times, most recently from 52209af to de58fbf Compare October 4, 2021 10:51
@jrainville
Copy link
Member Author

@cammellos sorry for the late reply. I was on vacation when you did the changes so I missed it and before that, this feature was not a priority so I had pushed it back.

Anyway, I rebased the PR, fixed a typo and also reviewed your changes.
It looks good, my only question would be what happens with the "contact persistence" part? I saw that you removed it. Is it because it was too implementation heavy or just because it is no longer wanted?

I can understand if it is the latter, since it would have been heavy on the network and also harder to implement. The contact signature is easier and also does solve the 1-1 chat issues we have.
However, we will still have the issue of losing all your contacts on account import. Is it fixed using the normal sync instead (between devices)?

@cammellos
Copy link
Contributor

@jrainville
thanks for the review,

It looks good, my only question would be what happens with the "contact persistence" part? I saw that you removed it. Is it because it was too implementation heavy or just because it is no longer wanted?

We have now implemented contact backup, it hasn't been specced yet, but it's already in develop (and likely in desktop), and it works slightly differently, so I thought I'd remove it

@jrainville
Copy link
Member Author

Turns out I can't approve my own PR 😅
Anyway, merge whenever you want.

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