We ramble about code, technology and life. Sometimes we actually code...


How do we scale Bitcoin

by Kyluke McDougall on 23 February 20178 min read

Over the last 2 to 3 years Bitcoin has been facing the same question that any other network faces at some point, "How do we scale this?"

Bitcoin

Bitcoin is a peer to peer payments network, comparable only to cash or gold. While it differs in many ways from cash or gold, they remain the closest comparison. The heart of the network is made up of the Blockchain. An immutable, transparent, distributed and open to innovation ledger, that keeps a record of all transactions, that have occurred on the network. This ledger is kept up to date using a consensus mechanism called proof of work; which validates all new transactions made on the network, as well as inadvertently confirming every existing transaction over and over again.

The people who partake in this consensus mechanism are called miners. Miners dedicate hardware which they have purchased, as well as electricity, to validate transactions made on the Bitcoin network. They group transactions into chunks (from the mempool, where new transactions are submitted to) and validate whether or not they are legitimate transactions. This is done based on an algorithm agreed upon by the entire world. Once they have validated the transactions, they solve a puzzle to prove that they did the work (proof of work) and submit these chunks to the Blockchain.

These chunks are called blocks. Each block, is currently 1MiB in size. The average transaction can range between 226 bytes and 1kb in size. Which usually translates to around 1500 -> 2500 transactions being mined in each block. Each block takes about 10 minutes to "find" (to validate transactions and to solve the puzzle). This is what is called Bitcoin's heartbeat. It beats every 10 minutes at a rate of 7 transactions per second (compared to VISA which handles on average around 2,000 transactions per second).

Scaling

The 1MiB limit was imposed by Bitcoin's creator Satoshi Nakamoto, about 1.5 years after it's launch, from 32MiB to 1MiB. Based on interpretations of his comments relating to it, this change in code was to keep bandwidth and network requirements low enough, to be practical for anyone to keep a copy of the Blockchain on their computer. The idea was to increase the block size at a later stage. However, he never commented on when or how this size increase would roll out. The idea was that by the time this question needed to be answered, we would've advanced far enough, in accordance with Moore's law, that a block size increase would essentially keep the cost of running a node to about the same as it was back then.

We've come to this point. Blocks are constantly reaching their 1MiB limit and have been for more than a year, we have a serious back log of transactions in the mempool every couple of days (think on average 60k transactions waiting to get confirmed) and have split the community into two camps. Each with their own idea on how to scale the Bitcoin network.

Segwit

On the one hand we have a Bitcoin improvement protocol called Segregated Witness or SegWit (segwit). Segwit's purpose isn't directly related to a block size increase but its improvements allow for a theoretical 0.7MiB increase in block size. To understand how this works, we need to look at how Bitcoin transactions work.

On a very simplistic basis, a Bitcoin transaction consists of inputs and outputs. Inputs contain transactions that you reference to prove how you got the Bitcoins that you are about to spend and outputs contain the destinations and amounts, where you would like to send these Bitcoin. The inputs are then signed by your private key which proves ownership of those Bitcoin and the the entire transaction (signed input and outputs combined) is submitted to the Blockchain. Each transaction in a block contains its own set of signatures and this contributes to the size of a transaction.

Segwit allows a miner to take the transaction signatures and split them from the transactions portion of the block. One of the problems that segwit is trying to fix is a more complex one called transaction malleability. Essentially, in some edge cases, transaction ID's can be changed during the mining process. Which means if you were monitoring a specific transaction ID to see if it has been confirmed or not, you'd never know. Once it is mined, the ID is "accidentally" changed. Causing a lot of confusion. Segwit solves this problem by splitting signatures from the transactions which prevents this change in ID from being possible. Which also provides the 0.7MiB block size increase.

The benefits of Segwit include:

  • Fixing transaction malleability (which enable things like the lightening network)
  • Increases the block size from 1MiB to ~1.7MiB
  • Provides security gains for hardware wallets
  • Improves Pay to Script Hash security
  • Linear scaling of sighash operations (prevents maliciously designed transactions from clogging up the network)
  • Reducing UTXO growth
  • Efficiency gains when not verifying signatures

For a more in-depth look at each of these points above, visit Segregated Witness Benefits.

Bitcoin Unlimited

On the other side of the coin, we have the so called "Big Blockers". Who firmly believe that in order to scale Bitcoin as a network, we must increase the block size. This would mean that more transactions can be mined at once. For instance, if the current "heartbeat" of Bitcoin produces 7 transactions per second with a 1MiB block size, increasing the block size to 2MiB would directly increase the transactions per second processed to 14. The debate between the "Big Blockers" is still open as to how big this increase should be, some want 2MiB, others 8MiB. Out of this dilemma, Bitcoin Unlimited was born. Bitcoin Unlimited tries to solve the block size issue by allowing users to define their own consensus on what block sizes to accept.

Problems with this solution include the increased cost of keeping a Bitcoin Node running. Meaning the number of Nodes would drop and the risk of centralisation increases. Other problems, related more specifically to Bitcoin Unlimited, stem from the ability for users to dictate their own accepted block sizes. Causing the network to be in constant flux over what is the true Blockchain and what is discarded as a side-chain. This can cause confusion as transactions which may have been mined on a side chain, will all of a sudden lose confirmations and end up in the mempool again (ending up in the mempool is the best case scenario, worst case, the transaction just disappears and the sender has their money back); due to the side chain being discarded.

Support

Bitcoin works on a consensus protocol. Every decision made in Bitcoin needs the buy in from the entire network. If a new feature is to be implemented, which changed the way Bitcoin functions, a voting mechanism is kicked into play. Anybody accepting this new feature, and would like to include it into their implementation of Bitcoin, casts their vote by "signaling" their support for this feature.

This is done by installing and running the version of Bitcoin which implements it. If more than 75% of the network is in agreement and votes toward a new feature, it becomes part of the Bitcoin consensus and the network moves in that direction as a whole. The other 25% have the choice to either take it or leave it. In a situation where the change is a so called "Soft Fork", the 25% will not be excluded from the network but will not reap the benefits of the new feature. If the implementation is rolled out as a "Hard Fork", the 25% are "forced" to switch otherwise they will end up on a side-chain. A version of Bitcoin which is not accepted by the new direction of the Blockchain and therefore has no buying power.

Everyone on the new main Blockchain will not see any transactions on the side-chain and vice-versa. They cut themselves off.

If we take a look at the current state of the Bitcoin Mining network, we see the following stats (these are sourced from Coin Dance):

  • SegWit: 25.7% have signaled their support
  • Bitcoin Unlimited: 19.9% have signaled their support
  • 8MiB Block Size Increase: 6.2% have signaled their support

It seems that after 2, going on to 3, years of this debate, we have not found a scaling solution that is accepted by everyone. Unfortunately, politics has had an influence in the decision making of many and each side has valid points. Regardless in which camp you sit, a scaling solution needs to be implemented. Sooner rather than later. We may only have a year or so left before the first contentious hard forks become a reality.