XDAGJ part 3 : setup & first run

FSOL
5 min readNov 8, 2022

--

This is the last part of this series concerning installing his own XDAGJ server. Please have a look on episode 1 and episode 2 before. Let’s go !

Reminder

This article is base on XDAGJ_Devnet_Tutorial_en.md file on GitHub XDAGJ repository.

1°/ Unpack XDAGJ

  • In terminal, let’s install UNZIP utility :
sudo apt install unzip
  • Now, let’s do that :
cd
cd xdagj
mkdir run && cd run
unzip ../dist/xdagj-linux.zip
  • You get this :

2°/ Create wallet

  • This wallet will contain the mining pool fees generated by miners.
  • Before create wallet, we need to apply HUGEPAGES setting :
sudo sysctl -w vm.nr_hugepages=2560
sudo bash -c "echo vm.nr_hugepages=2560 >> /etc/sysctl.conf"
  • Now, this is the command for launching XDAGJ manually :
sh xdag.sh -d
  • We use -dparameter to say we use DevNetwork.
  • Also, it could be -tparameter for TestNetwork.
  • And give any parameter to use MainNet.
  • You get this, but don’t worry, that’s normal :
  • You’ll have to create wallet for your node/pool. Give a password twice.
  • Then you’ll get mnemonic’s wallet. Don’t loose it, write it in a secured place :
  • Copy / Paste it with mouse selection :
  • Save this mnemonic phrase in a safe place, it is important.
  • And then it’ll display :
  • Now XDAGJ apparently working.

3°/ What happened during this first run ?

  • Now , let’s make some checks. Press <CTRL> + C to break execution, and let’s list directory :
ls -l

You should get this :

  • As you can see, 2 directories have been created : “devnet”& “logs”.
  • You can guess what’s inside “logs” directory.
  • On the other hand, let’s list the “devnet” contents :
cd devnet
ls -l
  • Directory “rocksdb” contain the DAG database.
  • Directory “wallet” contain node/pool wallet.

4°/ Create XDAG service

  • We want XDAG automatically start when PC is starting up. Let’s create a file service. In terminal, type :
sudo nano xdag.service
  • Copy/Paste theses lines inside editor :
[Unit]
Description=Xdagj
After=network.target
[Service]
User=<YOUR_USERNAME>
Group=users
Type=simple
Restart=on-failure
WorkingDirectory=/home/<YOUR_USERNAME>/xdagj/run
# For Mainnet node
# ExecStart=/bin/bash /home/<YOUR_USERNAME>/xdagj/run/xdag.sh
# For Testnet node
# ExecStart=/bin/bash /home/<YOUR_USERNAME>/xdagj/run/xdag.sh -t
# For Devnet node (Default)
ExecStart=/bin/bash /home/<YOUR_USERNAME>/xdagj/run/xdag.sh -d
# XDAGJ_WALLET_PASSWORD environment variable is required to automatically unlock your wallet.data file.
# Please ensure sure that the access permission of this service unit file is properly configured when you put your pas>
Environment=XDAGJ_WALLET_PASSWORD=<YOUR_WALLET_PASSWORD>
TimeoutStopSec=90
KillSignal=SIGINT
FinalKillSignal=SIGKILL
LimitNOFILE=500000
[Install]
WantedBy=multi-user.target
  • It should look like this :
  • Replace “<YOUR_USERNAME>” by your username set when you install Ubuntu Server (check screenshot 23 on article 1).
  • Replace “<YOUR_WALLET_PASSWORD>” by your real password.
  • To save and quit, press <CTRL> + X, then Y (for YES) and press ENTER to confirm.
  • We are now back to terminal, let’s copy this file in the right directory :
sudo cp xdag.service /etc/systemd/system/xdag.service
  • Let’s give some power to “xdag.sh” :
chmod +x xdag.sh
  • Now we will reset the services that start automatically when the server is turned on to take into account the new XDAG service :
sudo systemctl daemon-reload
sudo systemctl enable xdag.service
sudo systemctl start xdag.service
  • You’ll get this :

5°/ Proof of work

  • Let’s check if “xdag.service” is running properly :
sudo systemctl status xdag.service
  • You should get this :
  • Don’t be afraid with error on line 3 and warnings.
  • Line 6 say “telnet is running on 127.0.0.1:6001”. Don’t forget that, it’ll be very usefull !
  • Make CTRL + C to break this display.
  • Let’s check with “HTOP” utility :
htop
  • Red area : CPU threads
  • Green area : RAM state
  • Yellow area : all JAVA process with first one called “xdag.sh” (we know this file !)
  • Press F10 to quit.

Now your XDAGJ node/pool is running and automatically start when your Ubuntu server launch. BRAVO !

6°/ Let’s talk with XDAGJ

  • To talk with XDAGJ, we had to connect its with telnet on 127.0.0.1 port 6001. This address is its own address, only your server can access it :
telnet 127.0.0.1 6001
  • Default password is “root” (we’ll change that later).
  • What can we do know ?
help
  • Red area : all XDAG’s commands that exist.
  • Let’s try some :
state
  • Everything is normal. Can’t we get more informations ?
stats
  • In my case (I start with fresh new DAG from genesis), the DAG height is 95.
  • Let’s see last main blocks :
mainblocks
  • Beautiful !

7°/ Conclusion

Our XDAGJ server is now functional, DAG was create and works. The goal of this series is reached ! I had originally planned 3 articles for this series. So it is finished !

But there is still so much to say about XDAGJ to understand how it works and to master it…

That’s why I’m announcing the extension of this series and the arrival of other articles that will follow the 3 already published. We will learn how to do some stylish stuff and improve our skill with XDAGJ !

So, let’s go to part 4 of XDAGJ serie!

--

--