Concensus

At its core the blockchain is about several actors reaching concensus on what a valid block is. Each blockchain must choose its way of deciding exactly how that concensus is reached, and who can contribute to the search.

One of the better statements about the blockchain — and the Bitcoin blockchain in particular — that I have seen, and I wish I remembered when I read it, was something like this:

People think that the blockchain is all about solving incredibly difficult and complex equations, but the reality is that it’s like millions of computer shouting numbers across the internet until most of them reply “I agree”.

This sums up what happens with the concensus algorithm known as “proof-of-work” or POW. This is how the Bitcoin blockchain operates, and why you may read articles warning that it’s a huge waste of energy. With Bitcoin every miner is trying to come up with a single solution in the quickest time possible. If there are a million miners (an admittedly high estimate) then one may say that 999999 of these miners are wasting energy because only one will be the first to reach the correct answer. 

Of course that’s an absurd oversimplification. All the other miners on the network are also verifying the one correct solution that has been found, and are an essential part of the process. The more miners are online, the quicker the solution can be verified, accepted as correct by 50% + 1 of the miners, and appended to the chain. And the more miners there are the more remote the possibility that a brute force attack (the 51% attack) can even be attempted, let alone succeed.

A What Attack?

The 51% attack is the most elementary attack on a proof-of-work (POW)  blockchain network. If the concensus is 50%+1, then you can simply throw more miners on the network until you control 50%+1 of the global hashrate, and then you could rig the whole operation to enrich yourself by cheating, double-spending tokens, or making the network useless. 

With today’s cloud infrastructure it’s easier than ever to create hundreds or thousands of virtual machines in a very short amount of time, so this is not just a theoretical threat. It’s the most common mode of attack on smaller POW blockchains.

When it comes to these attacks, greater network size provides more protection. There’s very little risk of someone coming along and suddenly generating more hashrate than the rest of the bitcoin network. That hashrate, FYI, is currently hovering around the 50 million terahash per second. A terahash is one trillion of hashes per second, or (if my math isn’t completely off) roughly 5 quintillion hashes per second.

That being said, POW is a first-generation blockchain concensus strategy.  Newer blockchains can use a number of different strategies to establish concensus.

Cryptocurrency as a Reward for Mining

At the core of the idea of cryptocurrency is the idea of reward for work. 

For example, miners in Bitcoin all try to solve the same problem at once because whatever miner discovers the solution first wins a block reward. That reward is a number of Bitcoins. Initially 50 BTC were awarded, then it became 25 BTC, and now that number has been halved again to 12.5 BTC.  That is a substantial reward, even at this time. All the other miners get nothing. 

Proof-of-Stake

A proof-of-stake strategy operates with different assumptions. Instead of miners, the network is run by people who have previously invested in the network by acquiring its cryptocurrency. The idea there is that you need to have “skin in the game” to share in the rewards. For the blockchains that implement this, there is no block reward. Instead, fees are paid on the transactions on the network which is then distributed to the nodes that have registered a stake. To register a stake it must be placed in some kind of escrow.

With the POS strategy nodes that have a stake collect, package and encrypt transaction data and push it to the blockchain. Any actor’s participation is equal to the actor’s stake divided by the total number of staked tokens.

Delegated Proof-of-Stake

The delegated POS strategy takes that concept to the next level. In this system the stake-holders (stake-hodlers?) elect a certain number of their own to be witnesses. This is typically a low, odd number to avoid possible deadlock. 21 is generally considered to be a good number of witness nodes. 

Witness nodes are the only nodes that perform work (bundling and encrypting transactions) under this arrangement. Instead of earning a reward, witnesses are paid to ensure that their nodes perform the work.

These are the “big three” strategies at this time. There are other, less currently popular but not necessarily less valid strategies, like mandating that any one node on the network can only do work at certain time intervals, or where a number of nodes are chosen by lottery to perform work, and many more. The implementation details of each strategy can be wildly different.

