What is Blockchain?
August 7, 2022
What is Blockchain?
Blockchain is a special type of database in which information is stored. But a series of special features distinguish blockchain from other databases. There are a series of rules for adding new data to the blockchain. Also, once data is added to the blockchain and stored, it cannot be edited or deleted. Data in the blockchain network is entered into the database in a structure consisting of “Blocks”. Each block builds on the previous block and contains information that connects it to the previous block. Due to the fact that these blocks are connected to each other by means of information, they form a “Chain” in which the blocks are placed together in order of construction. The first block of the network without another block before it is called “Genesis Block”.
History and benefits of Blockchain
During the past few decades, some technologies have had a great impact on all levels of society and created a revolution in the way people live. For example, the introduction of the mobile phone and to this day new smartphones with amazing capabilities are being unveiled every day and have revolutionized not only the entertainment industry but also the way some groups earn money. Now, however, we are in the middle of another technological revolution called the blockchain network; A distributed network of databases that grows and stabilizes itself every moment. With a brief look at the last decade, we can see that the first major blockchain innovation was the birth of Bitcoin as the first cryptocurrency. Bitcoin’s market cap is currently hover and is used by millions of users daily for various payments. The second blockchain innovation was essentially the realization that the underlying technology of Bitcoin could be separated from cryptocurrency and used to facilitate the achievement of other goals.
The third innovation of this technology was the birth of the “smart contract”, which was introduced in the second generation of the system called Ethereum, and a bright future can be predicted for it. The fourth major innovation in blockchain-based networks was the introduction of Proof-of-Stake instead of Proof-of-Work to establish network security. Currently, most networks use the proof-of-work process to maintain network security, based on which, the group that has the most processing power to produce (mining) blocks makes the final decision and reaches a consensus about transactions and blocks. arrives; But on the other hand, the PoS process allows people to participate in the production and validation of the block transaction according to the number of native coins they own and provide to the network. In other words, by investing in the network, people will get permission to validate and extract and receive more rewards from the network.
How does the structure of blockchain work?
In general, the network consists of several layers, which include the following:
- Infrastructure (hardware, nodes)
- Networking (discovery of nodes, information replication and validation)
- Consensus (with the help of Proof of Work PoW or Proof of Stake PoS)
- Data (blocks and transactions)
- Application layer (smart contract and decentralized applications)
Blockchain stores all the information in a section called the ledger of the system. In addition, in the network, any information that is exchanged is called a “transaction”. In the past, blockchain was only used for digital currency trading; But today, different types of data can be exchanged in the platform of the blockchain-based network.
Each chain consists of several blocks and each block has three basic elements:
The data in the block.
A 32-bit number that we call Nonce. This number will be randomly generated when the block is created, and then it will generate the header hash of the block.
A hash is a 256-bit number that is combined with a Nonce number. This number must start with a large number of zeros; In other words, it will be a very small decimal number.
When the first block of the chain is created, the nonce number generates the cryptographic hash. The data inside the block is sealed and forever tied to the nonce and hash unless it is mined.
In the mining process, miners create new blocks on the chain. In the blockchain, each block has a unique nonce and hash number; But on the other hand, it also refers to the hash of the previous block in the chain; Therefore, mining a block is not easy at all, especially in large chains it will be extremely difficult.
Miners use special software to perform complex mathematical calculations in order to obtain a certain Nance number that produces an acceptable hash of the blockchain. Since the Nance number is 32 bits and the hash is 256 bits, there are approximately 4 billion possible combinations for the Nance number and the hash that must be extracted to get the correct combination. When the process of finding the correct combination is successful, the miner has found the “Golden Nonce” and its new block will be added to the chain.
Making changes to any block in the chain requires re-mining all subsequent blocks. For this reason, it is very difficult to manipulate the blockchain network because it takes a lot of time and requires a lot of computing power to get the golden Nance. Also, when a new block is mined, the changes within it are accepted by all active nodes in the network and the miner receives a reward.
In fact, this layer includes decentralized applications (dApps), dApp browser, user interface and application hosting. Decentralized applications can be accessed using the dApp browser. Unfortunately, common browsers such as Chrome and Firefox do not have the necessary ability to navigate between decentralized applications; But with decentralized browsers, you can browse the normal internet. dApps can be accessed from browsers inside the Metamask application.
Then, application hosting allows the user to launch and run all decentralized applications in this layer. Without this element, no decentralized application can run on the Internet. It is clear that the hosting protocol is also completely decentralized. In addition, maintenance of these hosting servers is completely safe. Decentralized applications are often similar to other applications, and their only difference is in having a decentralized network.
This layer provides access to important tools that help you build or run a decentralized application layer. Also, in this layer, it is possible to participate in blockchain control and access to off-chain calculations, state channels, data feed and side chain.
These sections can be briefly defined as the Data Feed process allows nodes to receive the most up-to-date version of information from all valid sources about the network. Off-chain computing allows computational processing to be performed outside of the blockchain network, increasing privacy. In fact, payment channels refer to the communication path between two nodes.
Apart from these elements, there may be other parts in this layer of blockchain. Oracles, multiple signatures, smart contracts, digital assets, wallets, distributed file storage memory, digital identities, etc.
The Semantic Layer includes the consensus algorithm, virtual machines, and other requirements for user participation, etc.
Without a consensus algorithm, the network loses its meaning. Consensus algorithm is a necessary process for agreement between the nodes of the network. Thus, in this process, all nodes must agree to verify information in the network; Therefore, no user can initiate a transaction and add it to the ledger unless they agree with other users to add the block after validating the information. Different types of consensus algorithms have been explained. For example, the first algorithm is called proof of work, the algorithm for proof of shares and their other derivatives are among the other algorithms used in blockchain.
Participation requirements placed in this layer refer to the rules that can be used to decide whether new users join the network. This element is mostly used in private blockchain technologies.
The virtual machines in this layer are also embedded in the network in order to increase the security and execution environment for all tasks. This feature is often used to implement smart contracts.The sidechains of this layer also allow developers to use separate blockchains to develop decentralized applications so that the core of the main network is not overshadowed.
One of the interesting parts is the forking process. But what is a blockchain fork? Fork in computer science means “branching” and “multi-branching”. To accurately define this concept and understand its process in network, we first go to its roots in software engineering. In Project Fork software engineering, or in other words, project branching occurs when developers separate a copy of the source code from the original software and develop it independently. This process makes software distinct and separate from the original software. Of course, developers should not necessarily create branches intentionally and with a previous purpose, and in the software environment, this process may occur unexpectedly.
In general, there are three types of forks, which of course can be divided into more subcategories. These three types of forks occur in different conditions. forks are:
In this type of branching, the new protocol is changed to be compatible with the previous one (Backward-Compatible). In this case, the software that runs on the nodes in the network undergoes a slight change, and the blocks that were extracted according to the new protocol are also considered valid by the nodes that have the old version of the blockchain. For example, the SegWit update to the Bitcoin network added a new class of addresses to the network known as Bech32. However, the addition of the new class of addresses did not invalidate the previous P2SH addresses, and a node with a P2SH address can have a valid transaction with a node with a Bech32 address.
In this type of fork, we see a wider change. In this type of branching, the protocol undergoes a so-called backward-incompatible change. In other words, the software changes in such a way that newly mined blocks according to the new protocol will not be validated by the previous version of the blockchain. When a hard fork happens, a new currency is born. For example, Bitcoin Cash was born after the hard fork of Bitcoin.
Nodes that update the hard fork will receive the digital currency of the new version equal to the number of digital currencies they have from the previous version. For example, if someone had 100 Bitcoins and ran a Bitcoin Cash Hard Fork Update, they would receive 100 Bitcoin Cash in addition to the number of Bitcoins.
Another example of hard forks is the update of Casper in Ethereum, which leads to a change in the agreement and consensus protocol of the nodes. During this update, Proof of Work (PoW) is going to be converted to Proof of Stake (PoS).