Welcome to Meros’s Update #28, covering 2/20/20 to 3/25/20! It’s been another five weeks since our last update, so we’re excited to detail everything we’ve done. When we left off, the main problem we were targeting was chain reorganizations. We had yet to implement them due to their complexity, yet we’re happy to announce they’re now properly implemented!
The steps to move to a more secure chain can be broken down as follows:
- Detect a longer chain.
- Revert to the last common block.
- Sync the longer chain.
As of the last update, we had implemented reversions for our Transactions DAG (storing transactions) and our Blockchain (storing various metadata). We had yet to implement reversions for our Consensus DAG, which keeps track of if transactions are verified/what the difficulties are/what Merit Removals exist. This was the most complicated system to implement reversions for, and the process identified several flaws in our existing code.
We reverted the Consensus and found some transactions were marked verified when they were originally unverified. It turns out, in a variety of scenarios, we wouldn’t mark transactions as verified when we were safely able to. Thankfully, we never marked transactions verified when they shouldn’t have been. These bugs hampered the speed at which transactions were verified, yet didn’t risk a error. Having fixed these bugs and implemented Consensus reversions, we now have a DAG that works as it needs to and is more efficient than before.
After finishing Consensus reversions, we focused on detecting longer chains. When we discuss longer chains in cryptocurrency, we don’t mean “This one has a length of 5 and this one has a length of 6”. “Longer chain” is a simplification made. What’s really intended is the chain with the most hash power behind it. If you lower the difficulty, you can easily find a longer chain, yet it won’t have the same security.
When calculating chain work, our existing difficulty code acted as a barrier. The existing code was… functional. It properly calculated a difficulty to try to preserve a ten minute block time. That said, it used a full 256-bit hash to represent difficulty, which made the algorithm to calculate chain work very slow. To solve this problem, we redid our difficulty.
Inspired by Cryptonote, which was inspired by Bitcoin, we now use a 64-bit difficulty for the Blockchain and a 32-bit difficulty for transactions. We also updated our algorithm from the custom algorithm it was to a standardized SMA, which offers greater accuracy in updating the difficulty to match the block time.
Beyond the functionality that was needed for our next testnet, there was also a bug causing nodes to crash after a few days. It turns out our networking code had what’s called a ‘data race’ in it. The networking library we use creates a network connection and tries to use it, before confirming the computer finished creating the connection. On a very rare occurrence, the networking library would try to use the connection before it was created, when most of the time it would be created before we attempted to use it, as the computer would be faster and win the ‘race’, which caused Meros to error out.
Unfortunately, due to the placement of this bug, we can’t easily fix it. For now, we’ve found a solution to stop the bug from triggering, yet it’s not optimal. The current solution is to slow Meros down to make sure it loses the race. Unfortunately, we can’t just slow down Meros in this one specific spot, so as of right now, Meros has been globally slowed down by around ~10%. We aim to fix this before mainnet.
Finally, we now have Docker images for Meros. They’re automatically built from the latest codebase, and available from Docker Hub. We’re happy to have these available as they represent making Meros even more accessible to people who want to run a node, no matter their background. This improvement is thanks to Javier Romero, a developer helping work on Meros.
That concludes the exciting updates from the past five weeks. A new testnet, Developer Testnet 4, will be held on Saturday, March 28th, at 8am CDT, to verify our recent work. We invite anyone and everyone to participate via our Discord. Simply ask for the “Developer Testnet Node” role and we’ll help you compile and run your own Meros node. As always. we’re excited for the future, and will make sure to keep you updated.