Skip to content

Commit

Permalink
#78 Add guide How to join network as validator (#105)
Browse files Browse the repository at this point in the history
* #78 Add guide `How to join network as validator`

* Update docs/run_testnet.md

Co-Authored-By: hleb-albau <hleb.albau@gmail.com>
  • Loading branch information
hleb-albau authored and arturalbov committed Dec 8, 2018
1 parent 17c0d77 commit e0f7116
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 24 deletions.
1 change: 1 addition & 0 deletions app/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func NewLinksHandler(cis CidIndexStorage, ls LinksStorage, imms *InMemoryStorage
if !ctx.IsCheckTx() {
imms.AddLink(link)
}
ls.AddLink(ctx, link)

return sdk.Result{Code: cbd.CodeOK, Codespace: cbd.CodespaceCbd}
}
Expand Down
5 changes: 2 additions & 3 deletions app/rank/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Next compile **cbdrank** lib, copy it to `/usr/lib/` folder:

```bash
# project root
cd poc/app/rank/cuda
cd app/rank/cuda
nvcc -fmad=false -shared -o libcbdrank.so rank.cu --compiler-options '-fPIC -frounding-math -fsignaling-nans'
sudo cp libcbdrank.so /usr/lib/
sudo cp cbdrank.h /usr/lib/
Expand All @@ -16,7 +16,6 @@ sudo cp cbdrank.h /usr/lib/
Compile binaries, copy configs and run daemon
```bash
# project root
cd poc
cp testnet/genesis.json .cyberd/config/genesis.json
cp testnet/config.toml .cyberd/config/config.toml
go build -tags cuda -o daemon ./cyberd
Expand All @@ -27,7 +26,7 @@ go build -tags cuda -o daemon ./cyberd
To test GPU and CPU rank computing determinism run:
```bash
# project root
cd poc/app/rank/cuda
cd app/rank/cuda
nvcc -fmad=false -shared -o libcbdrank.so rank.cu --compiler-options '-fPIC -frounding-math -fsignaling-nans'
sudo cp libcbdrank.so /usr/lib/
sudo cp cbdrank.h /usr/lib/
Expand Down
2 changes: 1 addition & 1 deletion app/rank/calculate_gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

/*
#cgo CFLAGS: -I/usr/lib/
#cgo LDFLAGS: -lcbdrank -lcudart
#cgo LDFLAGS: -L/usr/local/cuda/lib64 -lcbdrank -lcudart
#include "cbdrank.h"
*/
import "C"
Expand Down
98 changes: 98 additions & 0 deletions docs/join_network.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Run full node
//todo intro


## Prepare your server

First, you have to setup a server. You are supposed to run your validator node all time, so you will need a
reliable server to keep it running. Also, you may consider to use any cloud services like AWS or DigitalOcean.

Cyberd is based on Cosmos SDK written in Go. It should work on any platform which can compile and run programs in Go.
However, I strongly recommend running the validator node on a Linux server.
Here is the current required server specification to run validator node.

1. No. of CPUs: 8
2. RAM: 64GB
3. Card with Nvidia CUDA support(ex 1080ti) and at least 8gb VRAM.
4. Disk: 256GB SSD

## Install Dependencies

Cyberd requires **Go 1.11+**.
[Here](https://golang.org/doc/install) you can find default installation instructions for Go for various platforms.

Check Go version:
```bash
go version
// go version go1.11 linux/amd64
```

For installing **CUDA Toolkit**, please, visit [official Nvidia site](https://docs.nvidia.com/cuda/index.html).

Check toolkit version:
```bash
nvidia-smi
nvcc --version
// ....
// Cuda compilation tools, release 9.1, V9.1.85
```

### Compile binaries

Firstly, clone cyberd with required version.
```bash
git clone -b v0.1.0 --depth 1 https://github.com/cybercongress/cyberd.git
cd cyberd/
```

Than, build GPU Kernel (part of cyberd, that computes rank).
```bash
cd app/rank/cuda
nvcc -fmad=false -shared -o libcbdrank.so rank.cu --compiler-options '-fPIC -frounding-math -fsignaling-nans'
sudo cp libcbdrank.so /usr/lib/
sudo cp cbdrank.h /usr/lib/
cd ../../../
```

Compile binaries, copy configs and run daemon.
```bash

