-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Labels
designRequires designRequires designepicBig issue with multiple subissuesBig issue with multiple subissuesr&d:polykey:core activity 1Secret Vault Sharing and Secret History ManagementSecret Vault Sharing and Secret History Managementr&d:polykey:core activity 3Peer to Peer Federated HierarchyPeer to Peer Federated Hierarchy
Description
We have reviewed the gRPC API, and worked with it extensively. It's time to work out a better RPC layer for PK. There are several problems to to consider here:
- Cohesion
- Pagination
- Streaming and unification with pagination
- Client streaming can support some client usecases where only the client process has the data
- Authentication & Sessions - usage of metadata and bearer & basic tokens
- Client and Server Interception (Middleware)
- How client interception works: Session Bin Test Fixes #296 (comment)
- Add server interceptors grpc/grpc-node#419
- Client interceptors are available and are used in
src/client - Server interceptors are not yet available, so instead we use DIed functions like
authenticator
- CQRS in order to maintain consistency between different clients
- Naming Standardisation
- HTTP API portability and Web Gateway Portability
- Error handling
- https://www.grpc.io/docs/guides/error/
- We serialize our PK exceptions and then pass them to the client where it deserializes exceptions
- Do we have to consider backwards compatibility here? What happens if the agent side serializes an exception that doesn't exist on the client side code, the client side should gracefully handle this by throwing a generic exception that indicates the client doesn't understand the exception (but provide exception details)
- Resolve trailing metadata usage and sensitive information being exposed in exceptions Transport Agnostic RPC #249 (comment)
- Typescript Compatibility
- API versioning
- How should PK API be versioned? Should we always try to maintain 100% backwards compatibility, or have some way of versioning incompatible changes?
- How is a version signaled in gRPC? In REST this can be done in the URL or in the header metadata
- Guide from Microsoft https://docs.microsoft.com/en-us/aspnet/core/grpc/versioning?view=aspnetcore-5.0
- GRPC service version would be independent of the js-polykey version which is independent from the state version, which would give us 3 versions to manage:
- pk source version - updated when source code changes, minor is new features, major is any new incompatibility from anywhere: cli, service, node state... etc, e.g.
1.0.0 -> 1.1.0 -> 2.0.0 -> 2.0.1 - grpc service version - only major version and only changes on breaking changes, e.g.
1 -> 2 -> 3 - node state version - only major version and only changes on breaking changes to the node state, e.g.
1 -> 2 -> 3
- pk source version - updated when source code changes, minor is new features, major is any new incompatibility from anywhere: cli, service, node state... etc, e.g.
We have 2 main proto files:
proto/schemas/Client.protoproto/schemas/Agent.proto
And a Test.proto as well, this will need to be used to generate the marshaling code.
Additional context
- React Native and Mobile OS (iOS and Android) Compatibility #155 - compatibility with Mobile operating systems
- Third Party Integration - HTTP API, OAuth2 Provider API, Plugin API, Library vs Framework, Smart Tokens #166 - having a transport agnostic RPC will make it easier for third party integration as it's possible to extend the different transport options to communicate with the PK agent - such as TCP, and UDP... etc
- GRPC Web Proxy to enable Browser Integration and Eliminate Electron IPC #235 - would not be a problem anymore if a web-based transport is enabled, either that or if electron directly bridges into the nodejs runtime (rather than having the FE call into a BE proxy) - this is also relevant to any browser-extensions
- Async API for Notifications & Delay-Tolerant Synchronisation #248 - some RPC functionality is intended to support asynchronous API, should consider these design requirements for notifications
- Using QUIC/HTTP3 to replace utp-native for the Data Transfer Layer in the networking domain #234 - our RPC should be compatible on the transport layer for P2P communication, P2P hole punching occurs underneath the RPC layer, so the P2P side has to bootstrap from a lower level communication protocol which is purely message oriented
- IPv6 Support #400 - the RPC should be agnostic to IPv4 or IPv6
- Asynchronous Promise Cancellation with Cancellable Promises, AbortController and Generic Timer #297 - RPC mechanism must be cancellable ideally using cancellable promises, which includes cancelling the underlying side effect
- Apply
timedCancellabletoSigchainsuch as the deadline in nodes claim process #243 - it's a good idea for the RPC to have timeouts on its calls and to handle such timeouts, in particular we would want to be able to create "custom" protocols on top of any streams, or better would be to "lift" such protocols into the the underlying RPC system such as the nodes claiming process - https://exploringjs.com/nodejs-shell-scripting/ch_web-streams.html - Explanation of how to use Web Streams
Tasks
- - Review the proto3 guide, naming standard with reference to the proto files, look for ways to abstract or clean up the data
- Creating
.protodefinition subdomains. #279 - - Version the
Client.protoandAgent.protowith version names and test out multiple-version services, and find out what the client does when the version wanted is not available - - Test out grpc reflection for versioning if necessary
- - Update all the primitive types, and any usage of 64 bit int should have the string hint
- - Add some benchmarks to the grpc, and check if
MAX_CONCURRENT_CONNECTIONSis used - - Clean up types Wrapper methods in GRPCClientClient to get parameter types of the wrapped GRPC call #200 or gRPC abstractions based on new grpc libraries
- - Consider how to shutdown the grpc server and terminate all client connections as well
- Creating
- - Figure out CQRS, pagination and streaming
- - Clean up js-pagination client and server side utilities
- - Pagination on unary calls, and streaming calls that can be initialised with a pagination parameters (which would enable some sort of CQRS and event sourcing concepts)
- - Review in reference to authentication and sessions
- - Fix Exceptions with Sensitive Data and Trailing Metadata Usage Transport Agnostic RPC #249 (comment)
- - Check the HTTP API and web gateway compatibility
- - Deal with the fact that the new grpc-js
1.4.1version has some incompatibility:TypeError: http2Server.on is not a function.
Metadata
Metadata
Assignees
Labels
designRequires designRequires designepicBig issue with multiple subissuesBig issue with multiple subissuesr&d:polykey:core activity 1Secret Vault Sharing and Secret History ManagementSecret Vault Sharing and Secret History Managementr&d:polykey:core activity 3Peer to Peer Federated HierarchyPeer to Peer Federated Hierarchy