diff --git a/app/handler.go b/app/handler.go index a51c9fd1..ac8b0cd1 100644 --- a/app/handler.go +++ b/app/handler.go @@ -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} } diff --git a/app/rank/README.md b/app/rank/README.md index 1d16eefe..63581db7 100644 --- a/app/rank/README.md +++ b/app/rank/README.md @@ -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/ @@ -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 @@ -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/ diff --git a/app/rank/calculate_gpu.go b/app/rank/calculate_gpu.go index af7b18c5..57ac7081 100644 --- a/app/rank/calculate_gpu.go +++ b/app/rank/calculate_gpu.go @@ -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" diff --git a/docs/join_network.md b/docs/join_network.md new file mode 100644 index 00000000..05991488 --- /dev/null +++ b/docs/join_network.md @@ -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. diff --git a/docs/run_testnet.md b/docs/run_testnet.md new file mode 100644 index 00000000..6debab2c --- /dev/null +++ b/docs/run_testnet.md @@ -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" +``` + + + diff --git a/docs/run_validator_node.md b/docs/run_validator_node.md new file mode 100644 index 00000000..4eb0124a --- /dev/null +++ b/docs/run_validator_node.md @@ -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 --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/go.mod b/go.mod index 81069aa7..ff19fbd2 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 46884d09..114a6bdc 100644 --- a/go.sum +++ b/go.sum @@ -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=