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

docs: Updated readme P2P section #220

Merged
merged 1 commit into from
Feb 18, 2022
Merged

Conversation

jsimnz
Copy link
Member

@jsimnz jsimnz commented Feb 18, 2022

A simple update to add the P2P data sync section to the README, which can be further used by the docs team to create guides.

Closes #219

@jsimnz jsimnz added the documentation Improvements or additions to documentation label Feb 18, 2022
@jsimnz jsimnz self-assigned this Feb 18, 2022
@jsimnz jsimnz merged commit af5432a into develop Feb 18, 2022
@jsimnz jsimnz deleted the jsimnz/docs/readme-p2p-section branch February 18, 2022 09:27
Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

Minor typos

@@ -282,9 +282,90 @@ This only scratches the surface of the DefraDB Query Language, see below for the

You can access the official DefraDB Query Language documentation online here: [https://hackmd.io/@source/BksQY6Qfw](https://hackmd.io/@source/BksQY6Qfw)

## Peer-to-Peer Data Syncronization
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## Peer-to-Peer Data Syncronization
## Peer-to-Peer Data Synchronization

The P2P network uses a combination of server to server gRPC commands, gossip based pub-sub network, and a shared Distributed Hash Table, all powered by
[LibP2P](https://libp2p.io/).

Unless specifying `--no-p2p` option when running `start` the default behaviour for a DefraDB node is to intialize the P2P network stack.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Unless specifying `--no-p2p` option when running `start` the default behaviour for a DefraDB node is to intialize the P2P network stack.
Unless specifying `--no-p2p` option when running `start` the default behavior for a DefraDB node is to initialize the P2P network stack.


When you start a node for the first time, DefraDB will auto generate a private key pair and store it in the `data` folder specified in the config or `--data` CLI option. Each node has a unique `Peer ID` generated based on the public key, which is printed to the console during startup.

You'll see a printed line: `Created LibP2P host with Peer ID XXX` where `XXX` is your nodes `Peer ID`. This is important to know if we want other nodes to connect to this node.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
You'll see a printed line: `Created LibP2P host with Peer ID XXX` where `XXX` is your nodes `Peer ID`. This is important to know if we want other nodes to connect to this node.
You'll see a printed line: `Created LibP2P host with Peer ID XXX` where `XXX` is your node's `Peer ID`. This is important to know if we want other nodes to connect to this node.


> If a node is listening on port 9000 with the IP address `192.168.1.12` and a Peer ID of `12D3KooWNXm3dmrwCYSxGoRUyZstaKYiHPdt8uZH5vgVaEJyzU8B` then the fully quantified multi address is `/ip4/192.168.1.12/tcp/9000/p2p/12D3KooWNXm3dmrwCYSxGoRUyZstaKYiHPdt8uZH5vgVaEJyzU8B`.

Pubsub nodes *passively* synchronize data between nodes by broadcasting Document Commit updates over the pubsub channel with the document `DocKey` as the topic. This requires nodes to already be listening on this pubsub channel to recieve updates for. This is used when two nodes *already* have a shared document, and want to keep both their changes in sync with one another.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Pubsub nodes *passively* synchronize data between nodes by broadcasting Document Commit updates over the pubsub channel with the document `DocKey` as the topic. This requires nodes to already be listening on this pubsub channel to recieve updates for. This is used when two nodes *already* have a shared document, and want to keep both their changes in sync with one another.
Pubsub nodes *passively* synchronize data between nodes by broadcasting Document Commit updates over the pubsub channel with the document `DocKey` as the topic. This requires nodes to already be listening on this pubsub channel to receive updates for. This is used when two nodes *already* have a shared document, and want to keep both their changes in sync with one another.

defradb start --data $HOME/.defradb/data-node2 --p2paddr /ip4/0.0.0.0/tcp/9172 --url localhost:9182 --peers /ip4/0.0.0.0/tcp/9171/p2p/12D3KooWNXm3dmrwCYSxGoRUyZstaKYiHPdt8uZH5vgVaEJyzU8B
```

Lets break this down
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Lets break this down
Let's break this down


### Replicator Example

Lets construct a simple example of Node1 *replicating* to Node2.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Lets construct a simple example of Node1 *replicating* to Node2.
Let's construct a simple example of Node1 *replicating* to Node2.

- `--data` specifies the data folder
- `--p2paddr` is the multiaddress to listen on for the p2p network (default is port 9171)
- `--url` is the HTTP address to listen on for the client HTTP and GraphQL API.
- `--peers` is a comma-sperated list of peer multiaddresses. This will be our first node we started, with the default config options.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- `--peers` is a comma-sperated list of peer multiaddresses. This will be our first node we started, with the default config options.
- `--peers` is a comma-separated list of peer multi-addresses. This will be our first node we started, with the default config options.


There are two types of relationships a given DefraDB node can establish with another peer, which is a pubsub peer or a replicator peer.

Pubsub peers can be specified on the command line with `--peers` which accepts a comma seperated list of peer [MultiAddress](https://docs.libp2p.io/concepts/addressing/). Which take the form of `/ip4/IP_ADDRESS/tcp/PORT/p2p/PEER_ID`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Pubsub peers can be specified on the command line with `--peers` which accepts a comma seperated list of peer [MultiAddress](https://docs.libp2p.io/concepts/addressing/). Which take the form of `/ip4/IP_ADDRESS/tcp/PORT/p2p/PEER_ID`.
Pubsub peers can be specified on the command line with `--peers` which accepts a comma-separated list of peer(s) [MultiAddress](https://docs.libp2p.io/concepts/addressing/). Which takes the form of `/ip4/IP_ADDRESS/tcp/PORT/p2p/PEER_ID`.

- `--url` is the HTTP address to listen on for the client HTTP and GraphQL API.
- `--peers` is a comma-sperated list of peer multiaddresses. This will be our first node we started, with the default config options.

This will startup two nodes, connect to eachother, and establish the P2P gossib pubsub network.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This will startup two nodes, connect to eachother, and establish the P2P gossib pubsub network.
This will startup two nodes, connect to each other, and establish the P2P gossib pubsub network.

shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update README with new P2P Section
2 participants