Skip to content

Commit

Permalink
Merge pull request #83 from ethersphere/beta-0.1
Browse files Browse the repository at this point in the history
Beta 0.1
  • Loading branch information
significance authored Oct 5, 2020
2 parents 191cb2d + bcfc87e commit 91ffd10
Show file tree
Hide file tree
Showing 10 changed files with 383 additions and 65 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ $ npm run build

This command generates static content into the `build` directory and can be served using any static contents hosting service.

## Bumping Version

Don't forget to find and replace the version number for the whole of the docs folder.

## How to generate / include the API reference html

Expand Down
101 changes: 62 additions & 39 deletions docs/advanced/pss.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ Out of the ashes of Ethereum's vision for a leak-proof decentralised anonymous m

PSS provides a pub-sub facility that can be used for a variety of tasks. Nodes are able to listen to messages received for a specific topic in their nearest neighbourhood and create messages destined for another neighbourhood which are sent over the network using Swarm's usual data dissemination protocols.

### Enable PSS On Your Node

In order to receive PSS messages you must first enable the p2p websockets API when starting your node.

```sh
bee start --p2p-ws-enable
```

### Subscribe and Receive Messages

Once your Bee node is up and running, you will be able to subscribe to feeds using websockets. For testing, it is useful to use the [websocat](https://docs.rs/crate/websocat/1.0.1) command line utility.
Expand All @@ -31,21 +23,31 @@ Our node is now watching for new messages received in it's nearest neighbourhood

Messages can be sent simply by sending a `POST` request to the PSS api endpoint.

When sending messages, we must specify a 'target' prefix of the recipients swarm address, a partial address representing their neighbourhood. Currently the length of this prefix is recommended to be two bytes, which will work well until the network has grown to a size of ca. 20-50K nodes.
When sending messages, we must specify a 'target' prefix of the recipients swarm address, a partial address representing their neighbourhood. Currently the length of this prefix is recommended to be two bytes, which will work well until the network has grown to a size of ca. 20-50K nodes. We must also provide the public key, so that Bee can encrypt the message in such a way that it may only be read by the intended recipient.

For example, if we want to send a PSS message with **topic** `test-topic` to a node with address...

`7bc50a5d79cb69fa5a0df519c6cc7b420034faaa61c175b88fc4c683f7c79d96`

For example, if we want to send a PSS message to a node with address `49d80b28adccd67a09959a601f0e28521aaeb06bf1bf17e9e012e7b597c3d926`, we must include the 'target' `49d8`.
...and public key...

`0349f7b9a6fa41b3a123c64706a072014d27f56accd9a0e92b06fe8516e470d8dd`

...we must include the **target** `7bc5` and the public key itself as a query argument.

```sh
curl -XPOST localhost:8082/pss/send/test/49d8 --data "Hello Swarm"
curl -XPOST \
localhost:8082/pss/send/test/7bc5?recipient=0349f7b9a6fa41b3a123c64706a072014d27f56accd9a0e92b06fe8516e470d8dd \
--data "Hello Swarm"
```

### Send Messages in a Test Network

Now, let's see this in action by setting up two Bee nodes, connecting them, and sending PSS messages from one to the other.
Now, let's see this in action by setting up two Bee nodes on a test network, connecting them, and sending PSS messages from one to the other.

First start two Bee nodes. We will start them with distinct ports for the api, debug api and p2p port so that there are no conflicts, since they will be running on the same computer.

Run the following command to start the first node. Note that we are passing `""` to the `--bootnode` argument so that our nodes will not connect to the network.
Run the following command to start the first node. Note that we are passing `""` to the `--bootnode` argument so that our nodes will not connect to a network.

```sh
bee start \
Expand All @@ -54,27 +56,26 @@ bee start \
--debug-api-addr=:6062 \
--data-dir=/tmp/bee2 \
--bootnode="" \
--p2p-ws-enable \
--p2p-addr=:7072 \
--swap-enable=false
```

We must make a note of the Swarm overlay address, underlay address and public key which are created once each node has started. We find this information from the addresses endpoint of the debug API.
We must make a note of the Swarm overlay address, underlay address and public key which are created once each node has started. We find this information from the addresses endpoint of the Debug API.

```sh
curl -s localhost:6062/addresses | jq
```

```json
{
"overlay": "c4773d0d7e8e0b7cc2145b1f9c149a0befecaf7cb2ed6eb83a32babe60a18646",
"overlay": "7bc50a5d79cb69fa5a0df519c6cc7b420034faaa61c175b88fc4c683f7c79d96",
"underlay": [
"/ip4/127.0.0.1/tcp/7072/p2p/16Uiu2HAkypRG6iEA86Vgq8xWrywcFyFHeuX9apCezcbS3cCjGtnL",
"/ip4/10.169.169.20/tcp/7072/p2p/16Uiu2HAkypRG6iEA86Vgq8xWrywcFyFHeuX9apCezcbS3cCjGtnL",
"/ip6/::1/tcp/7072/p2p/16Uiu2HAkypRG6iEA86Vgq8xWrywcFyFHeuX9apCezcbS3cCjGtnL",
"/ip4/81.98.94.4/tcp/38023/p2p/16Uiu2HAkypRG6iEA86Vgq8xWrywcFyFHeuX9apCezcbS3cCjGtnL"
"/ip4/127.0.0.1/tcp/7072/p2p/16Uiu2HAmP9i7VoEcaGtHiyB6v7HieoiB9v7GFVZcL2VkSRnFwCHr",
"/ip4/192.168.0.10/tcp/7072/p2p/16Uiu2HAmP9i7VoEcaGtHiyB6v7HieoiB9v7GFVZcL2VkSRnFwCHr",
"/ip6/::1/tcp/7072/p2p/16Uiu2HAmP9i7VoEcaGtHiyB6v7HieoiB9v7GFVZcL2VkSRnFwCHr"
],
"public_key": "02548ba0cec39e6cae23b698eeff8bebbfee45811cdcf77bc53f1f59c528d00b98"
"ethereum": "0x0000000000000000000000000000000000000000",
"public_key": "0349f7b9a6fa41b3a123c64706a072014d27f56accd9a0e92b06fe8516e470d8dd"
}
```

Expand All @@ -87,32 +88,36 @@ bee start \
--debug-api-addr=:6063 \
--data-dir=/tmp/bee3 \
--bootnode="" \
--p2p-ws-enable \
--p2p-addr=:7073 \
--swap-enable=false
```

```sh
curl -s localhost:6062/addresses | jq
curl -s localhost:6063/addresses | jq
```

```json
{
"overlay": "c7806e676ac14f0f20aba144299146131bd33635c5b814ab993752386496b2cb",
"overlay": "a231764383d7c46c60a6571905e72021a90d506ef8db06750f8a708d93fe706e",
"underlay": [
"/ip4/127.0.0.1/tcp/7073/p2p/16Uiu2HAmVTDofiUt3BKE739m3ozsUMGuzD8mo6agADkzmrJ33uvn",
"/ip4/192.168.0.10/tcp/7073/p2p/16Uiu2HAmVTDofiUt3BKE739m3ozsUMGuzD8mo6agADkzmrJ33uvn",
"/ip6/::1/tcp/7073/p2p/16Uiu2HAmVTDofiUt3BKE739m3ozsUMGuzD8mo6agADkzmrJ33uvn",
"/ip4/81.98.94.4/tcp/20044/p2p/16Uiu2HAmVTDofiUt3BKE739m3ozsUMGuzD8mo6agADkzmrJ33uvn"
"/ip4/127.0.0.1/tcp/7073/p2p/16Uiu2HAmAqJkKJqZjNhuDtepc8eBANM9TvagaWUThfTN5NkfmKTq",
"/ip4/192.168.0.10/tcp/7073/p2p/16Uiu2HAmAqJkKJqZjNhuDtepc8eBANM9TvagaWUThfTN5NkfmKTq",
"/ip6/::1/tcp/7073/p2p/16Uiu2HAmAqJkKJqZjNhuDtepc8eBANM9TvagaWUThfTN5NkfmKTq",
"/ip4/81.98.94.4/tcp/25178/p2p/16Uiu2HAmAqJkKJqZjNhuDtepc8eBANM9TvagaWUThfTN5NkfmKTq"
],
"public_key": "034de9400e9200d7b22b9c6ff72a1d6b424c97ae4f4e151dd7ab49741db22e1310"
"ethereum": "0x0000000000000000000000000000000000000000",
"public_key": "02d68d57d9f3fe539990cdf03e7de96d56a5c68b42515bc465acec4edc5cedfe35"
}
```

Because we configured the nodes to start with no bootnodes, neither node should have any peers yet.
Because we configured the nodes to start with no bootnodes, neither node should have peers yet.

```sh
curl -s localhost:6062/peers | jq
```

```sh
curl -s localhost:6062/peers | jq
curl -s localhost:6063/peers | jq
```

```json
Expand All @@ -121,42 +126,59 @@ Because we configured the nodes to start with no bootnodes, neither node should
}
```

Let's connect them using the localhost (127.0.0.1) underlay address we noted earlier.
Let's connect node 2 to node 1 using the localhost (127.0.0.1) underlay address for node 1 that we have noted earlier.

```sh
curl -XPOST localhost:6062/connect/ip4/127.0.0.1/tcp/7073/p2p/16Uiu2HAmVTDofiUt3BKE739m3ozsUMGuzD8mo6agADkzmrJ33uvn
curl -XPOST \
localhost:6063/connect/ip4/127.0.0.1/tcp/7072/p2p/16Uiu2HAmP9i7VoEcaGtHiyB6v7HieoiB9v7GFVZcL2VkSRnFwCHr
```

Now, if we check our peers endpoint for node 1, we can see our nodes are now peered together.

```sh
curl -s localhost:6062/peers | jq
curl -s localhost:6062/peers | jq
```

```json
{
"peers": [
{
"address": "a231764383d7c46c60a6571905e72021a90d506ef8db06750f8a708d93fe706e"
}
]
}
```

Of course, since we are p2p, node 2 will show node 1 as a peer too.

```sh
curl -s localhost:6063/peers | jq
```

```json
{
"peers": [
{
"address": "c7806e676ac14f0f20aba144299146131bd33635c5b814ab993752386496b2cb"
"address": "7bc50a5d79cb69fa5a0df519c6cc7b420034faaa61c175b88fc4c683f7c79d96"
}
]
}
```

We will use `websocat` to listen for PSS messages on a specific topic ID on our first node.
We will use `websocat` to listen for PSS messages topic ID `test-topic` on our first node.

```sh
websocat ws://localhost:8082/pss/subscribe/test-topic
```

Now we can use PSS to send a message from our second node to our first node.

Since our first node has a 2 byte address prefix of `c477`, we will specify this as the `targets` argument in our POST request. We must also include the public key of the recipient as a query parameter so that the message can be encrypted in a way only our recipient can decrypt.
Since our first node has a 2 byte address prefix of `a231`, we will specify this as the `targets` section in our POST request's URL. We must also include the public key of the recipient as a query parameter so that the message can be encrypted in a way only our recipient can decrypt.

```sh
curl \
-XPOST "localhost:8083/pss/send/test-topic/c477?recipient=02548ba0cec39e6cae23b698eeff8bebbfee45811cdcf77bc53f1f59c528d00b98"\
--data "Hello Swarm"
-XPOST "localhost:8083/pss/send/test-topic/7bc5?recipient=0349f7b9a6fa41b3a123c64706a072014d27f56accd9a0e92b06fe8516e470d8dd"\
--data "Hello Swarm"
```

The PSS API endpoint will now create a PSS message for it's recipient in the form of a 'Trojan Chunk' and send this into the network so that it may be pushed to the correct neighbourhood. Once it is received by it's destination target it will be decrypted and determined to be a message with the topic we are listening for. Our second node will decrypt the data and we'll see a message pop up in our `websocat` console!
Expand All @@ -166,3 +188,4 @@ sig :: ~ » websocat ws://localhost:8082/pss/subscribe/test-topic
Hello Swarm
```

