Skip to content

Commit

Permalink
Improved full node installation doc
Browse files Browse the repository at this point in the history
See PR #278
  • Loading branch information
RiccardoM authored Sep 28, 2020
1 parent 4b75957 commit 914fe4c
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 102 deletions.
129 changes: 129 additions & 0 deletions contrib/validators/automatic-fullnode-installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
####################################
## Variables
####################################
MONIKER=$1
if [ -z "$MONIKER" ]; then
echo "Validator moniker not given. Please specify it as the first argument"
exit 0
fi

USER=$(id -u -n)


####################################
## Setup environmental variables
####################################
echo "===> Setting up environmental variables"

if [ -z "$GOBIN" ]; then
{
echo "export GOBIN=$HOME/go/bin" >> ~/.profile
source ~/.profile
} &> /dev/null
fi

if [ -z "$DAEMON_NAME" ]; then
{
echo " " >> ~/.profile
echo "# Setup Cosmovisor" >> ~/.profile
echo "export DAEMON_NAME=desmosd" >> ~/.profile
echo "export DAEMON_HOME=$HOME/.desmosd" >> ~/.profile
echo "export DAEMON_RESTART_AFTER_UPGRADE=on" >> ~/.profile
source ~/.profile
} &> /dev/null
fi

echo "===> Completed environmental variables setup"
echo ""

####################################
## Setup Cosmovisor
####################################
echo "===> Setting up Cosmovisor"

echo "=====> Downloading Cosmovisor"
# Download Cosmovisor
{
git clone https://github.com/cosmos/cosmos-sdk.git ~/cosmos
cd ~/cosmos/cosmovisor
make cosmovisor
cp cosmovisor $GOBIN/cosmovisor
cd ~
} &> /dev/null

# Prepare Cosmovisor
echo "=====> Installing up Cosmovisor"
{
wget -O desmosd-cosmovisor.zip http://ipfs.io/ipfs/QmbHnXy4mGuCDEaJF18DGTF86vtbgLZG5cffowoZypgwUj
mkdir -p ~/.desmosd
unzip desmosd-cosmovisor.zip -d ~/.desmosd
} &> /dev/null

echo "===> Completed Cosmovisor setup"
echo ""

####################################
## Setup Desmos
####################################
echo "===> Setting up Desmos"

# Setup desmosd to use Cosmovisor
{
alias desmosd=~/.desmosd/cosmovisor/current/bin/desmosd
alias desmoscli=~/.desmosd/cosmovisor/current/bin/desmoscli
} &> /dev/null

# Setup the chain
echo "=====> Initializing the chain"
{
desmosd init $MONIKER
} &> /dev/null

# Download the genesis file
echo "=====> Downloading the genesis file"
{
curl https://raw.githubusercontent.com/desmos-labs/morpheus/master/genesis.json -o $HOME/.desmosd/config/genesis.json
} &> /dev/null

# Setup the persistent peers
echo "=====> Setting persistent peers"
{
sed -i -e 's/persistent_peers = ""/persistent_peers = "7fed5624ca577eb0333d3631b5e4f16ba1736979@54.180.98.75:26656,5077b7964d71d8758f7fc01cac01d0e2d55b8c18@18.196.238.210:26656,bdd98ec74fe56146f08e886239e52373f6821ce3@51.15.113.208:26656,e30d9bb713d17d1e4380b2e2a6df4b5c76c73eb1@34.212.106.82:26656"/g' ~/.desmosd/config/config.toml
} &> /dev/null

echo "===> Completed Desmos setup"
echo ""

####################################
## Setup the service
####################################
echo "===> Setting up Desmos service"

{
FILE=/etc/systemd/system/desmosd.service
sudo tee $FILE > /dev/null <<EOF
[Unit]
Description=Desmos full node watched by Cosmovisor
After=network-online.target
[Service]
User=$USER
ExecStart=$GOBIN/cosmovisor start
Restart=always
RestartSec=3
LimitNOFILE=4096
Environment="DAEMON_NAME=desmosd"
Environment="DAEMON_HOME=$HOME/.desmosd"
Environment="DAEMON_RESTART_AFTER_UPGRADE=ony"
[Install]
WantedBy=multi-user.target
EOF
} &> /dev/null

echo "====> Starting Desmos service"
{
sudo systemctl daemon-reload
sudo systemctl enable desmosd
sudo systemctl start desmosd
} &> /dev/null

