This guide addresses enthusiastic amateurs and professionals with experience with linux, knowlegde on the shell (I used /bin/bash), who want to run a DECENT witness node.
I couldn’t find an easy and understandable step-by-step-guide which explains everything in simple English and also offeres some background – so I gathered all the information, researched, learned and want to share with you now. To make a long story short: I wrote the ultimate guide to setup a DECENT witness node and run it!
Due to the fact that DECENT once forked from bitshares/Graphene it uses a Delegated Proof of Stake (DPoS) consensus mechanism instead of Proof of Work (like for example Bitcoin does). So Mining is not defined in DECENT as a competition of calculations to find a solution for a block hash under changing limitations. Instead DECENT’s DPoS votes single nodes to give them a chance to build blocks. For that, one’s node needs to create a mining object and be voted in for “witnessing” – so to build up blocks with actual transactions and sign them. Of course such a system does not support a “come and go as you want” behaviour, but needs a node to stay online 24/7.
In exchange DPoS is by far faster and scales much better than any PoW-system. In best case it will always extend its limits and can process thousands of transactions per second. So it becomes a system supporting something like real-time processing transactions on a virtual dezentralized machine. If you have already an account from the ICO and a running decentd with wallet_cli compiled, you can go right into action!
Part II: Hardware and environment for your DECENT witness
This was my first stumbling block, setting up DECENT’s witness node.
You need to stay online 24/7 and be reachable under the same ip/domain without restarting decentd (daemon) for a long time.
Basis for everything should be linux (Debian or Ubuntu 16.04), but there are also some hardware requirements, if you want to follow the more complicated way (compiling). I will only touch that topic lightly here, because it easily becomes some “work intensive” and frustrating for both beginner and pros if it does not work. There is a second by far easier to setup version with docker (later more).
For both compiling and the by docker containerized version you need experience with linux and software/hardware which fulfills the following recommended requirements:
- Linux kernel > Version 4
- 4 Cores
- 16 GB RAM
- 500 MB HDD
- reasonable amount of swapspace (let’s say RAM + 100 MB)
A VPS with which is virtualized with openVZ DOES NOT work! The kernel version is too low and usually these offers do not support real swap space and only a 2.6.x kernel, which does not compile the code properly, nor is able to run docker. You can check your kernel version with “uname -r”.
Compiling (build from the scratch)
The sources for the decent network you can find on github. Ich you want to build from the scratch you can also try to follow texxi’s instructions on steemit (little bit outdated). At this point I will only give you a general desciption and common recommendation.
With git you can fork from the source, but for compiling you need special versions of libboost (1.60). So you need to take care to install the needed version of libboost and place it in your #path OR compile libboost for your system in the beginning. Here I see also a hurdle for developer, cause you need to separate your environment from other projects, and you need to take care of versioning. That can become pretty hard, if you have no experience with.
I can only highly recommend to setup your own user for DECENT after preparing the environment for build and make.
BTW: DECENT’s DCore is a complex and far developed project and compiling needs a long time and a high frustration tolerance and eager will to learn for beginners.
Dockerized version – use docker containers
On github a developer led me to a by far easier version. A big thanks at this point to marian-decent-ch for his support the preparation of some test containers and introduction to docker. I guess you are Marian Vanderka on DECENT’s team page. Also thanks to Mark Peter Mansell who is fighting himself through to achieve a proper documentation. I hope my guide for dummies can show where the hurdles for newbie devs are, who are not familiar the the graphene family already.
Also for the use of docker I give you only a common introduction, but I tried this on both docker for windows and linux. Both worked perfectly fine. I recommend a docker gui like portainer or kitematic. It is not really needed, but makes things easier to handle here and there.
What is a docker?
A docker puts everything which is needed to run an app in a container and makes it executetable on different OS or environments. Imagine it like an emulator, but it is more like a virtual machine in a box and this box has connections to its outside world like network, terminal and access to RAM, CPU cores and volumes.
The top source for already prepared docker containers is hub.docker.com where you can find also actual DECENT containers, which seem to be better manintained than some time ago, when I started my research on DECENT. You will need the containers with decentd and the wallet_cli. No need to download them now. docker will do that later automatically and all required dependencies at the first start. Please note that you need a working docker environment on your server. The CE-Version is okay. If you’re on ubuntu 16.04 you can follow these instructions (some complicated) or you can let the docker-script do all the work with:
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh
docker starts the dockerd daemon in the background, which is the entity which catches your docker commands and executes containters. If you only want to give it a quick check, if docker is properly setup to host the DECENT containers, you can open a terminal, respectively two terminals and with
docker run --rm -it --network=host decentnetwork/decentd decentd
and
docker run --rm -it --network=host decentnetwork/cli_wallet cli_wallet
you can start the daemon and the wallet_cli.
Please note that the decentd first needs to sync with the network. Actually there are more than 5 mil blocks, so it needs some time.
Please also note, that the wallet_cli will only connect to the synced daemon.
As a little test this is okay. You can stop the daemon with CTRL+C now. Due to the fact docker started the container with -rm option all the work will be gone anyway after stopping the container.
Please note that I used a root access, but it makes for sure more sense to create a new user, grand sudoer rights, disallow root access, prepare the server to resist against brute force attacks, setup a firewall, also install fail2ban and so on. Please don’t neglect hardening your server!
Anyway I created a space for decent to store its data. In case you also want to do so you have to add your home dir in the beginning of the path.
mkdir /scratch/decent
(This creates some temporarely space for DECENT’s data. I stole that idea from setting up and using my own lightning wallet.)
Open two terminals. In one you start the daemon. If you don’t use docker you can put it on its own screen. That’s not needed here, I’ll stick to the dockerized version.
docker run -it -v /scratch/decent:/root/.decent --network=host decentnetwork/decentd:latest decentd
That makes docker downloading the latest image and run the daemon in it, but maps the internal folder /root/.decent to the external directory /scratch/decent. That folder we later need access to. About the network you don’t need to care. The container claims and forwards the needed ports itself for the connections to the DECENT network and being reachable for remote procedure calls.
On the terminal you can see the daemon syncing with the network. After a start without the -rm (remove) option and mapping the work directory you can even close the terminal, or stop the daemon with CTRL+C, or stop/start/restart the whole container without to reindex or resync from the beginning. Also the docker container’s ID will stay the same (later more).
Time to startup the wallet_cli container. Please note that you better let the daemon sync first. You can compare block height at explorer.decent.ch. Then in the second terminal you start the second container with
docker run -it -v /scratch/decent:/root/.decent --network=host decentnetwork/cli_wallet:latest cli_wallet
As you see the cli uses the same folder and network. One hit on the RETURN-key and you see a prompt like “NEW >>>” which indicates that the wallet_cli was started for the first time and connected properly to the daemon.
Congratulations – you have a running environment to run a DECENT witness node.
Note, that from here on you can also start/stop the containers with your favorite docker gui (like kitematic or portainer). If you accidently close the shell or terminal you can login again and with
docker ps
you can find a list of running containers.
If you want to take over the STDout of a running container you can do so with
docker attach docker_id
If you want another shell into a running docker container you can do so with
docker exec -i -t docker_id /bin/bash
An now, please follow me into the rabbit hole – we will meet Alice.
Part III: Setting up the account, DECENT witness node and voting
As mentioned above it is time to take our chances and follow Alice deep deep into the rabbit hole. While Part I and II are easy to achieve for nearly any linux system admin the following part is somewhat harder. You have to keep in mind that even if you have already experience with other blockchains like Bitcoin and Co this is different. If you are a pro with bitshares/Graphene this is not a challenge at all, if you already setup masternodes for DASH or DASH-based developments like the super-save and super-secure CRAVE, you will find differences and similarities in setting up a witness node in DECENT.
From here on I will only roughly comment what is going on, so fasten your seat belts – here we go:
Please prepare a textfile on your desktop to copy & paste – you will need it! If you get a connection lost without copying the data, people will hear your cursing all over the world. So better prepare yourself a copy of what your’re doing and the results.
Now switch to the shell with the already open wallet_cli. It should greet you with “NEW >>>”. you have to type an re-type a password it and afterwords uplock the wallet with
unlock yourpassword
the prompt changes to “UNLOCKED >>>”
Now we will import your accountname and private key (which you should have ready, your textfile is a good place to store it temporarely).
import_key decentgousername privkey
returns TRUE if it worked fine. Now our wallet feels responsible for your account and has access to DECENT’s blockchain through it. We create three new sets of keys for it. Which works easily with three times
suggest_brain_key
each time in return you get a newly created keyset as a json object, which you copy into your textfile. Similar like
{
"brain_priv_key": "here are the text phrases",
"wif_priv_key": "privkey",
"pub_key": "pubkey"
}
I will call them now key 1 to 3. Using these keys you will register a complete new account now, but you can choose some stuff in between:
register_account new_username publickey1 publickey2 decentgousername true
That means: You register a new account with the new username username, sign that with pubkey1 and pubkey2 from your user decentgousername.
In return you get a json object again stating the new user account information. Copy it to your text file! This is the account you will setup the miner for. Important for this at the moment is the name only. That will be the name others can vote for later and which will appear in the “miner list” – as I know, but later there is another username which could be for that. I choose the same anyway.
The next step is obsolete at the time of writing, but I mention it anyway, because it is at least possible it becomes relevant again in the future. In the past it was needed to “deposit” some DCT on the miner. I read something about 3 DCT later about 50 DCT and only asking on DECENT’s telegram channel eventually brought out, that actually you don’t need to send any DCT to the miner account. If you have to later in the future it works like this:
transfer decentgousername new_username 50.00 DCT "memo" true
which means to send 50 DCT from your Decentgo-Account to your newly registered account. Fees are deducted from your account’s balance, not from the amount you’re sending. “memo” is a an optional note of your choice.
If it was needed to send 50 DCT (or whatever) you get in result a json object which states all needed information which was sent to the blockchain. Copy that.
Next step is to import the new account into your wallet. That was hard to understand for me, because I just created it with my wallet. But to create an account does not mean to own it. Maybe you created one for your friend – whatever the reason is, you need to import that. We already know how it works:
import_key new_username privkey2
You import the new account and sign that with the pivkey2 – one of the ones you already created it with. That grants you that permission and makes it verifiable. Result should be TRUE.
Now we shutdown the daemon with CRTL+C on the other terminal, which turns off the wallet_cli also. NOTE: DON’T LOCK the WALLET before. Don’t lock it at any time during this procedure- I did that and lost control over login again. Just let the wallet_cli container die. We restart it later. On the daemon terminal or on a new terminal you hangle through to
/root/.decent/data/decentd/config.ini
respectively (depending on your access shell):
/scratch/decent/data/decentd/config.ini
and open it with your favourite text editor. Mine is nano. So
nano /root/.decent/data/decentd/config.ini
does the job. nano has the advantage that on a ssh shell via putty you can copy-paste from and to a text file with rightclick. So it is awesome easy to copy
private-key = ["pubkey2","wifprivkey2"]
at the end of the file. Self-explanatory.
Restart both containers, with the docker run commands from above – first the daemon, of course. If you have a docker gui installed feel free also to use that to restart the containers and on the shell just with “docker ps” and “docker attach yxz” connect to the docker shells again. Let’s assume you did that, then you can create the so called miner object for your new user now.
create_miner username "proposal URL" true
What is proposal URL? Any URL you can show off why and how you setup your miner. Please prepare a website, blog, steemit, twitter or any reachable URL to explain your node, your intentions and if you like your ideology. In a DPoS-system like DECENT validating and block building nodes are really decentralized. PoW consensun mechanisms are needed for Bitcoin, but both PoW and PoW/PoS-Hybrids have the tendency to centralize. My two cent. Even a DASH-like masternode system offers some kind of VIP-Service (faster, more secure, more anonymously) at a higher price. But the fee is like some kind of “interest” on investment which is justified by the risk of being an early adopter/investor. Meanwhile the value of DASH is so high that the price for newcomers to run a masternode are a high barrier. So value is flowing to the already gathered value – centralizing. That kind of hoarding led to a HODL-attitude which is crippling innovation, but on bitshares/Graphene-based DPoS like DECENT the innovation can florish and new business concepts come across and alive. Not like BCash-supporter (I won’t drop names here, but you know who I am talking about), who see in their mining a money printing machine, in which they put their claws and they don’t want to give up under any circumstands. Lighting Network foresaw that and insisted on development forward. But sorry for the ideological rant, back to topic.
In return for creating the miner you get a json object with the transaction data for the creation. Next and last (!) step is a to change the signing key of our miner to the third one to “disconnect” from our keys used before to create the account and the miner object. With that we will get our miner-id!
update_miner username "proposal URL" publickey3 true
should be pretty clear. To get the witness in action we need to edit the config.ini again and add
enable-stale-production = true
miner-id = "1.4.X"
at the end of the file, where miner-id you get from the last json returned (which you saved nice and neat in your text file!)
Note: The miner-id is NOT the miner_account! It starts actually with 1.4.x NOT with 1.2.x!
Restart the daemon container! Done!
Was that that hard?
For me it was. Not the procedure itself, but to figure all that out – even with good connections to DECENT.
You can check the result by logging in at your decentgo client and check the section “vote” after decentgo synced. If you have DCT in your wallet you can already vote your node – or even better mine (jagottsicher). 🙂 If you liked this article and found it useful then vote for my node anyway! All my writing is without warranty and you do it on your own risk. But, I think this is the ultimate guide to run a DECENT witness node. A Seeder node should be very similar probably you ned to create a seeder object.
It took me days to figure all this out, but I didn’t want you just to copy-paste lots of code without understanding it. I hope my comments will help you. For me the telegram group of DECENT was a good source of support – even the founder contacted me and helped – and github also was useful. For Chinese (Mandarin) developers there are probably more sources, because many of the DECENT and DCore devs are located in China and do a hellish good job, but documentation in English suffered from that and was maybe somewhat neclegted. That’s another reason for me to write this little guide in English and not in my mother’s tongue, German.
And now:
Please vote for my node on DECENT!
vote_for_miner username jagottsicher true true
And I will vote your node in return if you leave me a comment – at best with a screenie of your vote!