arrow left
Back to Developer Education

Introduction to Blockchain Architecture

Introduction to Blockchain Architecture

As a financial market analyst, I recently ventured into the cryptocurrency asset class. I was astonished by the price delivery mechanism of cryptocurrencies and the huge number of assets. These assets are commonly referred to as tokens in the cryptocurrency market. <!--more--> During the early adoption phase of cryptocurrency assets, the theme behind its price delivery mechanism was "an extremely volatile asset." But, with institutions stepping into the marketplace, there has been a moderate fluctuation in its price delivery with lesser instances of extreme volatility and whipsaws.

Arguably, the cryptocurrency market structure is similar to the stock market. The cryptocurrencies are traded based on the merit seen by traders and investors. Several types of cryptocurrencies exist. They can be used as currencies (security tokens), store of value assets (value tokens), or utility tokens.

However, the financial aspect is intriguing, but what hooked my attention is the structure of blockchain technology. It is astounding and revolutionary. These aren't buzz words. We will get to it, and you will understand how my statements have merit.

Table of contents

What is Blockchain

Before we dive straight into what blockchain is, let’s examine the underlying units that make up a blockchain, this way, the definition makes more sense.

There is usually an origin in the blockchain: the first block in the chain. This block is called the Genesis Block because after the blockchain is initialized, the first block will always stay as number 1 for eternity.

There might be some data in the first (Genesis) block, such as transactions details by cryptocurrency users. It also consists of a Hash, a string of characters derived from the fields in the blockchain but in an encrypted format. The blocks usually contain a previous hash, but the Genesis block doesn’t because it is the first block.

The next block created will have some data in it.

The data includes information such as:

  • The hash
  • The previous hash

The previous hash references the hash of the previous block. If a single character in the previous block's data is altered, this will cause the hash to change completely, and the algorithm won’t update it in the current block. Hence, the relationship between them will break.

The process above proceeds as more blocks are mined. Then they are linked to one another based on the previous hash. In summary, Blockchain is a series of cryptographically linked blocks with each other through these hashes.

Components of Blockchain

The realms of blockchain are simply the characteristics or features that make blockchain what it is today. These characteristics are the founding pillars of blockchain technology, and they are:

  • Immutable Ledger
  • Distributed P2P Network
  • Hash Cryptography
  • Mining and Proof of Work
  • Consensus Protocols

In this article, I will only briefly touch on them.

Immutable ledger

To understand the concept of the immutable ledger, I’ll add some visuals below:

Blockchain Visual Representation

A ledger or block must be immutable. It must not be subject to change. In reality, when we add entries to a ledger, it can be altered, which is a fraudulent act. One of the core pillars of a blockchain is to ensure that data in the block is not subject to change, and here is how it guarantees that.

When a block is mined and added to the blockchain, a hash for the block is generated from combining the data in the block. In the image above, the first block is the genesis block, and it has no previous hash by default due to the absence of a preceding block. Instead, it has its hash, which is generated by combining its data and identifiers, along with a nonce calculated and agreed upon.

The next block has a similar data field to the genesis block, except the previous hash won't be empty. So instead, it takes the current hash of the previous block and assigns the value to the previous hash variable in the current block.

The current and previous blocks are linked based on the current hash and the previous hash field in the block. Note that if the previous block current hash changes, the current block previous hash data field will not change, resulting in an error in the blockchain.

The hashes ensure the concept of immutability in block data.

Distributed P2P network

Here is an image view of what a distributed peer-to-peer network looks like:

A Distributed Network - Image Credit(Wikipedia)

A distributed network consists of computers commonly referred to as nodes in the blockchain world, and they are interconnected, but they are not all connected simultaneously.

When a block is mined in a blockchain, copies are made available across all interconnected computers on the network. Still, the data are all encrypted through cryptographic keys.

In a distributed P2P network, once a new block is added to the blockchain, the block is added to all computers across the network but not simultaneously. As a result, some computers on the network will receive a block update faster than others, resulting in a problem, but we will get to this under consensus protocol.

The immutable ledger and the distributed P2P network is a vital component of the blockchain. When a block is mined successfully, it is added to the nodes on the network.

The concept of immutability holds firm due to the existence of distributed P2P. This is because the hash and the link between the current and previous block changes whenever a block or the data within the block changes.

