Skip to content

Commit

Permalink
docs: guide documentation for the node
Browse files Browse the repository at this point in the history
  • Loading branch information
rittme committed Mar 11, 2020
1 parent 8d6e2b1 commit 9217a91
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 129 deletions.
50 changes: 38 additions & 12 deletions packages/docs/docs/guides/6-hosting-a-node/0-intro.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,50 @@
---

title: Introduction to Request Node hosting
keywords: [Request node]
---# Introduction

---
Now you should be comfortable with features of the Request network.

# Introduction
In this guide we will explain what is the Request Node and help you to run your own.

Now you should be comfortable with features of the Request network.
## What is the Request Node?

Request Nodes are servers that run the lower layers of the Request protocol. They connect to the Ethereum and IPFS networks, to store and retrieve request transactions. Protocol users can interact with the Request Node through HTTP using the [request-client.js](../5-request-client/0-intro) library.

## Why run your own Node?

Running the Node locally on your machine will allow you to test your code using the Request Client easilly.

You may also want to host your Node in a server. Hosting your Node is the most decentralized setup possible. It allows you to:

- Store your own data and make sure it is safelly backed up
- Be technically independent: own your servers and control how you manage them
- Use custom configuration settings
- Customize storage options

## How to run your Node?

There are 3 currently supported ways to run the Request Node:

- Run from [**Docker**](./1-docker). Probably the easiest way to run the Request Node.
- Run the [**code**](./2-code) from the git repository. Especially useful if you are making changes to the protocol layers.
- Use our kubernetes **helm** charts. The best solution if you want to host your node on a Kubernetes cluster.

On the next pages, you can find out detailed steps on how to run each one of these.

## Prerequisites

In this guide we will guide through the installation of Request node.
Request uses IPFS and Ethereum as the storage for our protocol data. For this reason the Node needs connections to an Ethereum node and an IPFS node.

## What is it?
### Ethereum node

Request Nodes are HTTP servers used to allow clients to communicate with the Request Protocol, these servers abstract the complexity of IPFS and Ethereum for the users. The clients can perform all actions on requets by sending messages to the Node via HTTP.
You can use any HTTP/S Ethereum node to run your Request Node.
For local development, you can use ganache (explained in more details on the following pages).

## Why hosting your own node?
An easy way to get going with Ethereum Mainnet or Rinkeby is to use services like infura, that will expose an Ethereum Node API for you.

Hosting your node is the most decentralized setup possible. It allows you to:
* Be technically independent in your usage of the network
* Customize your broadcasting latency TODO:check with Vincent the wording for avoiding retention
* Customize storage options
### IPFS Node

This option is for advanced developers who are already at ease with Ethereum, IPFS and Request.
Request uses a dedicated IPFS network. This means that you need to have an IPFS Node with our network settings connected to your Request Node.
The good news is it's easy to set up our IPFS and we will show it to you on our next steps.
76 changes: 76 additions & 0 deletions packages/docs/docs/guides/6-hosting-a-node/1-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: Running a node with Docker
keywords: [Request node, setup, docker]
---

Running a Request Node with Docker is easy. There are only a few requirements:

- Docker installed on your system;
- A web3 provider (we recommend using a service like [infura](infura.io));
- An ethereum wallet with some funds for gas (if you plan on creating requests through this node);

## Launching the IPFS node

To launch the IPFS node run:

```bash
docker run -p 5001:5001 -p 4001:4001 requestnetwork/request-ipfs
```

This command will launch the IPFS node with Request network configurations.

## Launching the Request Node

To launch the Request node you can run:

```bash
docker run -p 3000:3000 -e MNEMONIC="<your wallet mnemonic>" -e WEB3_PROVIDER_URL="<your web3 provider url>" -e ETHEREUM_NETWORK_ID="<ethereum network id>" -e IPFS_HOST="host.docker.internal" requestnetwork/request-node
```

The environment variables passed to the script are:

- **MNEMONIC** should be the node wallet mnemonic seed.
- **WEB3_PROVIDER_URL** should be the URL to your web3 provider.
- **ETHEREUM_NETWORK_ID** should be either `1` for Mainnet or `4` for Rinkeby.
- **IPFS_HOST** is the url of your IPFS node. Here we use the internal docker url.

That's it! Now your Node should be running and synching to the network.
Give it some minutes to finish synching and it's API will be available on `http://localhost:3000`.

