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

SCP-002: Datastore P2P interface #4

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

Conversation

vaultec81
Copy link
Member

No description provided.

Copy link
Member

@aphelionz aphelionz left a comment

Choose a reason for hiding this comment

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

So it begins

@@ -0,0 +1,69 @@
## SCP-002: Datastore P2P interface
Copy link
Member

Choose a reason for hiding this comment

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

Right out of the gates I think we're gonna want to look at this one layer of abstraction upward:

This interface should be flexible enough to handle the internal needs of the datastores, as well as the external needs of whatever pubsub interface we end up using.

Internal requirements are defined as whatever this proposal ends up being, as well as whatever the current functionality is.

External means that eventually OrbitDB should be able to use MQTT, IPFS pubsub, whatever else we can think of
https://github.com/orbitdb/orbit-db-pubsub

Copy link
Member Author

@vaultec81 vaultec81 Dec 19, 2020

Choose a reason for hiding this comment

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

For example one possible external and internal requirement of the interface might be the use of a peerId in the pubsub messages to verify authenticity. However, if the pubsub like system being utilized does not support cryptographically signed peerIds and messages, then it might break certain functionality. I am not sure if MQTT has support for cryptographically signed messages and peerIds. If so we also need to make sure the formatting of these constructs is compatible, or can be transformed into a data type that is indifferent between systems.

* The network: Cloud of peers all interconnected interested in the datastore in question
* Broadcast channel: Global pubsub channel of the corresponding datastore.
* Application specific P2P API: Interface diagrammed by higher level code implementing `orbit-db-store`; Defined by the store type.

Copy link
Member

Choose a reason for hiding this comment

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

We should diagram this. I might take a stab at it.

### Hypothetical model N1
> Note all p2p traffic is over IPFS pubsub

**Flow**:
Copy link
Member

Choose a reason for hiding this comment

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

Note the prior work here:

Ideally we'd appropriate these (or at least get commit access)

**Flow**:

1. Asking peer joins store broadcast channel. (Example: Asking peer is just starting up and gets connected to the network)
2. Responding peer broadcasts a small message to all the other peers containing information regarding what diagrams/protocol it supports. Including Public key for encryption, if needed, and a forwarding pubsub channel ID (a channel where asking peers can send messages directly to the responding peer, derived from the peerId). The forwarding channel isn't designed to be a back and forth between a responding peer and an asking peer. Only a temporary channel for negotiating a direct peer-to-peer connection.
Copy link
Member

Choose a reason for hiding this comment

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

TODO: Research this at the IPFS level. I believe they have something like this now, or at least something experimental.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is some work being done for standardized data encryption as well as multikey, but it hasn't had much work done on it.
See
ipld/specs#257
ipfs-inactive/docs#87
ipfs/specs#58

More clarification would be helpful

* Pubsub relays can help with routing packets to peers behind a firewall.

**Disadvantages**
* No P2P transport security out of the box. Higher chance of an adversory capturing P2P messages
Copy link
Member

Choose a reason for hiding this comment

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

At least we have handshake security with the Noise protocol. Wondering what else we can utilize. However, with the externally-pluggable requirement we should probably handle this at the orbit-db-pubsub level

Copy link
Member Author

Choose a reason for hiding this comment

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

I am unaware the Noise protocol can be used over pubsub? Are you talking about noise protocol in regards to libp2p? Could you provide some more clarification?

scps/SCP-002.md Outdated Show resolved Hide resolved
* Peer discovery/rendezvous might be an issue.
* Requires building custom systems to accomplish the same level of functionality as Model N2.

### Hypothetical model N2
Copy link
Member

Choose a reason for hiding this comment

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

At first read I like this approach in general. Let's keep iterating on it.

Still relying on all peers to have a public/private key for the oplog entry signing.
* Querying other peers instead of searching local store.

Further discussion and comments is appreciated.
Copy link
Member

Choose a reason for hiding this comment

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

I would describe this as something similar to how you can define your own Index and Store classes when you extend orbit-db-store. It might be interesting to see it as a sibling class to those in a store implementation. Index, Store, and Messages, or some such thing

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.

2 participants