8. LAN shared node on RPi 4 - HaroldSP/Harold Wiki

Idena is a new blockchain and cool community with a proof-of-person technology, more about you can read here.

The basic idea of this article is to show how to make a LAN shared node on Raspberry Pi 4. It would be an easy guide and advanced users will not find here anything new.

1. Burning the image (Ubuntu 21.10 for Raspberry Pi)

It's not a big deal and there's a lot of tutorials on how to do that. The official image and all the info one can find on the official Canonical web-page. Ubuntu 21.10, server, 64-bit.

Micro SD card 256 GB, Samsung. Later on, I will provide some similar tutorials where the author is using M.2 SSD disk due to the better petter performance and less harmful operation mode, but after checking the prices I have decided that I will only use my 256 GB card because I need it only on the validation and the rest of the time it will be off.

2. Wi-Fi connection issues

For some unknown reason for me, there is some pain in connecting to wi-fi. This is that usually you just edit the network-config file on the system-boot partition (from Windows), put your credentials, and, voila, you are connected to wi-fi and can easily SSH into Raspberry. But this time it was different. I will leave links at the end of this section for those who are interested in more details, but that's what you should do:

2.1. Comment all code in that file except for wi-fi section:

version: 2
wifis:
  wlan0:
    dhcp4: true
    optional: true
    access-points:
      "your-wifi-name":
        password: "your-password"

That actually differs from the official website. Strictly spaces, no tabs, indentation matters.

2.2. Append this to the end of 'user-data':

##Reboot after cloud-init completes
power_state:
  mode: reboot

2.3. Link to the thread

3. Code

I will not go through the details, I will just leave some links to similar articles. The basic principle is that you need to prepare the environment and install a regular node, afterward make a shared node but the LAN one. Making a globally accessible shared node is a little bit more sophisticated and out of this article, though you can find some useful info in the provided links.

sudo apt update && sudo apt upgrade
sudo reboot

#getting your pi ip
sudo apt install net-tools
ifconfig

#We are installing tmux to be able to keep certain programs running even when PuTTY is closed, give this time to install
sudo apt-get install tmux

#golang is needed for us to use the Idena node, give this time to load. If you are having issues with this command - make sure you have the newest Ubuntu OS. See the software requirements above.
sudo apt-get install golang
sudo reboot

#checking if go and c is installed
go version
gcc -v

#setup 1GB of swap
sudo fallocate -l 1G /swapfile2 && sudo chmod 600 /swapfile2 && sudo mkswap /swapfile2 && sudo swapon /swapfile2 && echo "/swapfile2 none swap sw 0 0" | sudo tee -a /etc/fstab

node_version="0.28.3"
#download idena node source code and compile it
wget https://github.com/idena-network/idena-go/archive/refs/tags/v$node_version.tar.gz
tar -xf v$node_version.tar.gz                                                                                                                
cd idena-go-$node_version                                                                  
go build -ldflags "-X main.version=$node_version"
mv idena-go ..
cd ..
rm -r idena-go-$node_version v$node_version.tar.gz

#Ensure you have enabled 9009 port in the firewall: 
sudo ufw allow 9009

#making a shared node configuration file
#type it manually via nano or vim or do it with just one command
bash -c 'echo "{\"IpfsConf\":{\"Profile\": \"server\" ,\"FlipPinThreshold\":1},\"Sync\": {\"LoadAllFlips\": true}}" > config.json'

#starting idena node with an apikey flag (you can set whatever you want). A shared node flag is unnessesary for a lan shared node
#screen -dmS idena ./idena-go --rpcaddr=0.0.0.0 --apikey=123 config=config.json --profile=shared
screen -dmS idena ./idena-go --rpcaddr=0.0.0.0 --apikey=123 config=config.json

And that's it for the RPi part.

4. Making a tunnel. Laptop part

Now you need to make a shh tunnel to your localhost. You need Putty installed. Check path. Simply make the .bat file with the following contents:

@echo off
start "Putty" "C:\Program Files\PuTTY\putty.exe" -ssh -L 9009:localhost:9009 [email protected] 22 -pw your-rpi-user-password-without-quotes

5. Verification and extra links

Now you can go to the web-idena page, log in using your crypto identity's private key and your password, then go settings 🠊 Node and enter shared node url http://localhost:9009 and an API key, that you used in the flag.

That's it, now it should work.

5.1. Extra links:

Step by step instructions on how to run Idena node on Raspberry Pi 4 + m.2 drive

Script for Idena node setup on 64-bit Ubuntu server

oficcial article shared-node-setup-on-vps

running-your-own-shared-node-step-by-step-tutorial

enabling-ssl-for-the-shared-node-proxy-step-by-step-tutorial

Rusian article about shared node

Riaoda's global shred node

Adding your shared node to an Idena node marketplace

how-to-connect-web-app-to-my-node-on-vps

idena-go releases

indonesian guy sets up shared node on DO vps

This is an interesting and very in-deep article about shared node, maybe someday I will look through it more thoroughly:

Idena public shared node setup guide using your own SSL termination

5.2. Back-up

Actually, I do not understand why do they sometimes delete some articles without any announcement, but I do not want to go through a huge discussion about it, I will just leave an old code as it was, here with some extra explanation:

Web validation and Shared node in LAN setup shared node web validation lan. If you have multiple nodes in one local network, such as your home, you can set up a shared node for web validation. Running one node on one internet connection with greater hardware resources provides a better validation experience as opposed to running multiple nodes. You will need Linux machine (Ubuntu/Debian) or VM on which you will run the installation script. The script will set up a new node without identity to serve as a shared node for web validation. It is recommended that you shut down all other nodes, and leave just the shared node running during validation.

1. Install/use Ubuntu/Debian virtual machine with minimum 2 cores and 4GB ram.

2. Run instalation script on your virtual machine, it will setup and run shared node: wget https://raw.githubusercontent.com/rioda-org/idena/main/shared-node-lan.sh && bash shared-node-lan.sh

3. Let's connect client using the web app.

- Download and install Putty

- Make connect.bat file with contents: @echo off start "Putty" "C:\Program Files\PuTTY\putty.exe" -ssh -L 9009:localhost:9009 [email protected]_ADDRESS 22 -pw PASSWORD Change parameters so you can connect to your virtual machine. Run connect.bat so that pc has the connection up and running.

- Export private key from Idena desktop app in the Settings page, open Web app and enter private key and password that you got from Idena desktop app.

- For connection parameters, use: Shared node URL: http://localhost:9009 Shared node api key: 123

Good luck with your web validation!

#!/bin/bash
sudo apt-get install unzip curl screen -y
mkdir shared-node
cd shared-node
mkdir datadir
cd datadir
mkdir idenachain.db
cd idenachain.db
#wget https://idena.site/idenachain.db.zip
wget "https://sync.idena.site/idenachain.db.zip"
unzip idenachain.db.zip
rm idenachain.db.zip
cd ..
cd ..
curl -s https://api.github.com/repos/idena-network/idena-go/releases/latest | grep browser_download_url | grep idena-node-linux-0.* | cut -d '"' -f 4 | wget -qi -
mv idena-* idena-go && chmod +x idena-go
bash -c 'echo "{\"IpfsConf\":{\"Profile\": \"server\" ,\"FlipPinThreshold\":1},\"Sync\": {\"LoadAllFlips\": true}}" > config.json'
touch node-restarted.log
bash -c 'echo "while :
do
./idena-go --config=config.json --apikey=123
date >> node-restarted.log
done" > start'
chmod +x start
screen -dmS node ./start