Creating a Cold Staking VM Using Google VM and Partyman
This tutorial is ported from reddit. Thanks to u/VicariousTrader.
I recently did a lot of trouble shooting on Google’s cloud VM API. I was trying to make the lowest resource(Dollar and Memory) unit work without crashing or hang ups. It was a lot more difficult than I had expected so I thought I’d share some tips for anyone looking to set up their own staking nodes. Note, I had similar problems with my Raspberry Pi machine and found that most of these fixes worked for the Pi unit as well. All useful commands and pictures will be at the end of the article.
The machine I used was the N series, f1 Micro; running debian 9(stretch) with 12GB of storage(slightly larger than standard for blockchain growth/pagefile size) and full http and https access. (see figure 4). This is the smallest and lowest cost machine I could find (4.50$ cad/mnth).
The first and biggest problem I ran in to; was every time the partyman Particl daemon would reach block 500k+, most of the low memory machines would hang up and eventually crash. Anything below 1G of memory had this problem. Since the blockchain was bigger than the memory’s buffer it would consistently crash or freeze. I found the work around for this in Linux was to create a swap or “page” file that would allow the lower memory machines to dump their memory. Page/swap files are not standard in linux. Adding a page file, of at least 3GB was sufficient; and anything lower had good chances of crashing still.
The second problem was that the particl daemon likes you to be logged in as particl. Adding the user “particl” with sudo access is strongly recommended.
The third problem I had was with the VM’s network connection cables. I was constantly getting a missing netcat dependency while trying to build the VM. Installing openBSD solved this problem for me.
The final problem was opening up port 51738 to allow full node access. This step might not seem important but, if you want your node to be a full node, this must also be done. This step is done outside the VM in your compute engine’s firewall settings. Path: Google Cloud Compute Engine~VPC Network~Firewall~Create Firewall Rule. Add an outbound Rule as well. Port must be opened for all traffic and use ip range 0.0.0.0/0 to allow all traffic. Since its a cold staking node and doesn’t have actual coins, allowing all traffic seemed reasonable/safe. Its worth noting, that partyman will run and stake without port 51738 open. It will however not be a full staking node and its contribution to the network will be minimalized. See pictures 1-3 for help with port opening.
Anyone using these tricks on a Pi machine and wants port 51738, can use the ufw feature to allow themselves control over their firewall settings. Just make sure you also add port 22 to the firewall’s exceptions if you are using SSH.
The machine I used was the lowest possible. Its the N Series f1 micro and runs at about 4$ a month. after I create the VM with the settings shown (see figure 4), I enter in the following commands, in order;
sudo apt-get update sudo apt-get upgrade sudo apt-get install -y netcat-openbsd sudo apt autoremove
Create Swap File:
sudo fallocate -l 3G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile sudo sysctl vm.swappiness=90
vm.swappines Changes how aggressively linux will use the swap. Lower values means it will try to avoid. After some testing I found 90 is best.
change the default in fstab so that when your VM reboots, the swap stays on
sudo nano /etc/fstab
Append the following line to the file; then save and exit:
/swapfile swap swap defaults 0 0
Check the status of /swapfile
sudo swapon --show
Add user particl with sudo access
sudo useradd -m -G sudo particl sudo passwd particl
To change user-profle
sudo -u particl -s
Now that the page file is set up, we have and are logged into our correct user, and have completed all appropriate updates, we can install partyman and the particl daemon.
note make sure you are logged in as particl and that you log back in as particl when rebooting. The daemon will be installed under “particl” only. Once you’ve logged into your particl user, you may not be in the home directory anymore. Start with changing to home directory
then go on.
sudo apt-get install python git unzip pv jq dnsutils cd ~ && git clone https://github.com/dasource/partyman cd partyman ./partyman install ./partyman restart now ./partyman status
Assuming everything went according to plan, you should now have a running cold staking unit for PART.
Once the blockchain is done syncing, you can create your staking node and link your coins to it. I have not run into any problems with these last few commands so, everything should run smoothly from here. Don’t forget to zap your outputs on your main wallet if you do not wish to wait for your coins to become active/you have low supply.
./partyman stakingnode initiniatite staking node protocol
./partyman stakingnode newCreate new staking node address
./partyman stakingnodelist all current staking addresses and QR codes for them
Even with all these settings/changes, the VM would hang up a little bit from time to time. Mostly while still downloading the blockchain. Once you have done the “./partyman restart now” command, just be patient. after about 2 hours the chain should finish downloading and the hang ups will go away.
- Firewall/UFW controller: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-debian-9
- Create a Swap File: https://linuxize.com/post/create-a-linux-swap-file/
- Change/Modify Users: https://devconnected.com/how-to-change-user-on-linux/
- Partyman Github: https://github.com/dasource/partyman
- Particl Web: https://particl.io/
- Particl Discord: https://discord.me/particl (@Vicarious my user-profile)
- Google Cloud: https://cloud.google.com
Firewall Rule Creator
Inbound 51738 Firewall Rule
Outbound 51738 Firewall Rule
VM Creation Image
https://upcloud.com/pricing/ is a viable option too. 1GB RAM and 25GB SSD for $5 a month. 3 day free trial.
Promo Code https://upcloud.com/signup/?promo=K5F88X