Bootstrapping Blockchain

Blockchain is a design pattern for a peer to peer (P2P) distributed database that possesses a number of key characteristics that make it desirable to many people across a variety of industries and disciplines.

Originally exploited by the cryptocurrency Bitcoin, to allow trusted finicial transactions to occurr between untrusted parties in a P2P fashion. Bitcoin provides an alternative to financial intermediaries, whom usually validate or underwrite transactions for a fee and at a fairly slow pace. Instead the cryptocurrency empowers the users to make payments of any size, including micro-transactions, to anybody else in the network, no matter geography, for free, anonymously and almost instantaneously. It's not hard to see why this currency proved so popular with the online black market Silk Road.

A Blockchain is fundamentally just a linked list, where each node is a referred to as a block. The blocks store amongst other things, a transaction list, a signature and a reference back to the previous block. In Blockchain, the linked list is immutable, distributed and open to everybody in the network. It also relies heavily on cryptography to validate its own integrity and for anonymity.

Immutable

Once transactions have been added to a block, and a block accepted into the Blockchain, it should be considered immutable (cannot be edited or deleted). However, finalizing a block can take an indeterminate amount of time and may be overwritten due to parallel forks, this is something to consider and is implementation specific. I will explain how and why this is later.

Distributed

Each client in the network, disregarding lite clients, will have a full copy of the Blockchain transaction log. Therefore, there is no single point of failure or attack. Clients can simply go offline, come back on at a later time and re-synchronise with the network from peers.

Open

As well as everybody in the network having a copy of the transaction log, they can inspect the log to see individual transactions. There are various forms of openness within different Blockchains, some give certain clients read-only access, some give everyone write access, etc. However, the pattern really advocates openness to allow people to see all transactions so they can trust the network and its vendors. A few different types of Blockchain are as follows:

  • Public - everyone write/read
  • Public Consortium - members write/read, everyone read only
  • Private Consortium - members write/read

Cryptography

Cryptography is baked throughout any Blockchain technology. It is used to identify users, validate transactions, represent off-chain assets and secure the network through something called proof, which I'll explain later.

Transactions

Transactions are simply a piece of data that represents the sender transferring a token (could be money) to a recipient. Bitcoin uses transactions to simulate financial transactions i.e. the transfer of value. For instance a pseudo transaction might be:

{
    to: 'Client B',
    from: 'Client A',
    value: '10',
    reference: 'IOU',
    signature: 'b63648f12c08b868d5e086b7d'
}

In Bitcoin, rather than storing a balance against each account, you store a list of 'unspent transactions', which are basically transactions where other entities have sent you money and you have yet to spend it (think of them as vouchers). When you come to make a transaction to another entity in the network, you simply reference any unspent transactions you wish to spend as inputs to the transaction along with a recipient and some other metadata. This transaction then propagates out to the network via the P2P communication protocol. The transaction will then sit in the 'unconfirmed transaction' list for the rest of the network to see. When a client comes to confirm the transaction, it will grab it from the unconfirmed transaction list and run a series of checks, including; validating the source signature, verifying inputs (unspent transactions) and any other conditions the sender has defined. Once validated, the validating client (known as a miner) will embed the transaction in their block along with some other transactions ready to submit to the global Blockchain.

Q. So what stops other miners picking up that transaction, confirming it, embedding it and submitting their block at the same time or before this one?

A. Nothing, once a client has submitted their block to the Blockchain, it will propagate out to all the other nodes, part of the protocol means that clients automatically begin mining the next block on the longest chain. Therefore, if they see another chain with more blocks mined, they will simply forget their current transaction log and adopt that of the longer chain. This means that for every block mined there will be potentially numerous parallel forks as different clients simultaneously attempt to submit a block, but at some point one of the forks will become longer than the others and it will all collapse to that single source of truth.

Q. Ok... so what happens if I want to buy a car from 'Client X'. I send her a transaction worth £10,000, she sees the transaction has been accepted into the Blockchain and sends me the car, then I reverse that transaction and make a longer chain so that everybody synchronises on my transaction log and it looks like the payment never happened?

A. This is a classic problem with digital currencies known as the double spend problem. In other words, how can you ensure that digital money is only spent once when it is backed by a virtual asset which can be copied and shared. This is usually solved by the trusted intermediaries who agree on what money you have and thus what you can spend. In the world of Blockchain we use something called a proof to prevent this.