If you want to know more about the available options you can pass to the node, you can [check them here](https://github.com/RequestNetwork/requestNetwork/tree/master/packages/request-node#options).

## Using Docker Compose

We can (and should) use docker-compose to make it simpler to launch your local Request Node.
With [Docker Compose](https://docs.docker.com/compose/) installed, use the following `docker-compose.yml` file:

```yml
version: '3.1'

services:
request-node:
image: requestnetwork/request-node
environment:
IPFS_HOST: ipfs
ETHEREUM_NETWORK_ID: 4
WEB3_PROVIDER_URL: https://rinkeby.infura.io/v3/<your API key>
MNEMONIC: <your Mnemonic>
ports:
- '3000:3000'
depends_on:
- ipfs

ipfs:
image: requestnetwork/request-ipfs
ports:
- '4001'
- '5001'
```

Now you can run:

```bash
docker-compose up
```

Your node should start initializing.
71 changes: 0 additions & 71 deletions packages/docs/docs/guides/6-hosting-a-node/1-installation.md

This file was deleted.

85 changes: 85 additions & 0 deletions packages/docs/docs/guides/6-hosting-a-node/2-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
title: Running from the code repository
keywords: [Request node, test, ganache, local node]
---

If you can't use Docker or you want to run your node locally, from the source code, you can follow the steps in this document.
Running the Node in this way is useful for debugging and developing the Node itself.

# TODO Running fully locally

To run a Request Node locally for tests, make sure you have the necessary IPFS and Ethereum nodes available.

You can run the following steps to launch a fully local test Request Node.

## Cloning the repository

Let's clone the repository, install and build dependencies:

```bash
git clone https://github.com/RequestNetwork/requestNetwork.git
cd requestNetwork
yarn install
yarn build
```

You are ready to run the local test node. You will need three different consoles for Ethereum, IPFS and Request.

## Launching IPFS locally

First, make sure you [installed IPFS](https://docs.ipfs.io/guides/guides/install/) locally.

Now you need to configure your IPFS. We have a script to make it easy for you:

```bash
cd packages/request-node
yarn init-ipfs
```

Now you can run IPFS with:

```bash
ipfs daemon
```

## Running a local Ethereum test network

If you want to debug and test, you may be interested by using a local Ethereum network.
Install and run [ganache-cli](https://github.com/trufflesuite/ganache-cli) using:

```bash
yarn global add ganache-cli
cd packages/smart-contracts
yarn ganache
```

Now you have ganache running on your second console.
We're still missing all the important smart-contracts request use. On a new console, run:

```bash
cd packages/smart-contracts
yarn deploy
```

Done! Your local Ethereum network is ready for testing.

## Running the node

Now it's time to run the node:

```bash
cd packages/request-node
yarn start
```

Your node should be running! If you want to run it using a different Ethereum network, mnemonic, or a different IPFS server, you can check out the available options for the node [here](https://github.com/RequestNetwork/requestNetwork/tree/master/packages/request-node#options).

### NPX

If for some reason you want to run the Node without Docker, but don't need to make changes to the repository, you can also use npx to run it directly from npm:

```bash
npx @requestnetwork/request-node [OPTIONS]
```

If you got to this point you know what Node [options](https://github.com/RequestNetwork/requestNetwork/tree/master/packages/request-node#options) you should be using 🙂.
46 changes: 0 additions & 46 deletions packages/docs/docs/guides/6-hosting-a-node/2-local-node.md

This file was deleted.

30 changes: 30 additions & 0 deletions packages/docs/docs/guides/6-hosting-a-node/3-helm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Deploying a node in Kubernetes with Helm
keywords: [Request node, helm, kubernetes]
---

Deploying a Request node on Kubernetes is straightforward using our [helm](https://helm.sh/) chart.

You can see our chart in our [git repository](https://github.com/RequestNetwork/request-helm-charts/tree/master/request-node).

## Adding the chart

We host our chart on our own helm repo, since we upgrade it frequently.
To add our chart you can run:

```bash
helm repo add request https://request-charts.storage.googleapis.com
helm repo update
```

## Installing the chart

To install our chart with the release name `my-release`, you can run:

```bash
helm install --name my-release request/request-node
```

You will need to set up some required values, like mnemonic, web3ProviderUrl (you can use [infura](https://www.infura.io) API) and networkId (either `1` for mainnet or `4` for Rinkeby).

You can check out all our chart configuration options [here](https://github.com/RequestNetwork/request-helm-charts/tree/master/request-node#configuration).

0 comments on commit 9217a91

Please sign in to comment.