Structure of Blockchain
Last updated
Last updated
Blockchain can be structured using a number of blocks in which nodes authenticate the transactions that need to be stored in the block.
The block header contains various fields such as hash from the previous block, Timestamp, Version no., Nonce, and Merkle root. Blockchain Technology can be defined using three crucial concepts, which are blocks, nodes, and miners.
Miners are basically participants in the blockchain network whose main task is to verify the new arriving transactions, and they get the reward to validate the transaction that needs to be added to the blockchain. Miners solve a complex cryptographic puzzle to mine the new transactions in blocks that can be further appended to the blockchain, So, these fields of the block header can be defined as follows:
Previous block hash function: It contains 32 bytes of block header. This field contains the hash of the previous block, which can be computed using the block header of the previous block using the cryptographic hash function. Double SHA- 256 cryptographic algorithm is used for generating hash value.
Timestamp: It contains 4 bytes of block header. It indicates the time for the creation of the block, more accurately the time when the miner started hashing the header.
Version no.: It contains 4 bytes of block header. Version no. denotes the version a particular block is utilizing. Blocks are linked with each other using different blockchain versions such as Blockchain version 1.0 for storing the cryptocurrencies, Blockchain version 2.0 is used to execute smart contracts, i.e., Ethereum, Blockchain version 3.0 for a decentralized entity, and Blockchain version 4.0 to enable a scalable and transparent network for industrial purpose
Nonce: It also contains 4 bytes of block header. It is basically defined as a number used only once. Nonce is a random number that miners are computing to validate the transactions. So miners have to randomly find the number, i.e., an integer between 0 and 232 as 4 bytes of nonce can have a maximum of 32 bits
Merkle root: Merkle tree built using hash values of various transactions. Hash values of all the transactions are combined to generate a Merkle root, which can be called as the root of the Merkle tree. Merkle root reduces the computation time while verifying the transactions as even a slight change in the transaction can be reflected in the Merkle root, which reduces the effort of verifying all the transactions in the blockchain.
As discussed earlier, blockchain can be classified using blocks, nodes, and miners. These terms interrelate with each other to validate the transactions in the blockchain network.
Validation: validators are responsible for verifying transactions and adding new blocks to the blockchain. They ensure the integrity and accuracy of the network by validating data and reaching consensus. In Proof of Stake (PoS) systems, validators are chosen based on the amount of cryptocurrency they stake, and they are rewarded for correctly validating blocks. Validators play a crucial role in maintaining the security, decentralization, and efficiency of blockchain networks by preventing fraudulent activities.
Address: an address is a unique identifier used to receive and send cryptocurrency or tokens. It’s similar to a bank account number in traditional finance, but instead of storing the tokens directly, an address represents a specific location on the blockchain where the assets are associated. It is derived from a public key and ensures the secure transfer of digital assets.
Index: an index refers to a data structure or mechanism used to optimize the retrieval and querying of blockchain data. It helps in efficiently accessing and organizing large volumes of transaction data, blocks, or addresses stored on the blockchain.
Blocks in the blockchain network can be classified as follows:
The initial block of any blockchain network is known as the genesis block or Block 0. In 2009, an unidentified person named Satoshi Nakamoto created the Genesis Block, i.e., the first block of the blockchain, while launching the bitcoin. Genesis block initiates the blocks, which further connect to a number of blocks extending the number of transactions in the blockchain network. The Merkle root in the Merkle tree of block header ensures that all the transactions associated with their hashes remain validated throughout the network as any modification in the transaction reflects in the Merkle root, which further notifies the blockchain about the manipulation of transactions in the blockchain to ensure the security in the network.
Valid blocks are already mined blocks by the miners added to the blocks in the blockchain. It means blocks have been appended to the blockchain by solving complex mathematical cryptographic hash algorithms. Valid blocks are added to the network by satisfying the criteria of the consensus mechanism, further improving the security of the network.
The consensus mechanism verifies the blocks whether they can be appended to the blockchain or not. According to the consensus, if all the nodes in the network agree to the addition of a new block, then they are the valid blocks, but the rest of the blocks are orphan blocks. There can also be a scenario where a number of miners in the network are competing to get the reward for mining the valid blocks simultaneously, or there can be the involvement of any malicious attacker to add the invalid block. Still, the blockchain only accepts the valid block or the longest chain of blocks, making it secure and scalable for the network, and invalid blocks can be declared as orphan blocks.
In blockchain networks, different types of blocks serve specific roles in maintaining the integrity and security of the system. The Genesis Block marks the starting point of the blockchain, forming the foundation for all subsequent blocks. By leveraging cryptographic hashes and structures like the Merkle root, it ensures that any tampering with transaction data is detected, preserving the chain's validity. Valid blocks, appended through consensus and cryptographic proof, form the continuous, secure chain that powers the blockchain. However, orphan blocks, which do not meet the criteria of consensus, are excluded from the main blockchain. This system of block validation and exclusion helps maintain the security, immutability, and scalability of blockchain networks, ensuring that only legitimate blocks are added while invalid or competing blocks are disregarded.
All the computers expanded across the blockchain network are known as nodes.
Every time a request to add a new transaction is issued, it must be approved by all the participating nodes by checking the validity of the transaction. Once all nodes validate the transaction, voting is done to check every node’s decision about the transaction, as it may be valid or fraudulent.
Each node has a copy of the digital ledger; if the majority of the nodes say that it is a valid transaction, then it is added to the blockchain network; otherwise, it is rejected.
There are mainly two types of nodes Full nodes and Lightweight nodes. Full nodes can be further classified into Pruned nodes and Archival nodes.
Full nodes play an essential role in maintaining the transactions of the blockchain. It keeps track of all the transaction records, and if there is a new transaction or any modification to the blockchain, then full nodes should agree to the modifications to reflect the changes in the blockchain. But, there can be a scenario that even if the majority of the full nodes agree to any new transactions in the blockchain, then due to some conflicting nodes whole blockchain may not work according to the proposed changes. In this case, the blockchain will be split into two blockchains in which a modified blockchain can work according to the agreement of full nodes and another blockchain, i.e., due to disagreement of conflicting nodes can work in the same old manner only. Full nodes can be further classified into pruned nodes and archival nodes, which can be described as follows:
Pruned Nodes- Pruned nodes are full nodes which have limited memory storage to maintain the transactions in blocks. Although, there is no limit to add blocks to the blockchain satisfying the consensus mechanism, these nodes can’t hold the blocks exceeding the limit of their storage.
Archival Nodes- Archived nodes work in a similar way as full nodes that contain all the transaction records which should satisfy the criteria of the consensus mechanism. But, there is a difference that archived nodes also contain the oldest blocks, i.e., all the previous blocks of the blockchain, but these blocks are not considered in the case of pruned nodes. Therefore, archival nodes utilize more space of blockchain than pruned nodes.
Master Nodes- Master nodes can be defined as the type of archival full nodes that do not have any authority to append data blocks to the blockchain. The main task of these nodes is to validate the transactions and keep track of these transaction records.
Mining Nodes- As discussed earlier, the miners in the blockchain compete to mine or validate the transactions by solving the mathematical cryptographic puzzle fulfilling the consensus mechanism for security purposes. So, the nodes required to compute this complex puzzle by mining the blocks of valid transac- tions are known as mining nodes.
Staking Nodes-Similar to mining nodes, staking nodes mainly focus to satisfy the consensus mechanism in which all participating nodes should agree to the same decision for adding the new transaction to the blockchain. For staking nodes, a consensus mechanism, i.e., Proof-of-Stake is used so that authentic transactions can be appended to the blockchain, which will be discussed in further chapters.
Authority Nodes- In the open decentralized block chain network, any users can access the network to add their transactions, but there can be some malicious or faulty nodes trying to access the network that can be a threat to the security of the network. Due to these security issues, authority nodes are required to authenticate only validated transactions for the blockchain network.
Lightweight Nodes: Lightweight nodes accept data blocks of requisite and essential information, i.e., they only keep track of block headers of blockchain. So, if there is a request to access the block that is not considered by the lightweight nodes for faster transactions, then data can only be retrieved by considering the whole blockchain. Lightweight nodes facilitate faster transactions without considering the complete node, making it less flexible and reliable.