Blockchain Architecture

Güncellendi
Blockchain Architecture
Around how to realize decentralized trust, a blockchain can be divided into five layers from a technical point of view, which are the data layer, network layer, consensus layer, contract layer, and application layer, as shown in Figure 1. The data layer defines the blockchain’s underlying data structure, storage structure, and ledger pattern as the theoretical basis and outlines a theoretical model of decentralized trust. The theoretical model of blockchain decentralized trust in the network layer is realized by utilizing the distributed P2P network. In the consensus layer, the consensus algorithm organizes and coordinates the behaviors of nodes in the decentralized system to drive the continuous operation of the blockchain. In the contract layer, smart contracts are introduced as the extension of the blockchain so that the blockchain can handle more complex transactions. At the application layer, providing blockchain APIs makes it easy for developers to build Dapps and offer decentralized solutions to problems from various industries.
Mathematics 11 00101 g001 550Figure 1. Blockchain architecture.
3.1. Data Layer
Due to the lack of authoritative central node coordination and management, the decentralized system has problems such as easy data tampering, untraceable node behavior, and difficulty in rapidly authenticating transactions, leading to the data not being trusted. As the theoretical basis of blockchain, the data layer needs to solve the appealing problem to ensure that the data are credible to achieve decentralized trust. From the perspective of the logical structure of data, the blockchain is a chain composed of a connected block, and each block stores the transaction information. The blocks are connected by hash pointers and are chained in chronological order of their generation. According to the characteristics of the hash function, any slight modification to the block data will create a huge change in the hash value of the block, leading to the block not being chained. Based on that, security ensures that the data on the block is not tampered with, and thus the credibility of the data on the chain. The data layer constructs the decentralized trust model of blockchain from three aspects: data structure, storage structure, and ledger pattern.
3.2. Network Layer
The network layer is the key to implementing a decentralized system at the physical level. Decentralization means that the blockchain nodes are peer-to-peer at the physical level and that each node can communicate with each other without passing through the central node. Therefore, the network structure of the blockchain adopts the decentralized P2P structure. As shown in Figure 2, compared to a centralized network structure, a P2P network can ensure peer-to-peer communication between nodes, and nodes can join or exit the system quickly.
Mathematics 11 00101 g002 550Figure 2. P2P network vs. centralized network.
The P2P network is a distributed application architecture. The P2P networks were initially designed to facilitate the distribution of large files over unreliable networks. In a P2P network, multiple computers are connected in a peer-to-peer position, and the entire network does not require centralized coordination by a central processing node. In P2P networks, each peer can act as both requestor and responder of network services. Research on p2p network technology has recently focused on improving system performance and security. In system performance: Abudaqa et al. [33] summarized, evaluated, compared, and classified the techniques used to improve the performance of P2P file-sharing systems based on network coding; Milojicic et al. [34] provided a general analysis of the design and implementation issues of P2P systems in the context of practical cases. In security: Alharbi et al. [35] explored the security weaknesses and threats in P2P networks and proposed that the fundamental problem of P2P networks is the trusting of peers and the problem of secure traffic routing. Risson et al. [36] discussed the metrics affecting the robustness of P2P systems.
3.3. Consensus Layer
The consensus layer implements the consensus algorithm, which organizes and coordinates the decentralized system, allowing the blockchain to operate securely and stably. A blockchain is a distributed system where nodes communicate and coordinate with each other only through messaging because no central node is involved. In a distributed system, nodes agreeing on an event is also called a consensus, and a consensus algorithm is used to ensure data consistency among nodes in the system. Due to unavoidable problems such as network latency, node failure downtime, and bandwidth limitation, distributed systems are subject to the FLP impossibility principle and CAP theory. The FLP impossibility principle [37] means that in a system containing multiple deterministic processes, as long as one process may fail, no protocol can guarantee a finite time for all processes to agree. CAP theory points out that it is impossible for any distributed system to satisfy consistency, availability, and partitioning of fault tolerance at the same time [38], as shown in Figure 3. Therefore, according to CAP theory and the FLP impossibility principle, certain aspects must be traded off when designing consensus algorithms for blockchains.
Mathematics 11 00101 g003 550Figure 3. CAP theory.
Blockchain can be regarded as a distributed public ledger. The essence of consensus is to decide the bookkeeping right, i.e., to solve the problem of who can produce the blocks and package the transactions into the blocks. According to the different mechanisms to reach consensus, blockchain consensus algorithms can be divided into proof-based and voting-based.
3.4. Contract Layer
The contract layer implements smart contracts, a set of digitally set commitments that are unmodifiable once deployed and executed immediately once triggered. Smart contracts, as an extension of the blockchain, enable the blockchain to have the ability to handle logically complex transactions.
3.5. Application Layer
The application layer provides API interfaces for users to easily build Dapps using blockchain services and applies blockchains to various practical scenarios. With the development of blockchain technology, various Dapps have emerged to bring decentralized trust solutions to the problems of traditional industries.
4. Blockchain Basic Principle
4.1. Data Structure
A blockchain has a chain structure in terms of blocks to achieve data immutability. The data structure of different blockchain platforms differs in specific details but is the same overall. Take Bitcoin as an example. The block in Bitcoin is divided into the block header and the block body. The block header contains the version number, random number, hash of the previous block, Merkle tree root hash, timestamp, current workload proof difficulty, etc. The block body contains all the transactions packed into the block, and the Merkle tree comprises these transactions. To support smart contracts, Ethernet adds a system state to the block header for storing account balances, contract storage, contract code, and account random numbers.
A block contains a block header, timestamp, proof-of-workload random number, hash of the previous block, packed transactions, Merkle tree, etc. [1]. The block’s verification signature and proof-of-work use cryptographic algorithms such as elliptic curve encryption and SHA-256. The data-layer structure differs slightly from blockchain platform to blockchain platform because of the different functions they focus on. Take the Bitcoin system as an example, and the data-layer structure is shown in Figure 4:
Mathematics 11 00101 g004 550Figure 4. Blockchain data-layer structure.
To reduce the bandwidth consumption caused by block synchronization, each block in the Bitcoin system can be divided into two parts: the block header and the block body, which stores all the transaction records in the current block. Bitcoin nodes are divided into full nodes and light nodes. Bitcoin light nodes only need to synchronize the block header for block synchronization. The transaction records in the Bitcoin system are similar to the transaction records in the physical system. Each transaction record includes information such as the input and output addresses of the transaction information and the number of transfers. Based on this transaction information, a corresponding form of Merkle-tree structure can be generated from the bottom up. The hash value of the root node of the Merkle tree is stored in the header of the block, and at the time of each block generation, the bookkeeper of the block adds a timestamp to the block, which is used to mark the generation time of the block. As the timestamp is enhanced, the block is extended to form a chain of blocks with a time dimension, allowing data information to be traced back in time. In addition, the block header contains the hash value of the previous block header, the version number, the random number of the proof of work, and the target hash value, among other information. Finally, the all information in the header of this block is hashed, and the resulting hash value exists in the header of the next block, which, in terms of logical structure, makes each block linked together in the form of a chain.
4.1.1. Hash Function
Hashing converts data of any length into a number within a fixed range. The conversion method is called a hash function, which calculates the value obtained after the original value is called a hash value. Take MD5, a widely used hash function, as an example. The MD5 algorithm is also called the MD5 message digest algorithm, which can generate a 128-bit hash value to ensure the integrity and consistency of information transmission. The MD5 algorithm is universal, stable, and fast; and it is widely used in the encryption and protection of ordinary data.
Hash functions are the basis of crucial blockchain technologies such as hash lists, digital signatures, and Merkle trees. The calculation of the hash function is unidirectional. It is easy to calculate the hash value of the given data, but it is difficult to deduce the original data given the hash value. The generated hash value may be the same for different data, and this phenomenon is called a hash collision. Due to the one-way nature of the hash function, people who want to generate hash collisions can only continuously try random numbers through brute force. Therefore, the process of finding suitable random numbers to create hash collisions is often used as “proof of work” by the blockchain.
4.1.2. Hash List
In order to ensure that the block data cannot be tampered with, the hash value of the previous block is retained in other blocks except the Genesis block, and the blocks are connected with the hash value to form a hash list. A hash list is a one-way chain table in which hash pointers connect nodes. Any small change in the block data will cause a huge change in the hash value, so it is impossible to tamper with the data in the hash list.
In addition to a chained structure, some scholars have proposed a blockchain with a non-chain structure for dealing with different scenarios. Qi et al. [39] proposed a cascade structure of blockchain to solve the performance problem of blockchains, which can accelerate the generation of blocks, expand the capacity of blocks, reduce the risk of bifurcation, and increase the security. Ribero et al. [40] proposed a cryptocurrency called DagCoin based on DAG structure, the first blockchain-based on DAG. DagCoin has no fixed blocks; each transaction has its own proof of work. The system can achieve a speed comparable to Bitcoin. Despite the emergence of blockchains with non-traditional chain structures, such as DAG and cascade structures, mainstream blockchains are still dominated by chain structures.
4.1.3. Timestamps
To make transactions traceable, Bitcoin adds timestamps to blocks and calculates the block’s hash value by using the timestamp as the information in the block together. The timestamp is the total number of seconds from 00:00:00 GMT on 1 January 1970 to the present, and the timestamp proves that the transaction in the block must have existed at that time.
The current development of timestamps mainly revolves around improving timestamp accuracy and reducing errors. Zhang et al. [41] proposed an accurate blockchain-based timestamping scheme which solves the problem of the inaccuracy of file timestamps caused by blocks due to the existence of time errors in timestamps. Ma et al. [42] proposed an optimized blockchain timestamping mechanism that reduces the range of timestamps in blocks to an average of 10 min by serving external trust timestamps to the blockchain consensus.
4.1.4. Merkle Tree
Blockchain stores all the transaction records of history, and the data volume of historical transaction data will become larger and larger as time goes by. It is unrealistic to verify the existence of a certain transaction by traversing all the historical transactions. To enable fast transaction verification, all transactions in the block are stored as a Merkle tree.
A Merkle tree is a tree that connects parent and child nodes with a hash pointer. Bitcoin uses the simplest binomial Merkle tree to quickly verify whether a transaction exists in a block. The structure of a binary Merkle tree is shown in Figure 5. Each leaf node in the tree corresponds to a SHA256 hash of one transaction data within the block. The value of the parent node is obtained by concatenating the values of the two child nodes and then performing a hash operation. Hashing between nodes is performed repeatedly until the root hash value is reached, when the transaction Merkle root is generated. The Merkle root is used to detect any tampering with the transaction data in the block, so as to ensure the integrity of the transaction data in the block.
Mathematics 11 00101 g005 550Figure 5. Merkle tree.
4.1.5. Digital Signature
Bitcoin is a chain of digital signatures designed to prevent transactions from being forged or denied. A digital signature is an unforgeable string of numbers that can be generated only by the sender of the message. It proves the validity of the sender of the message. Digital signatures are often used to verify the integrity of documents or messages and are an effective way to make transactions non-repudiation and unforgeable. In the process of Bitcoin transactions, the owner of a Bitcoin transfers the coin to the next owner by digitally signing it with the hash of the previous transaction and the next owner’s public key and adding it to the end of the coin. The recipient can verify these signatures to validate the ownership of the coin.
Digital signatures are based on asymmetric encryption, first proposed by Rivest et al. [43]. Asymmetric encryption has two keys, which are used in the encryption and decryption processes. The commonly used asymmetric encryption algorithms in blockchain are RSA, SHA256, ECC, etc. As a decentralized distributed system, blockchain needs to adopt a compatible encryption algorithm because the system configuration of each node is different. RSA algorithm is an international standard algorithm that is widely used and compatible and can be applied to different systems. RSA is the first algorithm that can be used for encryption and digital signature, and it is also considered one of the best public key schemes. Although RSA has the characteristics of strong compatibility and high security, RSA has the problems of long key and time-consuming cryptographic computation. Compared to RSA, ECC has the advantages of small key length, high-security performance, and small time consumption for the whole digital signature. Compared with RSA, ECC can use a shorter key to achieve comparable or higher security than RSA.
4.2. Storage Structure
During blockchain transaction execution, transaction data need to be packaged into blocks, and data writing is in high demand. In the process of blockchain transaction validation, it is necessary to quickly locate the block where the transaction is in and perform transaction validation. Based on the above functional requirements, blockchain often uses a combination of file systems and databases to store block data. The file system can facilitate the system to append data in the form of logs, and the database stores the index information of the file where the block is located, which can quickly find the location of the relevant transaction block and assist the system in query. Block data and block “undo” data are stored in the file system, and block “undo” data are the data for rolling back the blockchain when the system generates a chain fork. The database stores the state and index data of the blockchain, which are usually stored in key–value pairs for quick querying.
4.3. Ledger Pattern
A blockchain is a decentralized transaction ledger, and the ledger records the history of all transactions. There are two main types of mainstream ledger patterns: transaction-based and account-based.
4.3.1. Transaction-Based Ledger
The transaction-based ledger is used for digital currency transactions and is the ledger model used by Bitcoin. In Bitcoin, an “Unspent Transaction Output” (UTXO) is used instead of a centralized institution to clear transactions. In this transaction-based model, the user’s assets are not explicitly recorded directly in the system but instead extrapolated from the information in UTXO. In order to know how many bitcoins a user has in total assets, we need to calculate how many coins that user has in total in all accounts in UTXO. The transaction-based ledger can record each transaction, trace the origin of each fund, and protect user privacy.
4.3.2. Account-Based Ledger
The account-based ledger is suitable for blockchain platforms that support smart contracts, such as Ethereum and Hyperledger Fabric. The account-based ledger model is similar to a bank account, where the account balance information is recorded explicitly by the system, and the transaction balance and business status data can be easily checked. Take Ethereum as an example. Ethereum accounts are divided into external accounts and contract accounts. External accounts are controlled by public–private key pairs; the user locally generates a public-private key pair. The private key controls the account also called a normal account. The user creates a contract that returns an address, and the contract can be invoked as long as the address of the contract is known. The account-based ledger gives participants a more stable identity and better support of smart contracts.
5. Consensus Mechanisms
In the decentralized scenario, without the participation of the central node, a fair operation mechanism, i.e., a consensus mechanism, must be established among the nodes of the blockchain to enable each node’s unified and coordinated operation. Blockchain establishes a “trustworthy” network among nodes through the consensus mechanism so that each node can reach an agreement and achieve data consistency in the ledger of each node in the blockchain, which drives the continuous operation of the blockchain. The consensus mechanism of blockchain mainly solves the problem of who will construct the block and who will package the transactions into the block [44]. The consensus mechanism is the core of blockchain technology, which determines the security, scalability, and distributed nature of blockchain system. The problem of consensus originates from the “biliteracy problem”, and later the “Byzantine general problem” was proposed. The biliteracy problem refers to how to achieve reliable communication over unreliable channels. The Byzantine problem refers to the problem of how to make a distributed system agree in the presence of malicious behavior (e.g., message tampering or forgery), and the nodes that can both fail and behave badly are called “Byzantine nodes”. Consensus algorithms can be divided into classical distributed system consensus algorithms and blockchain consensus algorithms, depending on the time. Classical distributed consensus algorithms include Paxos, Raft, and Kafka. According to the different mechanisms used to reach consensus, blockchain consensus algorithms can be divided into proof-based and voting-based. The proof-based consensus algorithms require “some competition” among nodes to decide the bookkeeping rights, such as proof-of-work (PoW) and proof-of-stake (PoS). Proof-based consensus algorithms do not require the strict identity of participants, and nodes are free to join and exit, so proof-based consensus algorithms are commonly used in public chains. The voting-based consensus algorithm is initiated by a node to reach consensus by having the whole network nodes vote on whether to agree to the proposal, such as practical Byzantine fault tolerance (PBFT) [45]. The voting-based consensus algorithms require a high identity of participating voting nodes and control the joining and exiting of nodes by the access mechanism, so voting-type consensus algorithms are commonly used in consortium chains.
The consensus algorithm is the core of blockchain technology and a research hotspot of blockchains. The current research on consensus algorithms mainly focuses on two aspects: performance optimization and application. In performance optimization: Wu et al. [46] proposed a hybrid consensus algorithm for blockchains that combines the advantages of PoS and PBFT algorithms. It reduces the number of consensus nodes to a fixed value through verifiable pseudo-random ordering and witnesses transactions between nodes. The improved hybrid consensus algorithm has excellent scalability, high throughput, and low latency, which is superior to the previous single algorithm. In applications: Biswas et al. [47] proposed a proof-of-block-transaction (PoBT) consensus algorithm. The algorithm allows the verification of transactions and the reduction of computation time for blocks, improving the performance of the system in terms of security, computation, memory, and bandwidth. Fu et al. [48] proposed a framework for evaluating consensus algorithms to provide guidance for the selection of consensus algorithms in sundry blockchain application scenarios.
5.1. Pow
5.1.1. Overview
The proof of work (PoW) algorithm is one of the most widely used consensus algorithms in blockchain systems, and the Bitcoin system uses the PoW consensus algorithm. The PoW algorithm was first used for spam detection [49], and the core idea is to include in the email proof that a certain job has been completed (hence the name “proof of work”). Usually, the calculation of such proofs takes a few seconds, so this does not cause any difficulties for casual users. However, for spammers, this can take weeks to send millions of spam emails. Email recipients can easily verify if an email is a spam by proof of workload.
In the blockchain using the PoW consensus algorithm, nodes need to constantly search for a specific random number, which is usually required to be calculated by a hash function (e.g., SHA-256) to obtain a hash value starting with several zero bits. It can be verified that the average work required to compute the random number is an exponent of the number of required zero bits. Due to the one-way computation and irreversible nature of the hash function, the random number found by the node is easily verified. In the Bitcoin system, the first node to find a specific random number is given bookkeeping rights and 50 coins as a reward. Hence, the process of finding random numbers is also called: “mining”.
5.1.2. Advantages and Disadvantages
The Bitcoin system has been running smoothly since its launch in 2009 without any major failures, which is a testament to the effectiveness and security of PoW. In the PoW consensus, a node needs to control 51% of the computing power of the whole network to launch an attack. In the absence of a centralized node, the probability of a successful node attack is very low. Therefore, PoW consensus can effectively guarantee the security of the blockchain system. However, in PoW consensus, nodes constantly performing hashing operations will consume a large number of power resources, and blockchain chain systems using PoW consensus generally have serious energy consumption problems. In addition, the throughput of transactions in PoW consensus is very low. E.g., Bitcoin processes about seven transactions per second due to the limitation of block-out time and block size. This low transaction throughput makes it difficult to meet other application scenarios.
5.1.3. Improved Algorithms
PoEWAL (proof of elapsed work and luck) [50]: The PoEWAL consensus reduced the energy cost of the consensus by adding a time limit to the PoW. The mechanism emphasizes consensus by solving problems partially rather than completely within a fixed time frame. By adjusting the size of a given time period, the resource consumption of block mining can be effectively reduced, and devices with low computing power can also participate in mining. However, the essence of the consensus is still to obtain more consecutive zero hash values through continuous hashing operations. There is a problem similar to PoW where nodes with high arithmetic power have a higher probability of successful mining.
The trust-based PoW mechanism [51]: It can effectively solve the problem of high energy consumption in PoW consensus while ensuring the security of the blockchain network. By introducing the attribute of the node credit value, the higher the credit value, the lower the difficulty of node mining. Using a malicious behavior detection mechanism, the behavior of nodes is divided into positive and negative aspects, and positive behavior helps to increase the credit value of nodes. In contrast, negative behavior decreases the credit value of nodes. The positive aspect is expressed as the number of valid transactions calculated and verified by the node in the consensus process. In contrast, the negative aspect is determined by the node’s malicious behavior time and penalty coefficient, where the malicious behavior is divided into two types. One is the node’s lazy inaction in the consensus process. The other is the node’s double spending attack in the transaction. The system dynamically adjusts the penalty factor according to the actual malicious behavior of the node, but it will bring on an additional computational overhead for malicious behavior monitoring.
5.2. Pos/Dpos
5.2.1. Overview
The Proof-of-Stake (PoS) [44] algorithm is designed to solve the problem of wasting a lot of resources by using PoW mining. Unlike PoW, which determines the bookkeeping right through the arithmetic power of nodes, PoS differentiates the bookkeeping right through the “equity” of nodes owning coins. The core idea of PoS is that in a decentralized network, the node with the largest equity will have a greater incentive to maintain the network. In terms of implementation, PoS introduces the coin age to dynamically adjust the mining level of nodes with different equity. The older the node, the lower the difficulty of mining it. Based on the appealing advantages of PoS, the PoS algorithm was first adopted in the blockchain platform peercoin, and Ethereum’s consensus mechanism was transitioned from PoW to PoS [52] on 15 September 2022.
Although PoS solves the energy consumption problem of PoW, the performance is still not improved. In response to the performance problems of PoS, Dan [53] proposed the delegated proof-of-stake (DPoS) algorithm [54]. The topology of DPoS is shown in Figure 6. DPoS reduces the pressure on the network by reducing the number of participating consensus nodes and adding an election mechanism to PoS. As a variant of PoS, DPoS is similar to PoS in that the number of representative members is limited and elected by all, and the elected representatives participate in the consensus.
Mathematics 11 00101 g006 550Figure 6. DPoS topology.
5.2.2. Advantages and Disadvantages
PoS consensus can significantly provide the transaction throughput of the system and reduce the energy loss in the consensus process. However, PoS consensus has disadvantages such as poor fairness and ease of generating the Matthew effect. The use of coin age will make it easier for the node with more tokens to gain bookkeeping rights, shifting the power gradually to that node, decentralizing the degree of decentralization, and making fairness worse.
5.2.3. Improved Algorithms
e-PoS [55]: In response to the possibility that PoS can lead to centralization and unfairness in blockchain systems, Saadd et al. improved PoS and proposed modular e-PoS. Compared with PoS, e-PoS can resist the power concentration of the network.
Ouroboros [56]: Kiayias et al. proposed the first proof-of-stake-based consensus protocol with strict security guarantees. Ouroboros also employed a new incentive mechanism to incentivize “proof-of-stake” protocols, where honest behavior is an approximate Nash equilibrium.
5.3. Pbft
5.3.1. Overview
Practical Byzantine fault tolerance (PBFT) [45] can tolerate Byzantine faults. The PBFT algorithm was proposed by Miguel Castro and Barbara Liskov in 1999. It improves the efficiency of the Byzantine algorithm and reduces the complexity from exponential to polynomial, making Byzantine fault tolerance practical. The PBFT algorithm can achieve 2f + 1 fault tolerance; f is the number of Byzantine nodes that can be tolerated; and 2f + 1 can ensure that the correct nodes in it send more information than malicious nodes. Therefore, the minimum number of nodes required by PBFT is 3f + 1 (the maximum number of fault-tolerant nodes is (n − 1)/3).
The PBFT algorithm is divided into five stages: request, preparation, preparation, confirmation, and reply. The process is shown in Figure 7. In the request stage, the client initiates a transaction request to the master node. In the pre-preparation phase, the master node verifies the message signature after receiving the request from the client. After the message signature verification is passed, it broadcasts the pre-preparing message to all the network’s nodes. In the preparation phase, the replica node verifies the message after receiving the pre-preparing information broadcast by the master node. If the verification is passed, the node broadcasts the prepare message to other nodes. In the confirmation phase, after receiving the correct prepare message from 2f other nodes, the node will enter the prepared state and send a commit message to other nodes. In the reply phase, after the node receives the commit message, it verifies the message, passes the verification, and waits for the commit message sent by 2f + 1 different nodes. After receiving the message, it will send a reply message to the client.
Mathematics 11 00101 g007 550Figure 7. PBFT consensus process.
5.3.2. Advantages and Disadvantages
The PBFT algorithm can realize Byzantine fault tolerance with polynomial complexity and reach a consensus in the presence of malicious nodes in the network so that the Byzantine fault tolerance algorithm can be applied in practical systems. However, the PBFT algorithm has problems such as high communication complexity, a fixed number of nodes, poor scalability and dynamics, and only being suitable for private chains or consortium chains. In terms of network resource consumption, the frequent broadcasting of messages by the system will also lead to high bandwidth consumption. When the number of participating nodes increases, network congestion will likely occur, resulting in system performance degradation. Regarding the number of participating nodes, the number of nodes in the PBFT algorithm remains unchanged, the nodes cannot enter and exit at will, and the number of nodes is fixed.
5.3.3. Improved Algorithms
Hot-Stuff [57]: This algorithm was proposed by Abra et al. It improves the efficiency of the distributed consistency algorithm by making improvements to PBFT. The Hot-Stuff algorithm uses a parallel pipeline processing proposal, which is equivalent to combining the preparation and commitment phases in PBFT into one phase. In addition, Hot-Stuff uses linear view change (LVC), which reduces the communication complexity in view change.
RPBFT [58]: In response to the problems of arbitrary master node selection, a high communication overhead, poor dynamics, and low efficiency in the PBFT algorithm, Li proposed the practical Byzantine fault-tolerant consensus algorithm (RPBFT) based on role management. The RPBFT algorithm divides nodes into three roles, manager, candidate, and normal nodes; and realizes the transition between roles through a reward mechanism and election mechanism. Each role has specific responsibilities, so the nodes do not need to restart the system during joining and exiting. Meanwhile, using a synchronous verification mechanism instead of the traditional view replacement protocol increases the node efficiency.
5.4. Discussion
The consensus mechanism is the core part of a blockchain. The traditional distributed consensus mechanism (PBFT) is not well adapted to the unique open environment of the blockchain, and the network connection is replicated between nodes. Therefore, traditional distributed consensus blockchain systems often employ various networking assumptions. However, reality often differs from our assumptions. Consensus mechanisms explicitly designed for blockchains (such as PoW, although its original purpose is not this, are still regarded as representatives of blockchain consensus mechanisms) often do not need to make various assumptions about the network and nodes. Thus, openness and decentralization tend to be stronger. In different application scenarios, the two have their advantages and disadvantages, and blockchain designers must choose.
6. Smart Contracts
Smart contracts are the core of blockchain 2.0 [59], represented by Ethereum smart contracts. They allow a blockchain to handle complex transactions not just limited to cryptocurrency ones. The concept of smart contracts was proposed before the emergence of blockchain, almost simultaneously with the emergence of the modern Internet. However, limited by the technological development at that time, smart contracts were not widely used until the emergence of blockchains.
Smart contracts are digitally established contractual terms that are self-verifying, self-executing, and do not require a third party. Compared to traditional contracts, smart contracts are more efficient, less costly, more secure, and free from “repudiation”. Smart contracts are designed to perform safely and efficiently without a trusted third party, which aligns with the “decentralized trust” of blockchain. The smart contract in a blockchain is essentially a piece of code that runs continuously, cannot be modified once deployed, and is executed automatically when a predefined condition is triggered. A blockchain enables reliable information exchange, value transfer, and asset management through smart contracts.
6.1. Development
Smart contracts were first proposed by American computer scientist Nick Szabo in 1995 [60]. In 2009, the Bitcoin platform went online, supporting the use of Bitcoin scripts to manage transactions with the prototype of smart contracts. Bitcoin also represented the first generation of blockchain technology. In 2014, Ethereum [61] introduced smart contracts and supported the creation of smart contracts in the Turing-complete programming language. In 2016, Kosba et al. [62] proposed Hawk, a smart contract development framework that protects user privacy. In 2018, Kalra et al. [63] proposed ZEUS, a smart contract security analysis framework. The framework provides an order of magnitude improvement in security analysis time compared to previous techniques. In 2020, Zheng et al. [64] classified smart contract applications by comparing and analyzing typical smart contract platforms.
In summary, smart contracts are evolving towards easier development, higher security, and widespread application. Additionally, with the rise in blockchain technology, smart contracts will also receive more attention from scholars while developing rapidly.
6.2. Contract Languages
Smart contracts are deployed to blockchains, which requires the contracts to be strongly typed, as blockchains have valuable storage space. In addition, smart contracts should be easy to read and not misleading. Therefore, traditional programming languages such as C/C++ and Java do not write smart contracts very well. Programming languages for smart contracts have been born to meet the development needs of smart contracts.
6.2.1. Solidity
Solidity [65] is a new language developed specifically for Ethereum smart contracts. It has a syntax similar to JavaScript and runs on EVM. Solidity is a statically typed programming language that supports inheritance, libraries, and user-defined types. It can be used to create voting, crowdfunding, blind auctions, and multi-signatures. It can be used to create a variety of contracts, such as voting, crowdfunding, blind auction, and multi-signature wallet. On Ethernet, solidity contracts are compiled into bytecode, written to blocks through special transactions, and eventually executed by other transactions driven by the Ethernet VM. Solidity is one of the most widely used contract languages today, but at the same time, solidity has seen many security vulnerabilities and corresponding attacks.
6.2.2. Vyper
To solve solidity’s security vulnerabilities, Vyper provides a smart contract language focusing on simplicity, suitability, and security [66], a contract-oriented Python programming language targeting EVM [67]. Vyper has a very clean and easy-to-understand syntax, so it is almost impossible for developers to write misleading programs.
6.2.3. Daml
The DAML language [68] is a domain-specific language specifically designed to encode shared business logic for simple, secure, and efficient applications. DAML is used for developing and deploying distributed applications in blockchain environments and is one of the best programming languages for smart contracts. Developers can use DAML to write applications quickly and concisely as an open-source programming language.
6.3. Platform Comparison
6.3.1. Bitcoin
In the Bitcoin network, users can write Bitcoin scripts to manage transactions. Bitcoin scripts are used to implement bitcoin transaction validation by checking a transaction’s lock script and unlock script. Bitcoin scripts are stack-based, non-stateful, non-Turing-complete scripting languages with no complex statements such as select and loop statements, and therefore, they have limited functionality. Bitcoin scripting reduces the complexity of the system while meeting the requirements of transaction needs. However, it also brings disadvantages, such as low flexibility and limited usage.
To allow Bitcoin to adapt to different systems, Bitcoin scripts are designed to be stateless so that a script can be executed similarly on any system. Suppose a script is validated on one system. In that case, it ensures that every other system in the Bitcoin network can also validate the script, meaning that a valid transaction is valid for everyone. A Bitcoin script is a sequence of actions for a transaction that describes what happens to the next person who wants to spend the bitcoins being transferred and will gain access to them, divided into locking scripts and transaction scripts. Bitcoin scripts have the makings of a smart contract.
6.3.2. Ethereum
For the first time in a blockchain system, Ethereum introduced smart contracts that support Turing completeness [5]. Ethereum uses Solidity to write smart contracts. Solidity is a contract-oriented, high-level programming language created to implement smart contracts. In Ethereum, smart contracts deploy bytecode to the Ethereum network through transactions. Ethereum successful deployment generates a new smart contract account, executed by an Ethereum Virtual Machine (EVM). When deploying a smart contract, the contract code is first compiled into EVM bytecode by the SOLC smart contract compiler, and then a single transaction is used to create the smart contract. Ethereum smart contracts are Turing-complete, so in theory, users can write programs that do anything with them. It is easy to create contracts for voting, crowdfunding, closed auctions, multi-signature wallets, etc., using solidity, and they can meet most smart contract development needs.
6.3.3. Hyperledger Fabric
Hyperledger Fabric [7] is a platform for distributed ledger solutions based on a modular architecture that is highly confidential, resilient, flexible, and scalable. Its main purpose is to support the pluggability of different components to the complexity and complexity of the economic ecosystem. Hyperledger Fabric typically deploys smart contracts in the form of chain code. In Hyperledger Fabric, the chain code is the business bearer and is primarily responsible for the specific business logic, i.e., encapsulating transaction definitions and processing logic into interfaces. Each chain code runs in a protected container (Docker), isolated from the running of background nodes. Hyperledger Fabric supports writing smart contracts in multiple languages, such as golang, java, and node.js, which greatly reduces the development threshold for smart contracts.
6.3.4. Eos
The Enterprise Operation System (EOS), a commercially distributed application blockchain operating system, is a new blockchain system developed by Block.one which aims to decentralize everything. As a new blockchain architecture [8], EOS provides a platform for smart contract development. It distributes storage designed to address scalability issues common in blockchain systems such as Ethereum and Bitcoin. EOS provides a decentralized application development environment with high transaction throughput through dPoS consensus and BFT consensus. Unlike Ether, which uses a virtual machine to execute smart contracts, EOS uses WebAssembly3, a portable, small, fast-loading, and web-compatible format, so users can write smart contracts in various languages as long as they can be compiled into WebAssembly3 (e.g., C++).
6.3.5. Avalanche
Avalanche is a new generation of public chain projects, and the main network was launched in September 2020. Avalanche is not a blockchain but a collection of blockchains composed of multiple subnets. The subnet has a special subnet consisting of three blockchains, the Primary Network. The three chains are the exchange chain (X-chain), platform chain (P-chain), and contract chain (C-chain). Each of the three chains has its functions, and they can be converted across chains, making it more convenient for users to take advantage of assets. The X-chain is responsible for the establishment and transferal of assets, and most users use this chain when transferring assets or trading assets. The P-chain is responsible for storing the data, information, and verification work on the chain. The C-chain is responsible for the functions of smart contracts. This chain is compatible with EVM, so it can be applied to most smart contracts. Thanks to its unique structure compared with traditional blockchain platforms, Avalanche has higher performance—it can achieve more than 4500tps—and is more scalable and secure.
6.4. Example
The following is an example of a money transfer contract to show the complete workflow of smart contract development, deployment, and execution. Suppose A wants to transfer money to B through a smart contract. The contract workflow is shown in Figure 8. First is development, where the business process of transferring money from A to B is written as smart-contract source code, and the source code is compiled into bytecode by a compiler. Next is deployment, where the compiled bytecode is deployed to the blockchain network via a single transaction. After consensus in the P2P network, the contract address is returned for contract invocation. Finally, when the deployed smart contract triggers an execution condition or is invoked to execute the contract transaction (e.g., deducting a specified amount from A’s account and adding a specified amount to B’s wallet), the result of the execution will be written to the block.
Mathematics 11 00101 g008 550Figure 8. Smart contract workflow.
In the process of transferring funds from A to B, the whole process is open and transparent without the intervention of a third party, and the results of the transaction execution are written to the blockchain and cannot be tampered with.
6.5. Discussion
The execution of smart contracts does not require the participation of a third party and can respond to user requests at any time, ensuring the fairness and efficiency of transactions. Before the contract is deployed, all the terms and execution processes have been formulated and executed under the computer’s absolute control, so there is no possibility of errors in the entire process. Once the contract is deployed, all content cannot be modified. If one party breaks the contract, it will be punished accordingly. Using smart contracts can save transaction fees charged by banks and service fees of intermediaries. In addition to the advantages mentioned above, smart contracts still have the following problems: security issues, as it is difficult for anyone to guarantee the complete correctness of the code, and errors cannot be modified; interface problems, as each blockchain has different forms of storage for digital assets; the issue of how to call smart contracts across blockchains to realize asset transfers remains to be researched.
7. Applications
From blockchain 1.0 to blockchain 3.0, blockchain technology has been flourishing. Blockchain technology has also been applied from the earliest cryptocurrency to a wider range of fields, such as cryptocurrency, healthcare, IoT, Security AI, and NFT. [13]. The decentralized, open, and transparent characteristics of blockchain can also bring decentralized solution ideas to existing problems in some fields.
7.1. Cryptocurrency
Cryptocurrencies have been around since the 1990s but were not used and developed for various reasons until the emergence of Bitcoin made them widely known. Electronic cash (Ecash) emerged in 1990, changing the way traditional money works and allowing it to be traded digitally and anonymously over the Internet. In 1997, Back proposed the hashcash algorithm mechanism [69], which calculates a token through the CPU cost function and can be used as a proof of workload. In 1998, Dai proposed the electronic cryptocurrency system B-money, a distributed system that uses cryptography to control the currency for transactions, and first adopted the idea of decentralization to design cryptocurrency. In 2008, influenced by the global financial crisis, the international community began exploring innovative finance. Satoshi Nakamoto proposed Bitcoin in this context, which also marked the birth of Blockchain 1.0 technology. Satoshi Nakamoto combined a distributed system using cryptography from Ecash and B-money and a proof-of-work mechanism from Back and Finney to solve the trust and Byzantine problems. Bitcoin is a P2P form of digital currency. Unlike traditional currencies, Bitcoin does not have a central currency issuer, and the P2P network nodes work together to keep the system running. Bitcoin is also the most successfully used cryptocurrency to date.
Cryptocurrency is by far the most successful and well-known application of blockchain. Cryptocurrencies, represented by Bitcoin, were once synonymous with blockchain. It is foreseeable that even in the future when blockchains are widely used, cryptocurrencies will remain among of the most important blockchain applications.
7.2. Energy
Current energy trading methods are still dominated by traditional centralized trading, which suffers from inefficient trading, opaque trading information, and long settlement times; and distrustful and opaque energy markets have potential security and privacy issues. In addition, intermittent energy sources and microgrids are an important part of the energy supply, and the increasing amount of renewables in the energy system requires new market approaches to pricing and decentralized generation [12].
Compared to centralized generation and single -arket pricing strategies, using a decentralized blockchain to control generation and energy trading can better incentivize generation organizations, improve generation efficiency, and facilitate energy trading. Kang et al. [70] proposed a localized P2P power trading system (PETCON) for local power trading among plug-in hybrid electric vehicles (PHEVs) based on consortium chain technology. In PETCON, electricity trading among PHEVs is resolved through an iterative double-auction mechanism that maximizes social welfare while protecting PHEVs’ privacy. Su et al. [71] proposed a smart-contract-based energy blockchain system that enables secure charging services for electric vehicles by executing smart contracts. The experimental results show that the scheme has higher efficiency compared to other conventional schemes.
Blockchain technology will be applied more to decentralized energy management and energy trading in the future, and decentralized energy management systems can supplement the current centralized energy management system.
7.3. Healthcare
The current information systems of most medical institutions are centralized and stored independently, which makes it difficult to efficiently interconnect data among medical institutions and inconvenient for patients to seek medical treatment across institutions. Centralized information systems are also vulnerable to hacking and data leakage, compromising patients’ privacy.
Blockchain’s tamper-proof and verification features can ensure that patients’ private information is not leaked [72]. Azaria et al. [73] have built a decentralized record management system (MedRec) to handle electronic medical data using blockchain technology. The system provides a comprehensive, immutable patient log and is easily accessible. Using PoW incentives enables patients to participate as “miners” in maintaining the system’s security while allowing patients and providers to choose the release of metadata to facilitate medical research. healthbank, a Swiss global digital health startup, offers users a secure blockchain-based data management platform [74], where users can store and manage their health information data, and the sovereignty of the data is in the hands of the user. In addition, healthbank can act as a data trading platform where users can save data for medical research, and where users can receive specific financial compensation for the data they provide. hirtan et al. [75] implemented a medical data-sharing system using Hyperledger Fabric, which can share important information about medical analytics among hospitals, medical clinics, and research institutions based on patient-defined access policies. The system uses a combination of public and private chains to protect user privacy. The private chain stores the user’s accurate ID information, and the public chain stores patient health information labeled with temporary IDs.
In summary, the use of blockchain to build a decentralized medical data management platform enables the sharing of medical data to facilitate medical research while ensuring the privacy and security of the data.
7.4. Internet of Things
IoT devices are found in various scenarios, such as cities, buildings, and homes. IoT combines various information sensing devices with networks to form a huge network to achieve interconnection of people, machines, and things at any time and place, allowing traditional devices to become intelligent and autonomous [13]. However, the IoT still has issues such as security and privacy that hinder its widespread use.
A blockchain can establish decentralized trust in a distributed environment [76], which helps to overcome the security issues and privacy problems of IoT. Alphand et al. [77] combined an object-based IoT security architecture and an ACE authorization framework. Their solution uses a blockchain to replace a single ACE authorization server. It enables smart contracts, handles authorization requests, and uses a self-healing key distribution scheme to achieve efficient management of the IoT. Li et al. [78] proposed a multilayer, secure IoT network model based on blockchain technology, providing a wide-area network solution for the IoT. The model reduces the difficulty of blockchain deployment by dividing the IoT into a multi-layered decentralized network while ensuring the high security and trustworthiness of the blockchain. Pinno et al. [79] proposed a blockchain-based IoT access authorization architecture that ensures the privacy and confidentiality of information collected by IoT devices. The architecture is compatible with many access control models used in the IoT today.
In summary, more and more blockchain technologies are being applied to the Internet of Things (IoT) to solve the privacy and security problems in the IoT. However, a blockchain consumes many resources, and IoT devices generally have little computing power and storage space, so the traditional blockchain is not directly applicable to the IoT.
7.5. Security AI
Thanks to the development of computing power brought about by cloud computing and the generation of many samples in the era of big data, artificial intelligence technology, represented by machine learning, has been developed and used increasingly. However, studies have shown that [80] machine learning models are vulnerable to attacks that lead to privacy leaks, posing privacy and security risks.
Blockchain’s data are highly redundant and decentralized, which is ideal for storing and protecting important privacy data from data loss or privacy leakage caused by attacks or mismanagement of centralized institutions. In recent years, various scholars have researched how blockchain can be applied to AI privacy protection. Zyskind et al. [81] implemented a decentralized personal data management system based on blockchain technology to ensure that users own and control their data. Additionally, they implemented a protocol that turns the blockchain into an automated access control manager that does not require a third party. Chen et al. [82] proposed LearningChain, a decentralized machine learning system for privacy protection and security, and designed a distributed stochastic gradient descent (SGD) algorithm to learn general prediction models. Decentralized SGD uses a differential privacy-based scheme to protect the data privacy of each party. Qi et al. [83] proposed a federated learning framework based on the consortium chains which can achieve secure and reliable federated learning without the need for a central model server. The federated learning framework can effectively protect model data privacy and prevent data poisoning attacks due to the noise-added differential privacy mechanism.
The blockchain can be regarded as a decentralized trusted database, replacing the centralized server to realize the data storage function required for machine learning and avoid privacy and security attacks on the central server.
7.6. Nft
A Non-Fungible Token (NFT) [84] is a token issued according to the Ethereum ERC721 and ERC1155 standards. It has indivisible, irreplaceable, and unique characteristics. Through NFTs, all tokenized properties can be freely traded with customized values based on age, rarity, liquidity, etc. NFT is mainly used for games, artworks, domain names, collectibles, virtual assets, real assets tokenization, and other fields, especially artwork and games that have received great attention in the market. NFT has greatly stimulated the prosperity of the decentralized application market. According to data from the cryptoslam website, as of August 2022, the cumulative transaction volume of NFT has reached $39,245,668,068. Wang et al. [85] conducted systematic research on NFTs for the first time, pointing out that the development of the NFT ecosystem is at an early stage, and related technologies need to be further developed.
7.7. Web 3.0
Web 3.0 is generally considered the next generation of the Internet, a decentralized Internet [86] running on blockchain technology. In this environment, users do not have to create multiple identities on different centralized platforms but can create a decentralized universal digital identity system that can pass through various platforms. The most prominent feature of Web 3.0 is that it can not only realize the exchange of data but also realize the circulation of value [87]. Web 1.0 data are read-only, such as Yahoo and MSN data. Web 2.0 data are read–write interactive, such as Facebook and Twitter data. Web 3.0 data are read–write interactive and owned and controlled by the creator; representative applications include Bitcoin, Ethereum, IPFS, etc. Web 3.0 is a new network infrastructure that integrates the traditional Internet, blockchain, programmable economy, etc. It is currently experiencing a blockchain, and its final architecture is uncertain, but the booming trend is unavoidable.
5layersBeyond Technical AnalysisbitongroupblockchainblockchainanalysisFundamental AnalysislayersPOWweb3

Aynı zamanda::

Feragatname