Stipend Blockchain, Multiple Exploits and Optimizations

NickS

These last few weeks in particular have been very important for Stipend, primarily as they explicitly tested the stability of the blockchain throughout and helped us to stamp out a few dangerous exploits that would have caused problems in the long run.

I personally had my hands full with this. In the last few weeks, I worked on completely re-coding MN payments. Before, it primarily was based on a scoring system that each wallet calculated. This allowed for a few individuals to tamper with their wallets and decide which MN to pay when finding a block. The new system is a straight queue, and pays out to the MN that hasn’t received a block in the longest period of time. This helps for each individual wallet to independently verify the MN reward payee, and reject blocks that try to modify this.

When implementing this model, though, the handling of newly created MNs within the queue presented some difficulty. You’d think it’d be as simple as just putting them at the end, but in order to ensure that the queue is the same across every wallet, we had to code it so that the chain looks through the last ~4000 blocks and specifically marks every instance of a MN receiving a reward. Newer MNs in particular have never received a reward within these blocks, and as a result, it places them at the front of the queue. That’s why you may have seen some examples where an individual creates a MN, gets a reward, destroys their MN, and then recreates it. In order to fix this, we contemplated quite a few solutions and decided to simply increase the number of confirmations the MN collateral must have (600) before it’s allowed to create a MN.

Overall, though, these last few weeks will only make Stipend stronger as a whole. Now that each individual exploit has been identified and patched, the chain will be much more stable in the coming months and years. Next week, I’ll continue to work more with the wallets and blockchain. I can’t foresee another mandatory update for quite a while though–I’ll just be adding more features to improve the technology even further.