go build -tags cuda -o daemon ./cyberd
go build -o cli ./cyberdcli
```

### Running daemon

Create a configuration directory(by default $HOME/.cyberd) in your home and generate some some required files.

```bash
./daemon init
```

We need the genesis and config files in order to connect to the testnet.
The files are already included in the cyberd repo. Copy them by.
```bash
cp testnet/genesis.json .cyberd/config/genesis.json
cp testnet/config.toml .cyberd/config/config.toml
```

You can run the node in background logging all output to a log file.

```
./daemon start &> cyberd.log &
```

All output will be logged in the gaia.log file. You can keep checking the output using tail -f.

```
tail -f cyberd.log
```

To check if your node is connected to the testnet, you can run this.

```
./cli status
```

You should be seeing a returned JSON with your node status including node_info, sync_info and validator_info.
If you see this, then you are connected.
60 changes: 60 additions & 0 deletions docs/run_testnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Running two validators testnet

## First machine - First validator

Build cyberd daemon and cli with default instructions. Let's suppose binaries named `daemon` and `cli`.

Create new account and copy seed phrase.
```
./cli keys add testnet_v2
```

Create network files for one validator:
```
./daemon testnet --v 1
```

Add generated previously account to genesis.
```bash
./daemon add-genesis-account cbd1pnuzd4tvqvrawjtk6q8wwvg9cmw4mnnmy9skdy 500CBD --home=./mytestnet/node0/cyberd
cp testnet/config.toml ./mytestnet/node0/cyberd/config/config.toml
```

Run daemon
```bash
./daemon start --home=./mytestnet/node0/cyberd
```

## Second machine - Second validator

Build cyberd daemon and cli with default instructions. Let's suppose binaries named `daemon` and `cli`.


Init daemon.
```asciidoc
./daemon init --home=./mytestnet/
```

Copy genesis and config
```bash
scp -P 33324 earth@earth.cybernode.ai:/home/earth/cyberd/mytestnet/node0/cyberd/config/genesis.json ./mytestnet/cyberd/config
scp -P 33324 earth@earth.cybernode.ai:/home/earth/cyberd/mytestnet/node0/cyberd/config/config.toml ./mytestnet/cyberd/config
```


```bash
./daemon tendermint show-validator --home=./mytestnet/

