From b52ce7b6f243f994e048b9a73ca5f39a9f0531f1 Mon Sep 17 00:00:00 2001 From: Hleb Albau Date: Tue, 11 Dec 2018 21:49:49 +0300 Subject: [PATCH] #104 Update documentation --- .circleci/config.yml | 4 +- .gitignore | 2 +- .goreleaser.yml | 6 +- Dockerfile | 8 +- build_binaries.sh | 6 -- {cyberdcli => cli}/commands/linktx.go | 2 +- {cyberdcli => cli}/main.go | 2 +- {cyberdcli => cli}/util/message.go | 0 docs/OLD_README.md | 2 +- docs/join_network.md | 98 ------------------- docs/run_validator.md | 136 ++++++++++++++++++++++++++ docs/run_validator_node.md | 65 ------------ entrypoint.sh | 15 +-- 13 files changed, 152 insertions(+), 194 deletions(-) delete mode 100755 build_binaries.sh rename {cyberdcli => cli}/commands/linktx.go (97%) rename {cyberdcli => cli}/main.go (97%) rename {cyberdcli => cli}/util/message.go (100%) delete mode 100644 docs/join_network.md create mode 100644 docs/run_validator.md delete mode 100644 docs/run_validator_node.md diff --git a/.circleci/config.yml b/.circleci/config.yml index 962a70ff..53fac466 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -32,7 +32,7 @@ jobs: command: | export GO111MODULE=on go build -o daemon ./cyberd - go build -o cli ./cyberdcli + go build -o cyberdcli ./cli go build -o cyberdproxy ./proxy go build -o cyberdclaim ./claim @@ -117,7 +117,7 @@ jobs: name: Github Release Cyberd Binaries command: | export GO111MODULE=on - go build -o cli ./cyberdcli + go build -o cyberdcli ./cli sudo apt-get update && sudo apt-get install -y rpm curl -sL https://git.io/goreleaser | bash diff --git a/.gitignore b/.gitignore index 41b8d575..6a28ca50 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ initial_guess_impact_results *.so *.o -cli \ No newline at end of file +cyberdcli \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index 32bc53ef..f0c8cd5a 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,7 +1,7 @@ builds: - - main: ./cyberdcli - binary: cli + main: ./cli + binary: cyberdcli env: - CGO_ENABLED=0 - GO111MODULE=on @@ -23,8 +23,8 @@ changelog: exclude: - '^docs:' - '^test:' + - '^CI:' - Merge pull request - - Merge branch nfpm: diff --git a/Dockerfile b/Dockerfile index 9b01d12f..c977024e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,8 +34,8 @@ RUN nvcc -fmad=false -shared -o libcbdrank.so rank.cu --compiler-options '-fPIC ############################################################################### WORKDIR /sources RUN go build -tags cuda -o daemon ./cyberd -RUN go build -o cli ./cyberdcli -RUN go build -o daemon_proxy ./proxy +RUN go build -o cyberdcli ./cli +RUN go build -o cyberdproxy ./proxy ############################################################################### @@ -65,8 +65,8 @@ RUN url="https://golang.org/dl/go${GO_VERSION}.${GO_ARCH}.tar.gz" && \ # Copy compiled kernel and binaries ############################################################################### COPY --from=build_stage /sources/daemon /usr/bin/cyberd -COPY --from=build_stage /sources/cli /usr/bin/cyberdcli -COPY --from=build_stage /sources/daemon_proxy /usr/bin/cyberdproxy +COPY --from=build_stage /sources/cyberdcli /usr/bin/cyberdcli +COPY --from=build_stage /sources/cyberdproxy /usr/bin/cyberdproxy COPY --from=build_stage /usr/lib/cbdrank.h /usr/lib/cbdrank.h COPY --from=build_stage /usr/lib/libcbdrank.so /usr/lib/libcbdrank.so diff --git a/build_binaries.sh b/build_binaries.sh deleted file mode 100755 index 842bed19..00000000 --- a/build_binaries.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -go build -o ~/go/bin/cyberd ./cyberd -go build -o ~/go/bin/cyberdcli ./cyberdcli -go build -o ~/go/bin/cyberdproxy ./proxy -go build -o ~/go/bin/cyberdclaim ./claim \ No newline at end of file diff --git a/cyberdcli/commands/linktx.go b/cli/commands/linktx.go similarity index 97% rename from cyberdcli/commands/linktx.go rename to cli/commands/linktx.go index 8b94d622..ed5ce47a 100644 --- a/cyberdcli/commands/linktx.go +++ b/cli/commands/linktx.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder" cbd "github.com/cybercongress/cyberd/app/types" - . "github.com/cybercongress/cyberd/cyberdcli/util" + . "github.com/cybercongress/cyberd/cli/util" "github.com/ipfs/go-cid" "github.com/spf13/cobra" "github.com/spf13/viper" diff --git a/cyberdcli/main.go b/cli/main.go similarity index 97% rename from cyberdcli/main.go rename to cli/main.go index f4ef9c2d..39c1efb1 100644 --- a/cyberdcli/main.go +++ b/cli/main.go @@ -11,7 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "github.com/cybercongress/cyberd/app" - cyberdcmd "github.com/cybercongress/cyberd/cyberdcli/commands" + cyberdcmd "github.com/cybercongress/cyberd/cli/commands" "github.com/spf13/cobra" "github.com/tendermint/tendermint/libs/cli" diff --git a/cyberdcli/util/message.go b/cli/util/message.go similarity index 100% rename from cyberdcli/util/message.go rename to cli/util/message.go diff --git a/docs/OLD_README.md b/docs/OLD_README.md index cec2be65..8bdcb613 100644 --- a/docs/OLD_README.md +++ b/docs/OLD_README.md @@ -58,7 +58,7 @@ In project directory go into `/cosmos/poc/` and run: ```$bash export GO111MODULE=on go install ./cyberd -go install ./cyberdcli +go install -o cyberdcli ./cli ``` This will create binaries for `cyberd` and `cyberdcli` diff --git a/docs/join_network.md b/docs/join_network.md deleted file mode 100644 index 05991488..00000000 --- a/docs/join_network.md +++ /dev/null @@ -1,98 +0,0 @@ -# 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. diff --git a/docs/run_validator.md b/docs/run_validator.md new file mode 100644 index 00000000..84df975b --- /dev/null +++ b/docs/run_validator.md @@ -0,0 +1,136 @@ +# Join Cyberd Network As Validator + +## 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: 6 +2. RAM: 32GB +3. Card with Nvidia CUDA support(ex 1080ti) and at least 8gb VRAM. +4. Disk: 256GB SSD + + +## Install Dependencies + +Our main distribution unit is docker container. +All images are located in default [Dockerhub registry](https://hub.docker.com/r/cyberd/cyberd/). +Rank calculated on **GPU** using [**CUDA Toolkit**](https://docs.nvidia.com/cuda/index.html). +In order to access **GPU** from container, nvidia drivers version **410+** and + [nvidia docker runtime](https://github.com/NVIDIA/nvidia-docker) should be installed on host system. + + +Check both driver and docker runtime installed correctly: +```bash +docker run --runtime=nvidia --rm nvidia/cuda:10.0-base nvidia-smi + +# Should be displayed something like this. +Tue Dec 11 18:02:15 2018 ++-----------------------------------------------------------------------------+ +| NVIDIA-SMI 410.78 Driver Version: 410.78 CUDA Version: 10.0 | +|-------------------------------+----------------------+----------------------+ +| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | +| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | +|===============================+======================+======================| +| 0 GeForce GTX 1050 Off | 00000000:01:00.0 Off | N/A | +| N/A 52C P0 N/A / N/A | 302MiB / 4042MiB | 2% Default | ++-------------------------------+----------------------+----------------------+ + ++-----------------------------------------------------------------------------+ +| Processes: GPU Memory | +| GPU PID Type Process name Usage | +|=============================================================================| ++-----------------------------------------------------------------------------+ +``` + +## Start Fullnode + +First, create folder, where daemon and cli will store data. Some commands may require admin privileges. +```bash +mkdir /cyberd +``` + +Run daemon with mounted volumes on created during previous step folder. +```bash +docker run -d --name=cyberd --runtime=nvidia \ + -p 26656:26656 -p 26657:26657 -p 26660:26660 \ + -v /cyberd/daemon:/root/.cyberd \ + -v /cyberd/cli:/root/.cyberdcli \ + cybercongress/cyberd:latest +``` + +To check if your node is connected to the testnet, you can run this: +``` +docker exec cyberd cyberdcli status +``` +You should be seeing a returned JSON with your node status including node_info, sync_info and validator_info. + +## Prepare stake address + +Alright, you are now connected to the testnet. +To be a validator, you will need some **CBD**(cyberd coin) to be bounded as your stake. +Top 146 validators by bounded stake will be active validators taking part in consensus. + +If you already have address with **CBD**, just restore it with your seed phrase into your local keystore. +```bash +docker exec -ti cyberd cyberdcli keys add --recover +docker exec cyberd cyberdcli show +``` + +If no, create new one using command below. +Also, you should send coins to that address to bound them later during validator submitting. +``` +docker exec -ti cyberd cyberdcli add +docker exec cyberd cyberdcli show +``` + +**** is any name you pick to represent this key pair. +You have to refer to this 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 ****. +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 +docker exec cyberd cyberd tendermint show_validator +``` + +It will return a bech32 public key. Let’s call it ****. +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 adjusting stake amount and other fields. + +```bash +docker exec cyberd cyberdcli tx stake create-validator \ + --amount=100CBD \ + --pubkey= \ + --moniker= \ + --trust-node \ + --from= \ + --commission-rate="0.10" \ + --commission-max-rate="0.20" \ + --commission-max-change-rate="0.01" +``` \ No newline at end of file diff --git a/docs/run_validator_node.md b/docs/run_validator_node.md deleted file mode 100644 index 4eb0124a..00000000 --- a/docs/run_validator_node.md +++ /dev/null @@ -1,65 +0,0 @@ -# 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 --recover -./cli show -``` - -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 -``` - - is any name you pick to represent this key pair. -You have to refer to this 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 . -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 . -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= \ - --moniker="hlb" \ - --trust-node \ - --from= \ - --commission-rate="0.10" \ - --commission-max-rate="0.20" \ - --commission-max-change-rate="0.01" -``` \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 3cbf3b78..7d2223e1 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,20 +1,11 @@ #!/bin/sh -if [ ! -f "/root/.cyberd/config/genesis.json" ] -then - cp /genesis.json /root/.cyberd/config/ - cat /root/.cyberd/config/genesis.json -fi - -if [ ! -f "/root/.cyberd/config/config.toml" ] -then - cp /config.toml /root/.cyberd/config/ -fi - - if [ ! -f "/root/.cyberd/config/node_key.json" ] then cyberd init + cp /genesis.json /root/.cyberd/config/ + cp /config.toml /root/.cyberd/config/ + cat /root/.cyberd/config/genesis.json fi exec "$@" \ No newline at end of file