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

Notifications subsystem #192

Closed
CMCDragonkai opened this issue Jul 3, 2021 · 15 comments
Closed

Notifications subsystem #192

CMCDragonkai opened this issue Jul 3, 2021 · 15 comments
Assignees
Labels
development Standard development enhancement New feature or request r&d:polykey:core activity 3 Peer to Peer Federated Hierarchy

Comments

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Jul 3, 2021

The notifications subsystem allows nodes from different gestalts to send messages to each other.

This is the way that users can tell other gestalts that they have shared a vault with them.

  • Number of messages must be limited possibly 10,000, afterwards the messages are dropped
  • Must use the ACL notify permission action
  • Need to consider that once a message is read by any, that message is kept around in the notification queue, but is considered to have been read

See https://gitlab.com/MatrixAI/Engineering/Polykey/js-polykey/-/merge_requests/204

Specification (from node notifications MR!161 in js-polykey):

  • Agent GRPC exposes sendMessage and readMessage.
  • Node GRPC exposes receiveMessage.
  • Client will trigger sendMessage to Agent.
  • Agent then connects to the node using NodeId and triggers a Node GRPC which is recieveMessage.
  • Other Agent will push messages to the Notification object.
  • Other Client can now shift all messages from the Notification object using readMessage that is a GRPC stream.

Note: gPRC calls should follow style outlined in #218

TODO

  • New domain notifications
  • Create Notification class
  • Inject ACL, DB, NodeManager as dependencies
  • Create the send and receive calls
  • Make a limit on the number of messages allowed
  • Check the ACL for permissions
  • Create the Agent GRPC calls to receive messages
  • Use the NodeManager to send out messages
  • Create tests for Notification class
  • Create pk notifications sub commands to introspect notifications
  • You might want to have a "read" status attached to each message indicating
  • Create tests for the pk notifications
@CMCDragonkai CMCDragonkai modified the milestones: Polykey CLI 1.0.0 Release, Polykey GUI 1.0.0 Release Jul 3, 2021
@CMCDragonkai CMCDragonkai added design Requires design development Standard development enhancement New feature or request labels Jul 3, 2021
@CMCDragonkai
Copy link
Member Author

When using the NodesManager, this is just making a call to send a message.

The Notifications will probably need the NodeManager as a dependency injection.

@DrFacepalm DrFacepalm removed the design Requires design label Jul 9, 2021
@CMCDragonkai
Copy link
Member Author

You do need to use the ACL to see if the there is a notify permission allowed on nodes trying to contact you.

@emmacasolin
Copy link
Contributor

Some previous work on the notifications was done in these two MRs:
https://gitlab.com/MatrixAI/Engineering/Polykey/js-polykey/-/merge_requests/146 - discussion of capabilities/potential implementations + a bit of code
https://gitlab.com/MatrixAI/Engineering/Polykey/js-polykey/-/merge_requests/161 - copy of above but actually merged

@CMCDragonkai
Copy link
Member Author

CMCDragonkai commented Jul 12, 2021 via email

@emmacasolin
Copy link
Contributor

A merge request has been created for this issue: https://gitlab.com/MatrixAI/Engineering/Polykey/js-polykey/-/merge_requests/204

@CMCDragonkai
Copy link
Member Author

You can store the count of the number of messages you have received in the domain-level DB. Then you create a sub level to store the actual messages.

Example see how ACL does it:

  protected notificationsDbDomain: string = this.constructor.name;
  protected notificationsMessagesDbDomain: Array<string> = [this.notificationsDbDomain, 'messages'];
  protected notificationsDb: DBLevel<string>;
  protected notificationsMessagesDb: DBLevel<NotificationId>;

      const notificationsDb = await this.db.level<string>(this.notificationsDbDomain);
      const notificationsMesssagesDb = await this.db.level<NotificationId>(
        this.notificationsMessagesDbDomain[1],
        notificationsDb,
      );

Use the notificationsDb to store domain-level dynamic configuration like the counter of messages.

The messages need to be ordered with respect to time. So you'll need a monotonic-lexicographic-integer. https://github.com/vweevers/monotonic-lexicographic-timestamp

Then if the messages exceeds the max limit, you can garbage collect old messages by dropping them (deleting them) from the message sub level.

@CMCDragonkai
Copy link
Member Author

Also denial of service is reduced because you must trust the other gestalt which relies on the notify permission.

@emmacasolin
Copy link
Contributor

The messages need to be ordered with respect to time. So you'll need a monotonic-lexicographic-integer. https://github.com/vweevers/monotonic-lexicographic-timestamp

@CMCDragonkai should this be installed as a dependency or a devdependency?

@CMCDragonkai
Copy link
Member Author

It should be a dependency.

@CMCDragonkai
Copy link
Member Author

@emmacasolin hit some difficulties with the iteration of the database. @DrFacepalm is looking into this by Friday and try to get as much done over the weekend as well.

@CMCDragonkai
Copy link
Member Author

@emmacasolin @DrFacepalm how is this going? What's the final remaining set of tasks?

@CMCDragonkai
Copy link
Member Author

Schedule this for merging (even if not entirely clean) for Monday.

New things can be assigned on top of this based on review of issues generated from Nodes CLI.

@CMCDragonkai
Copy link
Member Author

CMCDragonkai commented Aug 11, 2021 via email

@emmacasolin
Copy link
Contributor

Any follow-up issues regarding this issue since merging?

Nothing that I'm aware of, although I haven't been working on the code base since merging so others may be more likely to have run into issues if they're there

@CMCDragonkai
Copy link
Member Author

CMCDragonkai commented Aug 11, 2021 via email

@CMCDragonkai CMCDragonkai added the r&d:polykey:core activity 3 Peer to Peer Federated Hierarchy label Jul 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Standard development enhancement New feature or request r&d:polykey:core activity 3 Peer to Peer Federated Hierarchy
Development

No branches or pull requests

5 participants