Setup a LumenX validator

in #lumenx2 years ago

We’re going through difficult times for freedom. Western world authorities have turned their back to fundamental civil rights, such as progress, equality, people’s sovereignty and freedom. Nevertheless as corporations and political powers crack on freedom of speech, a new technology emerges as the full realization of whatever the net of nets was meant to be: a decentralized network of nodes, aimed to be censorship resistant and save data even though a catastrophe happens.

Blockchain technology solves this uncanny trajectory that web 2.0 has followed in recent years of centralized services, creating unique opportunities to preserve financial and speech autonomy in face of authoritarian leaderships that globalization entails.

As a Cosmoschain network, Lumenx needs validators and relayers to work smoothly, validating around one new block every six seconds. Whoever can set a new validator should run a node on a 24/7 basis. For this purpose, nodes must download the entire history of blocks, transactions and consensus to be synchronized with the network. A server running is the optimal option, but we know that main Big Tech providers lack of cheap solutions.
In order to stay away from big actors and provide an easy, fully decentralized and affordable access to VPS, Threefold labs is an advanced web3 platform offering storage, kubernets and virtual machines. From now on, I’m describing the process to a full node deployment from zero and almost cost free.

Open a new Threefold account and purchase their nativeTFT tokens
• Go to Threefold Dashboard and follow instructions. You need to install Polkadot extension for your browser and connect your wallet. Create a new account if you don’t have one, and save mnemonics. Enter your contract page here.
• Go to the upper right corner, create profile manager. Follow the instructions.
• Download Threefold Connect on your mobile device. Fund your wallet with TFT and send them to the address coded in the QR.

  • For this purpose, the simplest and cheapest way is to purchase or swap XLM (Stellar Lumens) in your favourite exchange, send them to a XLM account at Stellar Exchange and exchange them for TFT. About 500 TFT will last for some months.

    • Once you receive funds, deploy a Full Virtual Machine. Configure it with at least 4 vCPU, 8 GB RAM and 300 GB disk. Activate at least IPv4 and IPFS, scroll down to select the latest Ubuntu version and choose a working node to deploy your VPS (node 1 seems to work well).

    • Wait some minutes for the new contract, and copy the IP4. You can connect to it using the command

$ ssh [email protected]

  (where XXX.XXX.XXX.XXX is the VPS Ipv4 address). You can always consult your remaining funds, hourly costs and deployments by browsing to https://play.grid.tf/#/and activating your existing profile with your password. If you clean the web cache or access from a different browser/computer, you will have to create it again using the mnemonics and SSH key, so be warned to keep these data secure!

• Go again to Assets to withdraw your lumen (IBC transfer from Osmosis to LumenX account).

Prepare your VPS environment

Enter the virtual console by typing this command.

$ ssh [email protected]

Then, the console will ask for permission to create a key pair for the new remote connection. Accept the key creation, and you will switch into your server shell.

Upgrade the installed packages

$ apt update && apt upgrade

Install critical packages
$ apt install software-properties-common nano git curl make ufw jq build-essential unzip snap -y

Optional: create a separate user for your node

$ adduser lumenx #lumenx is the name for the newuser, you may choose any other
$ adduser lumenx sudo #add lumenx to the superuser group
$ su - lumenx

Install the compiler

$ sudo snap install go --channel=stable --classic
$ go version #check the version installed
$ export PATH=$PATH:$HOME/go/bin
$ echo export PATH=$PATH:$HOME/go/bin >> ~/.bashrc #add go binaries directory to path

Compile and install node binaries
$ git clone https://github.com/cryptonetD/lumenx.git && cd lumenx
$ git checkout v1.4.0
$ make install
$ lumenxd version #check the installation is correct

Initialize the node

$ lumenxd init YourNodeName #Choose the public name to be displayed
$ wget -O ${HOME}/.lumenx/config/genesis.json https://raw.githubusercontent.com/cryptonetD/lumenx/main/config/genesis.json #Download genesis file