Proof

Proof is a safeguard against a number of potential attacks, such as DDOS. It requires a client to invest something of value into the network in order to validate transactions. The cost of their investment should disincentives the client from attempting to attack the network. Proof comes in many different flavours, including; Proof of Work, Proof of Stake and Proof of Burn. The implementation details of each are vast and varied so I won't go into too much detail about each in this blog post. However, I will talk briefly about Proof of Work which is currently the most popular and successful proof method - even if it is the most wasteful and inefficient. With Proof of Work, once a miner has validated 'n' transactions and added them to their block, they must then solve a difficult computational problem in order for their block to be accepted into the Blockchain. This computational problem can only be solved via brute force and therefore can not be shortcut. The problem is engineered to a certain difficulty depending on the amount of computational power in the network - for instance Bitcoin's problems takes on average 10 minutes to solve. In this sense you can image this problem as a Sudoku, they are difficult to complete, easy to verify given a set of rules and the difficulty can easily be adjusted by adding or removing additional rows and columns.

Q. Why would miners waste electricity solving computational problems to verify other peoples transactions?!

A. Each miner who successfully mines a block and adds it to the Blockchain is rewarded for doing so with some currency i.e. Bitcoins, Ether, etc. An additional incentive is that the amount the miner receives in reward depreciates at certain Blockchain heights (the number of blocks in the Blockchain). In fact with Bitcoin the total amount of currency that will ever exist is capped, meaning miners will eventually only be incentivise to mine transactions based on additional transaction fees the transaction sender has attached.

Q. Sweet, so can I start mining and make money now?

A. Yes, although the probability of you mining a block and getting it added to the Blockchain is proportional to your investment in the network. In the case of Bitcoin, many organisations and individuals have invested heavily in ASICs and pooled resources to increase the probability they will win. Therefore, if you are simply mining on your laptop you will spend more on electricity than you will get in return for mining. This trend has created an imbalance in the Bitcoin currency that makes mining inaccessible to most. It has also increased the likelihood of a 51% attack (i.e. 1 pool owns more than 50% of the computational power and therefore can influence the network). Consequently, certain pools have had to throttle their users to ensure trust in the network as this would reduce the price of Bitcoin and therefore their ROI.

Q. Ok, what if I want to sell my cryptocurrency?

A. There are a large selection of Exchanges that can be used to buy and sell cryptocurrencies at the market rate.

Blockchain n.0

Bitcoin was an implementation of what is now referred to as a Blockchain 1.0, the transfer of value via open and distributed transactions. Since then, people have been trying to extend the Blockchain concept to include both data and executable code. Although Bitcoin has a limited scripting language, people such as Vitalik Buterin at Ethereum, are trying to build a turing complete platform underpinned by Blockchain technology. Extending this further is notion of Blockchain 3.0, which includes integration with external data and services. Microsoft are busy researching this particular idea to see how we can blend Blockchain into our existing suite of Enterprise tools. For more details on the work we're doing here please refer to this article.

Applications

Blockchain is a truly disruptive technology that could reshape markets and nullify entire business models. These implications make Blockchain as much a political decision as a technological one.
The potential applications for something as fundamental as an open distributed database are vast, however, Blockchain isn't necessarily a suitable option for most for a few reasons:

  • Low throughput
  • Slow transaction rate
  • Nondeterministic transaction time
  • Lack of reporting
  • Lack of analytics
  • Requires shared ownership (P2P)

Most of the successful Blockchain solutions I've seen so far are really only using the Blockchain as an open, immutable audit trail to make their operations more transparent and trustworthy. If we manage to stabilise and secure technology such as Ethereum and develop technology to integrate with external services, then this will open up many more opportunities for exploiting Blockchain in traditional workloads - for now however, I believe it is only really applicable to a few highly specialised workloads.

Summary

The future of Blockchain is really dependent on being able to iron out some of the security loop holes and bugs that are continuously been exposed, move away from Proof of Work to something more sustainable and to reduce the volatility of the currencies to make it a longer term investment option.

I will be posting a follow up blog that will explain how to get started developing Smart Contracts for a private Ethereum Blockchain hosted on Microsoft Azure.