A corruption of the blockchain could occur on just one node or multiple on the network.

However, on a distributed network, each node has a copy of the blockchain. Therefore, if a node is corrupt, the network will scan through the other nodes in the distributed P2P system to find a node with the correct state of the blockchain and copies the data to replace the corrupt node rendering the blockchain immutable.

Hash cryptography

In blockchain, there is the need for unique identification of each block, like a fingerprint. The way to ensure such is through an algorithm developed by the National Security Agency (NSA), the Secure Hash Algorithm 256 (SHA256).

Here is a link to test run the SHA256 algorithm. From the web application online, you can generate a hash of whatever text you input.

Here’s what mine looks like:

Hash Example

The text input of hello world produces the hash. If I change a single text or add a single space, this changes the hash completely - you can experiment on this.

In the blockchain, the data in the block + the previous hash and other properties are used to generate the hash for the block, which serves as a unique fingerprint for the block.

Mining and Proof of Work

Mining is a broad topic that deserves its own write-up. In this article, I’ll give an illustration of how mining works.

For a block to be mined and added to the blockchain after being verified, there is usually a target for miners to attain, and this is achieved by changing a field in the block until the block's hash falls below the target of the pool of hashes.

We’ve established that one cannot change the data in the field, so how do we make the hash change until it falls in the target zone? Well, two fields change, and they cause the hash to change. These fields are Timestamp and Nonce.

Now, in the block, we have a new field called the Nonce. The Nonce takes a number that ranges between zero and approximately 4 billion. The miner dedicates their computing power (GPUs, CPUs, and ASICs) to iterate through the Nonce until a Nonce value is found that causes the hash to fall below the target.

Iterating through the Nonce makes it easier for super-fast computers to mine a block. It has to do with iterating between zero and approximately 4 billion to find the perfect Nonce for the hash to fall below the target.

However, mining a block is more complex than just changing a Nonce, and this is because of the Timestamp field in the block.

The timestamp field takes the number of seconds from January 1, 1970, to date, and the field changes every second. This makes it difficult to mine a block because the block's hash changes for every second change in the timestamp.

Thus, miners require computing resources to iterate through the Nonce before a second change in the timestamp. This is because once a second change and the Nonce value is correct, the entire hash changes, and as a result, miners will have to go through the process of changing the Nonce before the timestamp changes to achieve the target.

Once the miner successfully finds the Golden Nonce plus the correlating timestamp (the Nonce value that causes the hash to fall below the target), the miner will go through a verification process that ensures that the miner has dedicated resources to solve the problem (the proof of work). Once the process is verified after running through checks, the block is mined and added to the blockchain.

Consensus protocol

The consensus protocol involves an interrelationship between the distributed network, the blockchain, and mining.

When a block is mined by miner A and also at the same time another block is mined by miner B, these two blocks will be added to the blockchain and then in the distributed network.

Now, remember I said the systems in the network receive the blocks at a different time. So, if there are six (6) systems in the networks, here’s how consensus protocol will work:

Let’s assume four (4) systems receive the block mined by miner A first, and then the remaining two (2) systems on the network receive the block mined by miner B first. This will result in a disagreement across the network because all the blocks must be exact. Therefore this is a problem, and how is it solved?

The network is quite intelligent, it assesses the systems on the network with the highest processing power, and from the illustration, the four (4) systems all received the block mined by miner A.

Thus they have more processing power than the rest of the two (2) systems. Then the consensus protocols will remove the blocks mined by miner B in the two (2) systems and sets them aside. It then adds the blocks mined by miner A.

The consensus protocol results in all the networks receiving the block mined by miner A, while the block mined by miner B will be set aside as an orphan block. What happens to orphan blocks is beyond the scope of this article.

Conclusion

You’ve made it to the end of this article. You now have sufficient knowledge about blockchain technology and how specific characteristics make the blockchain magnificent.

Here’s some additional reading for an in-depth understanding of blockchain technology:

Happy learning!


Peer Review Contributions by: Lalithnarayan C

Published on: Aug 17, 2021
Updated on: Jul 15, 2024
CTA

Start your journey with Cloudzilla

With Cloudzilla, apps freely roam across a global cloud with unbeatable simplicity and cost efficiency