Congratulations! 🎉 You have sent your first encrypted, zero leak message over Swarm!
8 changes: 5 additions & 3 deletions docs/community/community.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ title: Community
id: community
---

Swarm is all about community. We want to make sure you have the best possible experience as you join and enjoy being a part of the our new internet.

The Bee client has a vibrant community of developers and users who are ready to answer any questions and help you join the Swarm.
Swarm has a vibrant community of wonderful individuals who are eager to answer any questions and graciously welcome you to our swarm.

- Orange Lounge
- Mattermost
Join us at our self-sovereign [Bee Hive](https://beehive.ethswarm.org/) for peace, love, unity, respect, community, assistance and lots of highly obscure chat about cryptography.

Thanks for being here with us, making a difference, we appreciate you! 🐝
2 changes: 1 addition & 1 deletion docs/getting-started/start-your-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bee start \
--bootnode /dnsaddr/bootnode.staging.ethswarm.org
```

Since we haven't yet funded our account, we will see a message in our logs asking us to fund our Ethereum account. Navigate to the [Swarm Goerli Faucet](https://faucet.ethswarm.org/) and submit your address, ensuring it is prepended with the characters `0x` to the faucet, fill out the recaptcha and wait for confirmation that your GETH and gBZZ have been dispensed.
Since we haven't yet funded our account, we will see a message in our logs asking us to fund our Ethereum account. Navigate to the [Swarm Goerli Faucet](https://faucet.ethswarm.org/) and submit your address, ensuring it is prepended with the characters `0x` to the faucet, fill out the recaptcha and wait for confirmation that your gETH and gBZZ have been dispensed.

Now, we can run our Bee node and we will start to see Bee creating and waiting for transactions to complete. Please be patient as this might take a few moments.

Expand Down
2 changes: 1 addition & 1 deletion docs/installation/build-from-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ make binary
5) Check you are able to run the `bee` command. Success can be verified by running:
```sh
dist/bee version
> 0.2.0
> 0.3.0
```

6) (optional) Additionally, you may also like to move the Bee binary to somewhere in your `$PATH`
Expand Down
2 changes: 1 addition & 1 deletion docs/installation/configuration.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\---
---
title: Configuring Your Bee Node
id: configuration
---
Expand Down
Loading

0 comments on commit 91ffd10

Please sign in to comment.