The uptake on this is that while cryptocurrency saw the day thanks to proof-of-work blockchains, today the landscape offers many other possibilities which can be much more efficient than Bitcoin (which remains the gold standard). Less actors needed for concensus means less energy spent reaching that concensus, and also a much lower level of latency which allows for greater transaction throughput. 

To bring Bitcoin up again here, few people know that it’s a fairly slow network that has a typical ability to process maybe 5 transactions per second. Compare this to the Visa payment network, which can handle over 24000 transactions per second, and it becomes clear that if crypto is ever to see wide adoption as a means of transaction competing with Visa and other payment networks it needs to be a lot quicker.

And that’s today’s lesson.

What is a blockchain?

2018 is poised to be year when cryptocurrencies become mainstream. The original cryptocurrency, Bitcoin, has entered the common jargon of the modern world last year as its valuation hit record a record high of nearly 20k USD/BTC, and stayed in the news as its valuation dropped to more reasonable levels. Ethereum is also gaining recognition as it became the #2 cryptocurrency in terms of market capitalization. In short, a little over 8 years since the creation of Bitcoin cryptocurrencies are gaining recognition and acceptance in the “real” world.

Cryptocurrencies are created as part of something called a blockchain. And more than cryptocurrencies, it is the blockchain idea which is expected to have a huge impact on the computing world, at least for the next couple of years. As such it is a good idea to learn what a blockchain is, at both a basic and more advanced level.

The Basics

At its core, a blockchain is a distributed ledger. Those with an accounting background will immediately recognize what a ledger is — it is a record of transactions. A blockchain is distributed, which means that entries in the ledger are written by many parties, as opposed to by one centralized authority.

Like an ordinary paper ledger, blockchains are write-once. Once a block has been verified and added to the blockchain it cannot be erased or modified. This insures that transactions cannot be taken back.

The Nodes

All these “parties” are actually computers running a node for the blockchain’s network on the internet. This involves executing software which contributes to the blockchain network. Depending on the network involved there may be several types of nodes in a blockchain; this will be explored in depth later.

The Blocks

Nodes compile a number of transactions into a block. How large the blocks are, and how often they are verified, varies widely between blockchains. For example, the Bitcoin blockchain generates a block every 10 minutes. The Ethereum blockchain, in comparison, generates a block in less than 20 seconds, and Bitshares blocks are generated every 3 seconds at most. A number of factors affect block time; if you’re not intimidated by math check out this article for more information.

The Chain

Blockchains are so named because each new block is appended to the previous block, effectively forming a chain. In fact one can always look at certain information in the latest block of any given blockchain and trace the blockchain’s history all the way back to its very first block.

Hashing

Since blocks are appended to the blockchain by several different nodes, there needs to be a way to ensure that only the block with the right data can be added at any given time. Otherwise there would be no way of ensuring the continuity of the blockchain from the genesis block to the most current one.

This is where hashing comes in. Hashing is a cryptographical technique that is used to generate a unique code that can be used to identify a set of data, rather like a fingerprint. The hash is generated from the transactions contained in the block and recorded as data in the block, which also includes the hash from the previous block. This is one of the mechanisms used to verify any new blocks. If the previous-block hash does not match the previous block’s recorded hash, then the current block is invalid and cannot be added to the chain.

The actual library used to generate the hashes depends on the blockchain. SHA256 is a popular one and is used by Bitcoin. Other libraries include scrypt, X11, Cryptonight and ETHash.

Hashing produces a completely different string if there is any change whatsoever to the original hashed content. The SHA256 library can produce a very large number of distinct values (3.4028237e+38) so arriving at the same value from two different pieces of content is extremely unlikely. By comparison, the chances of winning the Powerball lottery in the USA is 1 in 2.92e8. One could win this lottery 4 times and that would still be less likely than generating the same hash from 2 different sources. Thus the use of hash values makes blockchains virtually tamper-proof.

This was a very basic overview of blockchains. We’ve barely scratched the surface. In my next few articles I will be providing more in-depth coverage on subjects such as concensus algorithms, blockchain node types, the relationship between blockchains and cryptocurrencies, and how the blockchain can be used by businesses to streamline processes and reduce processing costs.