Cardano stakepool

Home > Portfolio > vrijstaat.net stakepool

What is Cardano?

Cardano is a decentralized proof of stake (PoS) blockchain designed to be a more efficient alternative to proof of work (PoW) networks like Bitcoin. Cardano’s cryptocurrency is named Ada.

Cardano stakepools help to expand and secure the network while generating rewards/blocks. A pool consists of a nodes, which fulfill the roles of a block producer and relays. Every node must run on its own network at a different location.

Case profile
ClientMextro Media
ExpertisesInfrastructure sourcing, installation & maintenance
Disaster prevention & recovery planning
User training
ProblemsBad performance, no rewards
Neglected infrastructure incapable of running node software
Insecure management access
SolutionsUpgraded existing and deployed new infrastructure
Switched from Ubuntu Server to FreeBSD
Improved security with industry best practices
Results99.99% uptime
Actively generating rewards
Ransomware attack thwarted
A rasterized globe, showing Cardano network traffic.
The challenges at hand

Downtime means missed blocks and thus less rewards. Uptime and security are key, with high availability failover impossible. Reliability and recoverability are also important as certain aspects of a block producer are not reproducible data. Nodes that underperform do not amortize the investment, meaning optimization is also necessary.

Leveraging FreeBSD

Originally the pool ran on Ubuntu Server 18 and 20. Version 18 is at end of support, so I decided to tackle the servers running that first. Looking at the upgrade path, I realized there was a lot of work involved getting the things I like to see in these kinds of applications. I also took Cardano’s decentralization mission to heart and decided to practice operating system decentralization: roll out an alternative OS. If there’s an attack for Linux, it probably won’t work on FreeBSD, and the other way around. Since the absolute vast majority runs pools on Linux, this is an inherent advantage, as it will be more likely that hackers develop attacks for Linux run pools.

A UNIX terminal running htop.
Tried and true performance

BSD has been powering the world since the 1970’s, and FreeBSD since 1993. It has better network performance, rock solid reliability, less security issues and more security features in the base system. It’s also the first containerization platform. Finetuning the base system to suit your needs is also trivial.

Reduced deploy times and maintenance

Normally one has to compile the Cardano node software on every machine for every update, which takes many hours. This time required scales linearly with with every deployment. FreeBSD is the only OS with node software available natively, cutting maintenance hours by massive margins. It also runs it inside of a container by default, aiding security.

To help manage nodes I created the cnodectl tool, similar to apachectl. It was also contributed to the CardanoBSD project.

A man wrenching at a car.
An inside view of a hard disk.
More speed and reliability, less cost

Through the native ZFS filesystem, I was able to guarantee data integrity for the nodes while also improving performance.

Software ZFS RAID is industry standard because it allows for losing physical disks without losing data, while also checking for data integrity and making snapshots.

The node database (~152GB), through native Zstandard compression, fits in only 80GB (1.9x ratio). This means that we can use a smaller and cheaper disk for longer before it fills up. It also improves performance as less physical data has to be read from or written to the disks.

    Karura (crypto bot)

    Home > Portfolio > Karura

    What was Karura?

    This will be a bit of a read, but in 2020 I had a burnout which lasted until early 2022. I got interested in cryptocurrencies and the stock market as I didn’t have the energy to apply myself to real full-time work. After I got released from my contract in 2021 I started writing this crypto bot to help me understand what is going on behind the flashy charts.

    A crypto bot starting up...

    Karura was a bot that could pull info from a crypto exchange, run calculations and then spit the results out on Telegram. It never progressed to the point where it could buy and sell on its own. But writing it was a trip! I learned about indicators and API’s and subtle intricacies of certain coins.

    The source code can be found on my GitHub.

    The nerdy bit

    Like Majorak, Karura was written in PHP. The goal was to learn and to get back into the swing of things after not doing much for close to one-and-a-half years. I decided not to use a framework, as I figured that it wouldn’t be needed. In hindsight it was probably easier to go with one.

    Pulling info from Kraken, my exchange at the time, turned out to be very difficult as they went down often. After realizing this I even implemented an automatic reconnect feature to help remedy this. It wasn’t enough and I switched to Binance, which never skipped a beat.

    Likewise I also did not use PHP’s trader extension… Preferring instead to dig deep into the algorithms behind the indicators like RSI or support & resistance. This turned out to be a good decision as I learned a lot about optimizing and even multithreading (which was overkill and never made it in!) Other madness soon followed. I realized that looking at a screen is really boring and I’d like to take it on the go…

    Deciding on Telegram, I had rough prototype code running and sending messages to my phone in intervals decided on by me.

    And… What then?

    It worked! Really well! It ran for over 4 months without pause. Eventually I learned to do what I had told the bot to do so it became obsolete. To this day I find the code to be written really well. I can take bits out and plop them in other projects and it still works flawlessly.