Add peers to your config file
$ sed -E -i 's/persistent_peers = ".*"/persistent_peers = "[email protected]:26696,[email protected]:26666,[email protected]:26656,[email protected]:26656”/' $HOME/.lumenx/config/config.toml
Or you can edit the config file
$ nano ~/.lumenx/config/config.toml
scroll down to persistent_peers and add the content
"[email protected]:26696,[email protected]:26666,[email protected]:26656,[email protected]:26656”

Set StateSync module

SNAP_RPC="https://rpc.lumenx.chaintools.tech:443"
SNAP_RPC2="https://rpc-lumenx.cryptonet.pl:443"
LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height);
BLOCK_HEIGHT=$((LATEST_HEIGHT - 1000));
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH
sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).$|\1true| ;
s|^(rpc_servers[[:space:]]+=[[:space:]]+).
$|\1"$SNAP_RPC,$SNAP_RPC2"| ;
s|^(trust_height[[:space:]]+=[[:space:]]+).$|\1$BLOCK_HEIGHT| ;
s|^(trust_hash[[:space:]]+=[[:space:]]+).
$|\1"$TRUST_HASH"| ;
s|^(seeds[[:space:]]+=[[:space:]]+).*$|\1""|" $HOME/.lumenx/config/config.toml

Or edit config.toml using nano command, scroll down to StateSync, enable the module and fill with the content shown here:
https://ping.pub/lumenx/statesync

Create daemon service

$ sudo tee /lib/systemd/system/lumenxd.service > /dev/null << EOF

[Unit]
Description=Lumenx Mainnet Node Service
After=network-online.target
[Service]
User=$USER
ExecStart=$HOME/go/bin/lumenxd start
Restart=on-failure
Restart=always
RestartSec=10
LimitNOFILE=4096
Environment="DAEMON_HOME=$HOME/.lumenx"
Environment="DAEMON_NAME=lumenxd"
[Install]
WantedBy=multi-user.target
EOF

$ sudo systemctl enable lumenxd #enable the service to run at startup
$ sudo systemctl start lumenxd #start the service manually

Check the node daemon is synchronized and validating transactions
$ sudo journalctl -fu lumenxd -o cat #check the service feed #CTRL+C to exit

Create keyring pairs

$ lumenxd keys add key_file_name -i #you can choose any name for your key file

At this point you will need to insert your Cosmos account BIP39 mnemonic (to access your wallet). Click enter. For the second question,just hit enter. Finally, establish a password (any password you choose) to save your key pair. If no error is displayed, you are ready for the last step!

CREATE VALIDATOR

$ MONIKER=YourNodeName #repeat the public name chosen for your node
lumenxd tx staking create-validator
--amount= 1000000ulumen \ #The amount of tokens to autostake *1000000
--pubkey=$(lumenxd tendermint show-validator)
--moniker="$MONIKER"
--commission-rate="0.10"
--commission-max-rate="0.20"
--commission-max-change-rate="0.05"
--min-self-delegation="1"
--from=key_file_name \ #repeat the name of your key file
--chain-id=LumenX
--fees=5000ulumen

In the example above, we are autostaking 1 lumen (note that any amount is given in microunits, so it’s necessary to multiply it by a million, adding six zeros). The commission rate is the part of all delegators’ rewards you will receive. In this case, it is 10% (0.10). The maximum commission rate is a warrant to delegators you won’t be able to rise it above this value. In this case, it is 20% (0.20). This data can’t be changed, so specify a comfortable value margin.

Rate change is the maximum amount you will be able to change at once, using the edit options. Minimum self delegation is the minimum amount you ought to autostake. If you ever fall below this minimum, your validator will be jailed.

Once created, check your validator status by typing

$ lumenxd status | jq '.validator_info'

Also check your validator is visible here:

https://ping.pub/lumenx/staking
Don’t forget to backup also this file
$HOME/.lumenx/config/priv_validator_key.json

It’s the blockchain identity of your validator. If you ever lose it, you won’t be able to restore it again and you will need to start from scratch with a different account.
Good luck and enjoy your staking.