tail -100f /var/log/syslog
10 changes: 9 additions & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,15 @@ module.exports = {
collapsable: true,
children: [
["fullnode/overview", "Overview"],
["fullnode/setup", "Setup"],
{
title: "Setup",
collapsable: false,
children: [
["fullnode/setup/overview", "Overview"],
["fullnode/setup/automatic", "Automatic setup"],
["fullnode/setup/manual", "Manual setup"],
]
},
["fullnode/rocksdb-installation", "Using RocksDB"],
["fullnode/update", "Update"],
]
Expand Down
2 changes: 1 addition & 1 deletion docs/fullnode/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ A full-node is a program that fully validates transactions and blocks of a block

Of course, it is possible and encouraged for users to run full-nodes even if they do not plan to be validators.

If you would like to become a **Desmos** validator, you must first run a **Desmos** fullnode. To do so, please refer to the [installation instructions](setup.md).
If you would like to become a **Desmos** validator, you must first run a **Desmos** fullnode. To do so, please refer to the [installation instructions](setup/overview.md).
59 changes: 59 additions & 0 deletions docs/fullnode/setup/automatic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Automatic full node setup
Following you will find how to download and execute the script that allows you to run a Desmos full node in minutes.

:::warning Requirements
Before proceeding, make sure you have read the [overview page](overview.md) and your system satisfied the needed requirements.
:::

## 1. Download the script
You can get the script by executing

```shell
wget -O install-desmos-fullnode https://raw.githubusercontent.com/desmos-labs/desmos/master/contrib/validators/automatic-fullnode-installer.sh
```

Once you downloaded it properly, you need to change its permissions making it executable:

```shell
chmod +x ./install-desmos-fullnode
```

## 2. Execute the script
Once you got the script, you are now ready to use it.

### Parameters
In order to work, it needs the following parameters:

1. The `moniker` of the validator you are creating.
This is just a string that will allow you to identify the validator you are running locally. It can be anything you want.

### Running the script
Once you are ready to run the script, just execute:

```shell
./install-desmos-fullnode <PARAMETERS>
```

E.g:

```
./install-desmos-fullnode my-validator
```

## How it works
The script will perform the following operations.

1. **Environment setup**
It will create all the necessary environmental variables.

2. **Cosmovisor setup**
It will download Cosmovisor and set it up so that your node is able to automatically update based on on-chain upgrades.

3. **Desmos setup**
It will download and install Desmos properly so that your node is able to start syncing and also update itself based on all the on-chain upgrades that have been done until now.

4. **Service setup**
It will setup a system service to make sure Desmos runs properly in the background.

5. **Service start and log output**
Finally, it will start the system service and output the logs from it. You will see it syncing the blocks properly and catching up with the rest of the chain.
110 changes: 15 additions & 95 deletions docs/fullnode/setup.md → docs/fullnode/setup/manual.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,16 @@
# Installing and running a Desmos fullnode
# Manual full node setup
Following you will find the instructions on how to manually setup your Desmos full node.

:::warning This guide is for new fullnodes only
If you have previously run a fullnode and you wish to update it instead, please follow the [updating guide](update.md).
:::warning Requirements
Before starting, make sure you read the [setup overview](overview.md) to make sure your hardware meets the needed requirements.
:::

## Requirements
In order to run a full node, the following minimum hardware requirements should be met:

- 2 CPU cores
- 4GB of RAM
- 40GB disk space

However, these requirements **will not** be sufficient in the future. For this reason, if you plan to run your validator node for an indefinite amount of time, we suggest you to use the following hardware:

- 4 CPU cores
- 8GB of RAM or more
- 512GB of disk space or more


## 1. Setup your environment
In order to run a fullnode, you need to build `desmosd` and `desmoscli` which require `Go`, `git`, `gcc` and `make` installed.

This process depends on your working environment.

:::: tabs

::: tab Linux
The following example is based on **Ubuntu (Debian)** and assumes you are using a terminal environment by default. Please run the equivalent commands if you are running other Linux distributions.

```bash
# Install git, gcc and make
sudo apt install build-essential --yes

# Install Go with Snap
sudo snap install go --classic

# Export environment variables
echo 'export GOPATH="$HOME/go"' >> ~/.profile
echo 'export PATH="$GOPATH/bin:$PATH"' >> ~/.profile
source ~/.profile
```

:::

::: tab MacOS
To install the required build tools, simple [install Xcode from the Mac App Store](https://apps.apple.com/hk/app/xcode/id497799835?l=en&mt=12).

To install `Go` on __MacOS__, the best option is to install with [__Homebrew__](https://brew.sh/). To do so, open the `Terminal` application and run the following command:

```bash
# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```


> If you don't know how to open a `Terminal`, you can search it by typing `terminal` in `Spotlight`.
After __Homebrew__ is installed, run

```bash
# Install Go using Homebrew
brew install go

# Install Git using Homebrew
brew install git

# Export environment variables
echo 'export GOPATH="$HOME/go"' >> ~/.profile
echo 'export PATH="$GOPATH/bin:$PATH"' >> ~/.profile
source ~/.profile
```

:::

::: tab Windows
The software has not been tested on __Windows__. If you are currently running a __Windows__ PC, the following options should be considered:

1. Switch to a __Mac__ 👨‍💻.
2. Wipe your hard drive and install a __Linux__ system on your PC.
3. Install a separate __Linux__ system using [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
4. Run a __Linux__ instance on a cloud provider.

Note that is still possible to build and run the software on __Windows__ but it may give you unexpected results and it may require additional setup to be done. If you insist to build and run the software on __Windows__, the best bet would be installing the [Chocolatey](https://chocolatey.org/) package manager.

:::

::::

## 2. Build the software
## 1. Build the software
:::tip Choose your DB backend
Before installing the software, a consideration must be done.

By default, Desmos uses [LevelDB](https://github.com/google/leveldb) as its database backend engine. However, since version `v0.6.0` we've also added the possibility of optionally using [Facebook's RocksDB](https://github.com/facebook/rocksdb), which, although still being experimental, is know to be faster and could lead to lower syncing times. If you want to try out RocksDB (which we suggest you to do) you can take a look at our [RocksDB installation guide](rocksdb-installation.md) before proceeding further.
By default, Desmos uses [LevelDB](https://github.com/google/leveldb) as its database backend engine. However, since version `v0.6.0` we've also added the possibility of optionally using [Facebook's RocksDB](https://github.com/facebook/rocksdb), which, although still being experimental, is know to be faster and could lead to lower syncing times. If you want to try out RocksDB (which we suggest you to do) you can take a look at our [RocksDB installation guide](../rocksdb-installation.md) before proceeding further.
:::

The following operations will all be done in the terminal environment under your home directory.

Expand Down Expand Up @@ -120,7 +40,7 @@ If the software is built successfully, `desmosd` and `desmoscli` will be located
desmosd version --long
```

## 3. Initialize the Desmos working directory
## 2. Initialize the Desmos working directory
Configuration files and chain data will be stored inside the `.desmosd` directory under your home directory by default. It will be created when you initialize the environment.

```bash
Expand All @@ -130,7 +50,7 @@ desmosd init <your_moniker>

You can choose any moniker your like. It will be saved in the `config.toml` under the `.desmosd` working directory.

## 4. Get the genesis file
## 3. Get the genesis file
To connect to or start a new network, a genesis file is required. The file contains all the settings telling how the genesis block of the network should look like. To connect to the `morpheus` testnets, you will need the corresponding genesis file of each testnet. Visit the [testnet repo](https://github.com/desmos-labs/morpheus) and download the correct genesis file by running the following command.

```bash
Expand All @@ -142,7 +62,7 @@ rm $HOME/.desmosd/config/genesis.json
curl https://raw.githubusercontent.com/desmos-labs/morpheus/master/genesis.json -o $HOME/.desmosd/config/genesis.json
```

## 5. Connect to persistent peer
## 4. Connect to persistent peer
To properly run your node, you will need to connect it to other full nodes running with the same software and genesis file. This can be done configuring the `persisten_peers` value inside the `config.toml` file localed under the `.desmosd` working directory.

```bash
Expand All @@ -160,7 +80,7 @@ persistent_peers = "7fed5624ca577eb0333d3631b5e4f16ba1736979@54.180.98.75:26656"
Save the file and exit the text editor.

## (Optional) Change your database backend
If you would like to run your node using [Facebook's RocksDB](https://github.com/facebook/rocksdb) as the database backend, and you have correctly built the Desmos binaries to work with it following the instructions at [point 2](#2-build-the-software), there is one more thing you need to do.
If you would like to run your node using [Facebook's RocksDB](https://github.com/facebook/rocksdb) as the database backend, and you have correctly built the Desmos binaries to work with it following the instructions at [point 1](#1-build-the-software), there is one more thing you need to do.

In order to tell Tendermint to use RocksDB as its database backend engine, you are required to change the following like inside the `config.toml` file:

Expand All @@ -174,9 +94,9 @@ To become
db_backend="rocksdb"
```

Once you have done so, you can go ahead with [point 6](#6-start-the-desmos-node).
Once you have done so, you can go ahead with [point 5](#5-start-the-desmos-node).

## 6. Start the Desmos node
## 5. Start the Desmos node
Now you are good to run the full node. To do so, run:

```bash
Expand Down Expand Up @@ -232,7 +152,7 @@ You should see an output like the following one:

If you see that the `catching_up` value is `false` under the `sync_info`, it means that you are fully synced. If it is `true`, it means your node is still syncing.

After your node is fully synced, you can consider running your full node as a [validator node](../validators/setup.md).
After your node is fully synced, you can consider running your full node as a [validator node](../../validators/setup.md).

## (Optional) Configure the service
To allow your `desmosd` instance to run in the background as a service you need to execute the following command
Expand Down
Loading

0 comments on commit 914fe4c

Please sign in to comment.