The bugs that almost killed Bitcoin

Bitcoin was the first cryptocurrency, being introduced to the world by the anonymous developer or group of developers that go by the name Satoshi Nakamoto.

BTC has had a long history of ups and downs, some of which were quite good for the community as it allowed folk to further accumulate additional Bitcoin. Others, however, almost destroyed the original crypto.

Today I aim at looking at some of the toughest bugs Bitcoin developers had to deal with, why did they happen, what went wrong and how they were mitigated.

I will do my best to keep things simple and not technical.

Ready to hear some of the most disturbing stories surrounding Bitcoin?

Emperor evil laugh

How bugs happen

Software is created through scripts. In Bitcoin, the original version was programmed in a low-assembly language called ‘c++’.

Even though developers, especially in the open-source world, make tons of runs at the code, some bugs tend to happen. This may be due to changes that make some functions incompatible with the new code, due to errors in the new code or even due to functions that do stuff they shouldn’t.

Whatever the reason may be, you must realise that Bitcoin, being open-source software, is also prone to some bugs and errors. Even though most issues are easily fixed (BTC is lucky enough to have top-notch devs looking at it), sometimes bugs that arise may cause unforeseeable problems.

Below I will look into the top three bugs and errors that almost led to Bitcoin’s demise.

Bug 1: OP_LSHIFT crash

One of the original instructions that you could run in the scripting language was OP_LSHIFT which would shift a number a certain set of places to the left. It was discovered that when using OP_LSHIFT on some machines, processing the transaction would cause the machine to crash.

The way that this bug works is that you would simply make an evil transaction and send it to a bitcoin node, effectively causing the node to crash.

The way developers fixed the bug was to invalidate certain functions, making the script return ‘false’ – essentially not running the program (the transaction).

Bug 2: Inflation error

Inflation bugs allow you to print more money. It’s almost like you are able to become a central bank within the Bitcoin protocol.

The code that originated the problem was about adding up all the outputs and all the inputs in the transaction. You subtract all the inputs from the outputs, and if you got a negative number then that meant your outputs were greater than your inputs.

Basically an inflation bug is caused by an overflow, as in when the absolute value of the number is too high for the computer to represent it.

So this allowed the user to print money, and this bug was exploited on main net. Billions of BTC were produced.

To solve the issue the code was patched and every miner switched to a new fork, using the last block before the exploit. In essence, there was a hard-fork of the Bitcoin code.

Bug 3: Netsplit

The netsplit bug exploits the fact that you can have two alternative blocks with different transactions in it, that hash to the same value.

This doesn’t mean the hash value is broken. It means that there are two blocks, with different transactions that collide, which have the same hash.

This bug has an easy fix. Miners simply need to eventually reject one of the blocks, making those transactions invalid.

Collisions may happen, and are known to happen, to a certain extent. One of the worst times there were two valid blockchains for around eight blocks. Meaning some miners were mining one chain, while others were mining a different chain.

These splits may happen but eventually get resolved, as one of the chains will get more work done and replace the other.

Artículos relacionados