./cli tx stake create-validator \
--amount=100CBD \
--pubkey=cbdvalconspub1zcjduepq2pr9cqd9apves6av0xafzgzvvl0ky8904wlkecwu4vghxteutrsq8pcfa7 \
--moniker="hlb" \
--chain-id=chain-hFpwd3 \
--from=testnet_hlb \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01"
```



65 changes: 65 additions & 0 deletions docs/run_validator_node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Run validator node

Firstly, run full node using "[Run full node](run_testnet.md)" guide.

Alright, you are now connected to the testnet.
To be a validator, you will need some **CBD**(testnet coin).

## Prepare stake address
If you already have address with **CBD**, just restore it into your local keyspace.

```bash
./cli keys add <your_key_name> --recover
./cli show <your_key_name>
```

If no, create new one and send coins to it.
You first need to create a pair of private and public keys for sending and
receiving coins, and bonding stake.

```
./cli keys add <your_key_name>
```

<your_key_name> is any name you pick to represent this key pair.
You have to refer to this <your_key_name> later when you use the keys to sign transactions.
It will ask you to enter your password twice to encrypt the key.
You also need to enter your password when you use your key to sign any transaction.

The command returns the address, public key and a seed phrase which you can use it to
recover your account if you forget your password later.
Keep the seed phrase in a safe place in case you have to use them.

The address showing here is your account address. Let’s call this <your_account_address>.
It stores your assets.

## Send create validator transaction

Validators are actors on the network committing new blocks by submitting their votes.
It refers to the node itself, not a single person or a single account.
Therefore, the public key here is referring to the node public key,
not the public key of the address you have just created.

To get the node public key, run the following command.

```bash
./daemon tendermint show_validator
```

It will return a bech32 public key. Let’s call it <your_node_pubkey>.
The next step you have to declare a validator candidate.
The validator candidate is the account which stake the coins.
So the validator candidate is an account this time.
To declare a validator candidate, run the following command.

```bash
./cli tx stake create-validator \
--amount=100CBD \
--pubkey=<your_node_pubkey> \
--moniker="hlb" \
--trust-node \
--from=<your_key_name> \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01"
```
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ require (
github.com/spf13/pflag v1.0.2
github.com/spf13/viper v1.0.0
github.com/stretchr/testify v1.2.1 // indirect
github.com/syndtr/goleveldb v0.0.0-20180708030551-c4c61651e9e3 // indirect
github.com/syndtr/goleveldb v0.0.0-20181128100959-b001fa50d6b2 // indirect
github.com/tendermint/btcd v0.0.0-20180816174608-e5840949ff4f // indirect
github.com/tendermint/ed25519 v0.0.0-20171027050219-d8387025d2b9 // indirect
github.com/tendermint/go-amino v0.14.1
github.com/tendermint/iavl v0.12.0 // indirect
github.com/tendermint/tendermint v0.27.0-dev1
github.com/tendermint/tendermint v0.27.0
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect
github.com/zondax/ledger-goclient v0.1.0 // indirect
golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e // indirect
Expand Down
22 changes: 4 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -121,34 +121,20 @@ github.com/spf13/viper v1.0.0 h1:RUA/ghS2i64rlnn4ydTfblY8Og8QzcPtCcHvgMn+w/I=
github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=
github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U=
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/syndtr/goleveldb v0.0.0-20180708030551-c4c61651e9e3 h1:sAlSBRDl4psFR3ysKXRSE8ss6Mt90+ma1zRTroTNBJA=
github.com/syndtr/goleveldb v0.0.0-20180708030551-c4c61651e9e3/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/syndtr/goleveldb v0.0.0-20180815032940-ae2bd5eed72d h1:4J9HCZVpvDmj2tiKGSTUnb3Ok/9CEQb9oqu9LHKQQpc=
github.com/syndtr/goleveldb v0.0.0-20180815032940-ae2bd5eed72d/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/syndtr/goleveldb v0.0.0-20181128100959-b001fa50d6b2 h1:GnOzE5fEFN3b2zDhJJABEofdb51uMRNb8eqIVtdducs=
github.com/syndtr/goleveldb v0.0.0-20181128100959-b001fa50d6b2/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/tendermint/btcd v0.0.0-20180816174608-e5840949ff4f h1:R0wLxgASGMoRQTF/dCSk4N+M3j9DLyPDzDff2WtCg/I=
github.com/tendermint/btcd v0.0.0-20180816174608-e5840949ff4f/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U=
github.com/tendermint/crypto v0.0.0-20180820045704-3764759f34a5 h1:u8i49c+BxloX3XQ55cvzFNXplizZP/q00i+IlttUjAU=
github.com/tendermint/crypto v0.0.0-20180820045704-3764759f34a5/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk=
github.com/tendermint/ed25519 v0.0.0-20171027050219-d8387025d2b9 h1:zccWau0P8FELSb4HTDJ88hRo+WVNMbIbg27rFqDrhCE=
github.com/tendermint/ed25519 v0.0.0-20171027050219-d8387025d2b9/go.mod h1:nt45hbhDkWVdMBkr2TOgOzCrpBccXdN09WOiOYTHVEk=
github.com/tendermint/go-amino v0.12.0 h1:zpGVp3gOCwlju/4plyGEI0vLFY389o9i1PasldjiDig=
github.com/tendermint/go-amino v0.12.0/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso=
github.com/tendermint/go-amino v0.14.0 h1:KQpB5tjLqe4+m/TQT93lfg1VdYypbEwrqtDMk84o4Bs=
github.com/tendermint/go-amino v0.14.0/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso=
github.com/tendermint/go-amino v0.14.1 h1:o2WudxNfdLNBwMyl2dqOJxiro5rfrEaU0Ugs6offJMk=
github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso=
github.com/tendermint/iavl v0.11.0 h1:3RsyfghB/8hD5Fa9zN1dvPu35vnC0SbnjmEiSyWRbAw=
github.com/tendermint/iavl v0.11.0/go.mod h1:EoKMMv++tDOL5qKKVnoIqtVPshRrEPeJ0WsgDOLAauM=
github.com/tendermint/iavl v0.11.1 h1:qcEBQRj189WuAdSeTm3jx9waySYltnX1IdATyQA1gRU=
github.com/tendermint/iavl v0.11.1/go.mod h1:EoKMMv++tDOL5qKKVnoIqtVPshRrEPeJ0WsgDOLAauM=
github.com/tendermint/iavl v0.12.0 h1:xcaFAr+ycqCj7WN1RzL2EfcBioRDOHcU1oWcg83K028=
github.com/tendermint/iavl v0.12.0/go.mod h1:EoKMMv++tDOL5qKKVnoIqtVPshRrEPeJ0WsgDOLAauM=
github.com/tendermint/tendermint v0.25.1-rc0 h1:ZFI9ha8A88vTYoLwVjrTYljR0GvKsUDKGXDsdPFnZ0s=
github.com/tendermint/tendermint v0.25.1-rc0/go.mod h1:ymcPyWblXCplCPQjbOYbrF1fWnpslATMVqiGgWbZrlc=
github.com/tendermint/tendermint v0.26.1 h1:lrHaNz3K/+vB3V9DfHWEvh7LNiZdaJsmmqO6SVDVd28=
github.com/tendermint/tendermint v0.26.1/go.mod h1:ymcPyWblXCplCPQjbOYbrF1fWnpslATMVqiGgWbZrlc=
github.com/tendermint/tendermint v0.27.0-dev1 h1:KwVYIeQjU4m8aZr6ID9xqZ+i3RiHRSZ0d5GHxP9LE8A=
github.com/tendermint/tendermint v0.27.0-dev1/go.mod h1:ymcPyWblXCplCPQjbOYbrF1fWnpslATMVqiGgWbZrlc=
github.com/tendermint/tendermint v0.27.0 h1:PeH/nkYqzG7hEdKmG5aJZFCOi6aSr9nIUjC0Echtzjc=
github.com/tendermint/tendermint v0.27.0/go.mod h1:ymcPyWblXCplCPQjbOYbrF1fWnpslATMVqiGgWbZrlc=
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc h1:BCPnHtcboadS0DvysUuJXZ4lWVv5Bh5i7+tbIyi+ck4=
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc/go.mod h1:r45hJU7yEoA81k6MWNhpMj/kms0n14dkzkxYHoB96UM=
github.com/zondax/ledger-goclient v0.1.0/go.mod h1:ILyu7qO5zsod0bzyxY9NCMlFTb8AXZzJAJf0T85b2jA=
Expand Down

0 comments on commit e0f7116

Please sign in to comment.