为广大币圈朋友提供币圈基础入门专业知识!
当前位置首页 > 区块链知识> 正文

区块链分布式共享,区块链的分布式结构可理解为

发布时间:2023-12-06-07:26:00 来源:网络 区块链知识 区块   分布式   共识

区块链分布式共享,区块链的分布式结构可理解为


请查看相关英文文档

Ⅰ What is the consensus mechanism of blockchain?

How to achieve consensus in a decentralized network? In the blockchain system, there is no centralized accounting institution like a bank. It is crucial to ensure the consistency of each transaction on all accounting nodes, that is, to achieve consensus across the entire network. The consensus mechanism solves this problem. At present, the main consensus mechanisms include the proof-of-work mechanism PoW and the proof-of-stake mechanism PoS. PoW determines your probability of obtaining accounting rights by evaluating your workload. The greater the workload, the more likely you are to obtain this accounting opportunity. PoS determines your probability of obtaining accounting rights by evaluating the number and length of time you hold tokens. This is similar to the dividend system of stocks. People who hold relatively large shares can receive more dividends. The principle of DPOS is similar to that of POS, except that some "people's congress representatives" are selected. The main difference from PoS is that nodes elect several agents, who verify and keep accounts. With the development of technology, more advanced consensus mechanisms may be born in the future.

Ⅱ What does blockchain mean? What are the characteristics of blockchain?


Regarding the technology of blockchain, I believe many friends have already paid attention to it. Blockchain It can be said to be a hot topic right now, with news media reporting heavily on it claiming it will create the future. So what does blockchain mean? What are the characteristics of blockchain? Today we will introduce the blockchain to you in detail, and hope that you will have a deep understanding after reading it.
What does blockchain mean?
Blockchain is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithms. The so-called consensus mechanism is a mathematical algorithm that establishes trust and obtains rights and interests between different nodes in the blockchain system.
Blockchain is also an important concept of Bitcoin. The "2014-2016 Global Bitcoin Development Research Report" released by the Internet Finance Laboratory of Tsinghua University PBC School of Finance and Sina Technology mentioned that blockchain is Bitcoin's underlying technology and infrastructure.
Blockchain is essentially a decentralized database and serves as the underlying technology of Bitcoin. The blockchain is a series of data blocks generated using cryptographic methods. Each data block contains information about a Bitcoin network transaction and is used to verify the validity of its information (anti-counterfeiting) and generate the next block.
In a narrow sense, blockchain is a chain data structure that combines data blocks in a sequential manner in chronological order, and is cryptographically guaranteed to be non-tamperable and non-forgeable. Ledger.
Broadly speaking, blockchain technology uses block chain data structures to verify and store data, uses distributed node consensus algorithms to generate and update data, uses cryptography to ensure the security of data transmission and access, and uses A new distributed infrastructure and computing paradigm that uses smart contracts composed of automated script code to program and manipulate data.
What are the characteristics of blockchain?
Through the summary analysis of the blockchain, we getThe characteristics of the blockchain have the following four main points: 1. The first is de-intermediation of trust. This is also repeatedly emphasized. What Songwei and yesterday said is not decentralization but de-intermediation. Change, coincidentally.
2. The second feature is its stability, reliability, and sustainability. Because it is a distributed network architecture, no central node can be hit or attacked, so in the overall technical layout It has stronger stability, reliability and sustainability.
3. Third, its strong security and consensus mechanism do not require the entry of a third party, but are achieved through a technology, a previously scheduled technology to complete the entire transaction.
4. The fourth is the openness, transparency and non-tamperability of transactions. Many practitioners in the industry have shared these characteristics with you, so these are the four characteristics of the blockchain.
Because of these characteristics, blockchain can receive huge attention from many financial institutions and many industries in the future or now.
The above is what the editor brings to you. What does blockchain mean? What are the characteristics of blockchain? of the entire content.

Ⅲ Consensus Mechanism of Blockchain

1. Goal of Blockchain Consensus Mechanism

What is Blockchain? Simply put, blockchain is a decentralized database, or it can be called a distributed ledger. Traditionally, all databases are centralized. For example, a bank's ledger is stored in the bank's central server. The disadvantage of a centralized database is that the security and accuracy of the data depend entirely on the database operator (i.e., the bank), because anyone who has access to the centralized database (such as bank employees or hackers) can destroy or modify the data in it.


Blockchain technology allows databases to be stored on thousands of computers around the world. Everyone’s ledger is synchronized through a peer-to-peer network, and anyone in the network can Once a user adds a transaction, the transaction information will be notified to other users through the network for verification and recorded in their respective ledgers. Blockchain gets its name because it is a data structure composed of blocks containing transaction information linked in an orderly manner from back to front.


Many people’s question about blockchain is that if each user has an independent ledger, does it mean that they can add to their own ledger? Arbitrary transaction information, and how can thousands of ledgers ensure the consistency of accounting? Solving the problem of accounting consistency is the goal of the blockchain consensus mechanism. The blockchain consensus mechanism aims to ensure that the data in all nodes in the distributed system are exactly the same and can reach agreement on a certain proposal (for example, a transaction record). However, due to the introduction of multiple nodes in a distributed system, various very complex situations will occur in the system; as the number of nodes increases, node failure or failure, nodeIt has become a common problem for the network communication between them to be interfered or even blocked. Solving various boundary conditions and unexpected situations in the distributed system also increases the difficulty of solving the distributed consistency problem.


Blockchain can be divided into three types:


Public chain: full Anyone in the world can enter the system at any time to read data, send confirmed transactions, and compete for accounting in the blockchain. Public blockchains are generally considered "completely decentralized" because no one or institution can control or tamper with the reading and writing of data. Public chains generally encourage participants to compete for accounting through a token mechanism to ensure data security.


Alliance chain: Alliance chain refers to a blockchain in which several institutions jointly participate in management. Each institution runs one or more nodes, and the data in it only allows different institutions within the system to read, write and send transactions, and jointly record transaction data. This type of blockchain is considered “partially decentralized.”


Private chain: refers to a blockchain whose write permission is controlled by an organization or institution. The qualifications of participating nodes will be strictly restricted. Since the participating nodes are limited and controllable, private chains can often have extremely fast transaction speeds, better privacy protection, lower transaction costs, and are not prone to malicious attacks. , and can meet the necessary requirements of the financial industry such as identity authentication. Compared with centralized databases, private chains can prevent single nodes within an organization from deliberately concealing or tampering with data. Even if an error occurs, the source can be quickly discovered, so many large financial institutions are currently more inclined to use private chain technology.

2. Classification of blockchain consensus mechanisms

The difficulty of solving distributed consistency problems has given rise to several consensus mechanisms, each of which has its own advantages and disadvantages, and is also suitable for different environment and issues. The consensus mechanisms that are common knowledge include:


l PoW (Proof of Work) workload proof mechanism

l PoS (Proof of Stake) ) Equity/Equity Proof Mechanism

l DPoS (Delegated Proof of Stake) Share Authorization Proof Mechanism

l PBFT (Practical Byzantine Fault Tolerance) Practical Byzantine Fault Tolerance Algorithm

l DBFT (Delegated Byzantine Fault Tolerance) authorized Byzantine fault tolerance algorithm

l SCP (Stellar Consensus Protocol) Stellar Consensus Protocol

l RPCA (Ripple Protocol Consensus Algorithm) Ripple Consensus Algorithm

l Pool Verification Pool Consensus Mechanism


(1) PoW (Proof of Work) proof-of-work mechanism


1. Basic introduction


< /p>

In this mechanism, every node on the network is using the SHA256 hash function to calculate the hash sum of a constantly changing block header. Consensus requires that the calculated value must be equal to or less than a given value. In a distributed network, all participants need to continuously calculate the hash value using different random numbers until the goal is reached. When one node calculates an exact value, all other nodes must confirm with each other that the value is correct. Transactions in new blocks will then be verified to prevent fraud.


In Bitcoin, the above nodes that calculate hash values ​​are called "miners", and the PoW process is called "mining". Mining is a time-consuming process, so incentives have been proposed (such as granting miners a small share of Bitcoin). The advantage of PoW is complete decentralization, but its disadvantage is the waste of resources caused by consuming a lot of computing power, the cycle of reaching consensus is also relatively long, and the consensus efficiency is low, so it is not very suitable for commercial use.



2. Application examples of cryptocurrency


Bitcoin and Litecoin. The first three phases of Ethereum (Frontier, Homestead, and Metropolis) all adopt the PoW mechanism, and its fourth phase (Serenity) will adopt the proof-of-stake mechanism. PoW is suitable for public chains.


Although the PoW mechanism has successfully proved its long-term stability and relative fairness, under the existing framework, using the "mining" form of PoW will consume A lot of energy. The energy it consumes is just to continuously perform SHA256 calculations to ensure fair workload, and has no other meaning of existence. The current transaction efficiency that BTC can achieve is about 5TPS (5 transactions/second). Ethereum is currently subject to the upper limit of the total amount of GAS in a single block, and the transaction frequency that can be achieved is about 25TPS, which is the same as the average thousand times per second., VISA and MASTERCARD, whose peak processing efficiency can reach 10,000 times per second, are far different.


3. Simple diagram understanding mode



(ps: The process of calculating hash values ​​by A, B, C, and D is "mining". In order to reward the time cost, the mechanism will use a certain number of Bitcoins as incentives.)


(Ps: In PoS mode, your "mining" income is proportional to the age of your currency (number of coins * number of days), and has nothing to do with the computing performance of the computer. We can think that the accumulation of any probabilistic events is proof of work, such as gold mining. Assuming that the gold content of ore is p% mass, when you get a certain amount of gold, we can think that you must have dug 1/p mass of ore. And The more gold you get, the more reliable the proof is.)


(2) PoS (Proof of Stake) equity/stake proof mechanism

< p>

1. Basic introduction


PoS requires people to prove their ownership of the currency amount, and they believe that they have more currency people are less likely to attack the network. Selection based on account balance is very unfair, as the single richest person is bound to dominate the network, so many solutions have been proposed.


In the proof-of-stake mechanism, whenever a block is created, miners need to create a transaction called "coin rights", which will be determined according to a certain Proportionately sends some coins to miners in advance. Then the equity proof mechanism reduces the mining difficulty of nodes in equal proportions based on the proportion and time of tokens held by each node (coin age) according to the algorithm, so as to speed up the node's search for random numbers and shorten the time required to reach consensus.


Compared with PoW, PoS can save more energy and be more efficient. But since the mining cost is close to 0, it may be vulnerable to attacks. And PoS still essentially requires nodes in the network to perform mining operations, so it is also difficult to apply in the commercial field.



2. Application examples of digital currency


The more mature digital currencies under the PoS mechanism are Peercoin and NXT. Compared with PoW, the PoS mechanism saves energy and introduces the concept of "Coin Sky"to participate in random operations. The PoS mechanism allows more currency holders to participate in the accounting work without the need to purchase additional equipment (mining machines, graphics cards, etc.). The computing power of each unit token is positively related to the length of time it is held. That is, the more tokens a holder holds and the longer the time, the greater the probability that the holder can sign and produce the next block. Once it signs the next block, the currency days held by the currency holder will be cleared and a new cycle will be re-entered.


PoS is suitable for public chains.


3. How to generate block signers


Under the PoS mechanism, Because the signers of blocks are randomly generated, some currency holders will hold tokens for a long time and in large amounts to obtain a greater probability of generating blocks, and to clear as many of their "coin days" as possible. Therefore, the number of circulating tokens in the entire network will decrease, which is not conducive to the circulation of tokens on the chain, and prices will be more susceptible to fluctuations. Since there may be a small number of large investors holding most of the tokens in the entire network, the entire network may become more and more centralized as the running time increases. Compared with PoW, the cost of doing evil under the PoS mechanism is very low, so for forking or double-spending attacks, more mechanisms are needed to ensure consensus. Under stable conditions, approximately 12 transactions can be generated per second, but due to network delays and consensus issues, it takes about 60 seconds to fully broadcast the consensus block. In the long run, the speed of generating blocks (that is, clearing "coin days") is much lower than the speed of network propagation and broadcasting. Therefore, under the PoS mechanism, it is necessary to "limit the speed" of generated blocks to ensure the stability of the main network. run.


4. Simple diagram understanding mode




(PS: The more “shares” you own, the easier it is for you to obtain account rights. It refers to how much currency you get, which depends on the workload you contribute to mining and the performance of your computer. The better, the more mines will be allocated to you.)


(In a pure POS system, such as NXT, there is no mining process, and the initial equity The distribution has been fixed, and then only the equity is transferred among traders, very similar to stocks in the real world.)


(3) DPoS (Delegated Proof of Stake) ) Share authorization certification mechanism


1. Basic introduction


Due to various disadvantages of PoS , thus the first equity representative of BitSharesThe proof mechanism DPoS (Delegated Proof of Stake) came into being. The core element of the DPoS mechanism is election. Holders of each system's native tokens can participate in elections in the blockchain, and the balance of the tokens they hold is the voting weight. Through voting, shareholders can elect board members and express their attitudes on issues related to the development direction of the platform, all of which form the basis of community autonomy. In addition to voting in elections themselves, shareholders can also vote on their behalf by authorizing their election votes to other accounts they trust.


Specifically, DPoS was invented by the Bitshares project team. Stakeholders elect their representatives to generate and verify blocks. DPoS is similar to a modern corporate board of directors system. The BitShares system calls token holders shareholders, and shareholders vote to elect 101 representatives. These representatives are then responsible for generating and verifying blocks. If a currency holder wants to be called a representative, he must first use his public key to register on the blockchain and obtain a unique 32-bit identity identifier. Shareholders can vote on this identifier in the form of transactions and get votes. The top 101 people were selected as representatives.

Representatives take turns to generate blocks, and the profits (transaction fees) are equally divided. The advantage of DPoS is that it greatly reduces the number of nodes participating in block verification and accounting, thereby shortening the time required for consensus verification and greatly improving transaction efficiency. From a certain perspective, DPoS can be understood as a polycentric system, which has the advantages of both decentralization and centralization. Advantages: It greatly reduces the number of nodes participating in verification and accounting, and can achieve second-level consensus verification. Disadvantages: Voting enthusiasm is not high, and most token holders do not participate in voting; in addition, the entire consensus mechanism still relies on tokens, and many commercial applications do not require the existence of tokens.


The DPoS mechanism requires that before generating the next block, it must be verified that the previous block has been signed by a trusted node. Compared with PoS's "National Mining", DPoS uses a system similar to the "Congress" to directly select trusted nodes, and these trusted nodes (i.e. witnesses) exercise power on behalf of other currency holders. Witnesses Nodes are required to be online for a long time, thus solving a series of problems such as delays in block production that may be caused by PoS block signers not always being online. The DPoS mechanism can usually reach a transaction speed of 10,000 transactions per second, and can reach the level of 100,000 seconds when the network delay is low, which is very suitable for enterprise-level applications. Because Gongxinbao Data Exchange has high requirements for data transaction frequency and long-term stability, DPoS is a very good choice.



2. Institutions and systems under the share authorization certification mechanism


The board of directors is the authority of the blockchain network. The candidates for the board of directors are elected by system shareholders (i.e. currency holders). Board members have the right to Initiate and vote on motions.


One of the important responsibilities of the Board of Directors is to adjust the variable parameters of the system as needed. These parameters include:


l Fee related: rates for various transaction types.

l Authorization related: parameters related to charges and subsidies for third-party platforms that access the network.

l Block production related: block production interval, block reward.

l Identity review related: review and verify the information of abnormal institutional accounts.

l At the same time, matters related to the interests of the Board of Directors will not be set by the Board of Directors.


In the Finchain system, witnesses are responsible for collecting various transactions broadcast when the network is running and packaging them into blocks. Their work is similar to that of the Bitcoin network In the Bitcoin network that adopts PoW (Proof of Work), a lottery method in which the probability of winning depends on the hash power determines which miner node generates the next block. In a financial chain network that adopts the DPoS mechanism, the number of witnesses is determined by voting by the board of directors, and the candidates for the witnesses are determined by voting by currency holders. The selected active witnesses package transactions and produce blocks in order. After each round of block production, the witnesses will randomly shuffle the cards to determine the new order before entering the next round of block production.


3. Application examples of DPoS


Bitshares uses DPoS. DPoS is mainly suitable for alliance chains.


4. Simple diagram understanding mode





(4) PBFT (Practical Byzantine Fault Tolerance) Practical Byzantine Fault Tolerance Algorithm


1. Basic introduction


PBFT is an algorithm based on strict mathematical proof, which requires three stages of information interaction and local consensus to achieve the final unanimous output. The three stages are preparation (pre-prepare), prepare (prepare), implement (commit). The PBFT algorithm proves that as long as there are more than 2/3 normal nodes in the system, it can ensure that a consistent consensus result can be output in the end. In other words, in a system using the PBFT algorithm, it can tolerate no more than 1/3 of the total number of nodes in the system (including nodes that intentionally mislead, intentionally damage the system, time out, repeatedly send messages, forge signatures, etc., also known as " Byzantium" node).



2. Application examples of PBFT


The famous alliance chain Hyperledger Fabric v0.6 uses PBFT, and v1.0 launched an improved version of PBFT, SBFT. PBFT is mainly suitable for private chains and consortium chains.


3. Simple diagram understanding mode




The above figure shows a simplified PBFT protocol communication model, where C is the client, 0 – 3 represents the service node, where 0 is the master node and 3 is the fault node . The basic process of the entire protocol is as follows:


(1) The client sends a request to activate the service operation of the master node;

(2) When the master node receives the request, it starts a three-phase protocol to broadcast the request to each slave node;

(a) Sequence number allocation phase, the master node assigns a sequence number n to the request, broadcasts the sequence number allocation message and the client's request message m, and will construct a pre-prepare message to each slave node;

(b) In the interaction phase, the slave node receives the pre-prepare message and broadcasts the prepare message to other service nodes;

(c) In the sequence number confirmation phase, after each node verifies the request and sequence in the view, it broadcasts the commit message, executes the received client request and responds to the client.

(3) The client waits for responses from different nodes. If m+1 responses are the same, the response is the result of the operation;



p>


(5) DBFT (Delegated Byzantine Fault Tolerance) authorized Byzantine fault tolerance algorithm


1. Basic introduction


DBFT is based on PBFT. In this mechanism, there are two types of participants, one is the "super node" that specializes in accounting, and the other is ordinary people who do not participate in accounting in the system. user. Ordinary users vote for super nodes based on the proportion of their equity holdings. When a consensus (accounting) needs to be passed, a spokesperson is randomly selected among these super nodes to formulate a plan, and then other super nodes use Byzantine fault tolerance to algorithm (see above), that is, the principle of majority submission. If more than 2/3 of the super nodes agree with the speaker plan, a consensus is reached. This proposal becomes the final published block, and the block is irreversible, and all transactions in it are 100% confirmed. If a consensus proposal has not been reached within a certain period of time, or if illegal transactions are discovered, other super nodes can reinitiate the proposal and repeat the voting process until a consensus is reached.



2. Application examples of DBFT


NEO, a domestic cryptocurrency and blockchain platform, is the developer and adopter of the DBFT algorithm.


3. Simple diagram understanding mode




Assume that there are only four super nodes in the system voted by ordinary users. When a consensus needs to be passed, the system will randomly select one of the representatives to speak. People make plans. The spokesperson will hand over the prepared plan to each representative. Each representative will first determine whether the speaker's calculation results are consistent with their own records, and then discuss with other representatives to verify whether the calculation results are correct. If 2/3 of the representatives unanimously agree that the calculation results of the speaker's plan are correct, then the plan is passed.


If less than 2/3 of the representatives reach a consensus, a new speaker will be randomly selected and the above process will be repeated. This system is designed to protect the system from leaders who are unable to function.


The above figure assumes that all nodes are honest and reach 100% consensus, and plan A (block) will be verified.



Given that the spokesperson is a randomly selected representative, he may be dishonest or malfunctioning . The above figure assumes that the spokesperson sends malicious messages to 2 of the 3 representatives (scenario B), and at the same time sends a correct message to 1 representative (scenario A).


In this case the malicious message (scenario B) cannot pass. The calculation results of the representatives in the middle and on the right were inconsistent with those sent by the spokesperson, so they could not verify the plan drawn up by the spokesperson, causing the two people to reject the plan. The representative on the left received correct information that was consistent with his own calculation results, so he was able to confirm the plan and successfully completed a verification. However, this plan still failed to pass because less than 2/3 of the representatives reached a consensus. A new spokesperson will then be randomly selected and the consensus process will begin again.




The above picture assumes that the speaker is honest, but One of the representatives experienced an anomaly; the representative on the right sent incorrect information to the other representatives (B).


In this case, the correct information (A) formulated by the speaker can still be verified, because both the honest representatives on the left and the middle can verify that the correct information (A) formulated by the spokesperson The plan drawn up by the spokesperson reached a 2/3 consensus. The representative can also determine whether the speaker is lying to the node on the right or the node on the right is being dishonest.


(6) SCP (Stellar Consensus Protocol) Stellar Consensus Protocol


1. Basic introduction


SCP is a consensus algorithm developed and used by Stellar (a decentralized global payment protocol based on the Internet). It is based on the Federated Byzantine Agreement ( Federated Byzantine Agreement). Although traditional non-federated Byzantine protocols (such as PBFT and DBFT above) ensure that consensus can be reached through distributed methods and achieve Byzantine fault tolerance (can tolerate at most failed nodes that do not exceed 1/3 of the total number of nodes in the system), it is a Centralized system - The number and identity of nodes in the network must be known and verified in advance. The difference of the Federated Byzantine Agreement is that it can be decentralized and Byzantine fault-tolerant at the same time.


[…]


(7) RPCA (Ripple Protocol Consensus Algorithm) Ripple Consensus algorithm


1. Basic introduction


RPCA is Ripple (an Internet-based An open source payment protocol that can achieve decentralizationConsensus algorithm developed and used (centralized currency exchange, payment and clearing functions). In Ripple's network, transactions are initiated by the client (application) and broadcast to the entire network through the tracking node or validating node. The main function of the tracking node is to distribute transaction information and respond to client ledger requests. In addition to all the functions of the tracking node, the verification node can also add new ledger instance data to the ledger through the consensus protocol.


Ripple's consensus occurs between verification nodes. Each verification node is pre-configured with a list of trusted nodes, called UNL (Unique Node). List). Nodes on the list can vote on the transaction. The consensus process is as follows:


(1) Each verification node will continuously receive transactions sent from the network. After verification with the local ledger data, they are illegal. The transactions will be discarded directly, and the legal transactions will be summarized into a transaction candidate set (candidate set). The transaction candidate set also includes transactions left over from the previous consensus process that could not be confirmed.

(2) Each verification node sends its own transaction candidate set as a proposal to other verification nodes.

(3) After the verification node receives a proposal from other nodes, if it is not from a node on UNL, it will ignore the proposal; if it is from a node on UNL, it will compare it with the proposal. Transaction and local transaction candidate set, if there is the same transaction, the transaction gets one vote. Within a certain period of time, when a transaction receives more than 50% of the votes, the transaction enters the next round. Transactions that do not exceed 50% will be left for the next consensus process to be confirmed.

(4) The verification node sends transactions with more than 50% of the votes as proposals to other nodes, and at the same time increases the threshold of the required votes to 60%, repeating steps (3) and (4) until the threshold Reach 80%.

(5) The verification node formally writes the transactions confirmed by 80% UNL nodes into the local ledger data, which is called the last closed ledger, which is the last (latest) status of the ledger.


In Ripple's consensus algorithm, the identities of participating voting nodes are known in advance. Therefore, the algorithm is more efficient than anonymous consensus algorithms such as PoW. Transactions The confirmation time only takes a few seconds. This also determines that the consensus algorithm is only suitable for alliance chains or private chains. The Byzantine Fault Tolerance (BFT) capability of the Ripple consensus algorithm is (n-1)/5, which means it can tolerate Byzantine errors in 20% of the nodes in the entire network without affecting the correct consensus.



2. Simple diagram understanding model


Consensus Schematic diagram of process node interaction:



Consensus algorithm process:


< /p>


(8) POOL verification pool consensus mechanism


The Pool verification pool consensus mechanism is based on A mechanism developed based on traditional distributed consensus algorithms (Paxos and Raft). The Paxos algorithm is a consensus algorithm based on message passing and highly fault-tolerant proposed in 1990. In the past, Paxos has been the standard for distributed protocols, but Paxos is difficult to understand and even more difficult to implement. Raft is a consensus algorithm released in 2013 that is simpler than Paxos and can realize the problems solved by Paxos. The process of reaching consensus in Paxos and Raft is like an election. Candidates need to convince the majority of voters (servers) to vote for them and follow their actions once selected. The difference between Paxos and Raft lies in the specific process of election. The Pool verification pool consensus mechanism is based on these two mature distributed consensus algorithms, supplemented by a data verification mechanism.






IV What is the concept of blockchain? What exactly is blockchain? Read it in three minutes!

On October 25, 2019, Xinwen Broadcast sent a very important signal: the country must vigorously develop blockchain. After that, blockchain has become an Internet celebrity, and the figure of "blockchain" is floating in the streets and alleys. In fact, many technology companies have already deployed blockchain technology.

Although blockchain is very popular, many people do not know much about blockchain.

What is blockchain?

Let’s first take a look at how Du Niang explained it. Network display: Blockchain is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithms.

Why is blockchain called blockchain?

The blockchain is linked by blocks one by one, and the blocks are storage units one by one, which record the communication information of each block node. The blocks are much like the records of the database. times writtenEntering data means creating a block. With the expansion of information exchange, one block continues with another, and the result is called a blockchain.

What are the characteristics of blockchain?

Blockchain mainly has the following characteristics:

1. Decentralization: In the blockchain system, every node has equal rights. and obligations, there is no central control here. Decentralization has well established trust relationships with each other. Although there is no central management organization, people can collaborate with each other and trust each other. This mainly applies blockchain distributed ledger technology.

2. Openness: Blockchain data is open to everyone. Except for some encrypted information that is not open, everyone can check the data here.

3. Independence: The entire blockchain system does not rely on other third parties. All nodes can automatically and securely verify and exchange data within the system without any human intervention.

4. Security: Blockchain has a certain degree of security and cannot be tampered with. Because everyone in the blockchain system has the same ledger, if someone wants to tamper with it, it is possible to forge a non-existent record only if they control more than 51% of the accounting nodes. Of course, this is basically impossible. This is mainly due to the core technology of the blockchain: the consensus mechanism. The consensus mechanism has the characteristics of "the minority obeys the majority" and "everyone is equal".

5. Anonymity: Many people think that if the blockchain is so open and transparent, will we lose privacy? In fact, no, although the transaction information in the blockchain is open and transparent, the identity information of the account is encrypted and can only be accessed with authorization.

Now let me tell you a story to help you better understand the blockchain.

There are three people in the family, mom, dad, older brother and younger brother. Last year, my father was in charge of the family's account books. He was responsible for all the family's income and expenses alone.

However, on the day of Double Eleven, my mother, who has always been frugal, wanted to buy herself a beautiful piece of clothing on a certain online store. When she checked the account book, she found something was wrong. It stands to reason that except for some money deposited in banks and financial management, the whereabouts of the daily consumption money at home are all in this account book, but no matter how you look at it, it is wrong. Some consumption is clearly not recorded, but is recorded.

Later, my father took the initiative to confess that he couldn’t help but buy a pack of cigarettes.

Later, my mother changed her strategy and the whole family kept accounts. Everyone recorded their monthly consumption expenditure in their own account books. Whenever there was a transaction or consumption at home, my mother would shout, "Book it," and everyone would record the transaction in their own books. That's itIn the centralized accounting model, everyone is the center and everyone has a ledger.

The previous accounting model for dad was centralized accounting. If dad wanted to do something alone, it would be difficult for anyone to see it. The decentralized accounting model has solved the problem of centralization very well. The disadvantage of bookkeeping is that it is very difficult for dad to tamper with the books.

For example, if dad wants to take some money from the ledger and secretly buy cigarettes, the amount of money is limited, and if he wants to take the money, he has to change the ledger, but he only tampered with his own ledger. No, he had to change the accounts of three people including himself. And this is undoubtedly more difficult than reaching the sky.

So, many times my father had the idea of ​​smoking, but he had no choice but to give up the idea due to the current situation.

Are blockchain and Bitcoin the same thing?

In fact, blockchain and Bitcoin are not the same thing. It is just the underlying technology of Bitcoin. Bitcoin is the first digital currency applied by blockchain.

In 2008, Satoshi Nakamoto first proposed the concept of blockchain. In the following years, it became a core component of the electronic currency Bitcoin, serving as a public account book for all transactions. Blockchain was first applied to Bitcoin.

The origin of blockchain is to solve the problem of trust, and one of the most successful applications of blockchain is digital currency. Bitcoin is arguably the most successful application of blockchain so far.

What are the applications of blockchain?

The application of blockchain is actually very wide. In addition to digital currency, the future applications of Bitcoin are still very extensive. Blockchain technology has been widely used in different industries. Such as product traceability, copyright protection and transactions, payment and settlement, Internet of Things, digital marketing, medical care, etc., promoting different industries to quickly enter the "blockchain+" era.

1. Payment and clearing: Blockchain can abandon the role of transit banks, realize point-to-point payment, reduce transit fees, and accelerate fund utilization.

2. Product traceability: For example, if we buy a piece of clothing on a certain store, we can see the past and present life of this piece of clothing.

3. Securities trading: Traditional securities trading requires the coordination of four major institutions, which is inefficient and costly. Blockchain technology can independently complete one-stop services.

4. Supply chain: Introducing blockchain technology into the supply chain system, synchronizing information within the system can control all links, better complete division of labor and collaboration, and facilitate subsequent accountability.

5. Intellectual property rights: With copyright on the chain, our photographic works, musical works, literary works, etc. will become our information, and the ownership of the information will be confirmed and become our property.

IV BlockchainTechnical concept

Blockchain technology concept

Blockchain technology concept. Nowadays, blockchain has become an area of ​​concern to most people, and many companies have already studied it in depth. Technical situation, but there are still people who don’t know much about it. Below I will share an article about the concept of blockchain technology.

Blockchain technology concept 1

Basic concepts and working principles of blockchain

1. Basic concepts

Blockchain is a distributed data storage, point-to-point New application models of computer technologies such as transmission, consensus mechanisms, and encryption algorithms. The so-called consensus mechanism is a mathematical algorithm that establishes trust and obtains rights and interests between different nodes in the blockchain system.

Blockchain is an important concept of Bitcoin. It is essentially a decentralized database and serves as the underlying technology of Bitcoin. The blockchain is a series of data blocks generated using cryptographic methods. Each data block contains information about a Bitcoin network transaction, which is used to verify the validity of the information, prevent counterfeiting, and generate the next block.

In a narrow sense, blockchain is a chained data structure that combines data blocks in a sequential manner in chronological order, and is cryptographically guaranteed to be non-tamperable and non-tamperable. Fake distributed ledger.

Broadly speaking, blockchain technology uses block chain data structures to verify and store data, uses distributed node consensus algorithms to generate and update data, and uses cryptography to ensure data transmission and access. It is a new distributed infrastructure and computing method that uses smart contracts composed of automated script codes to program and operate data securely.

2. Working principle

The blockchain system consists of data layer, network layer, consensus layer, incentive layer, contract layer and application layer. Among them, the data layer encapsulates the underlying data blocks and related basic data and basic algorithms such as data encryption and timestamps; the network layer includes distributed networking mechanisms, data dissemination mechanisms, and data verification mechanisms; the consensus layer mainly encapsulates network nodes Various consensus algorithms; the incentive layer integrates economic factors into the blockchain technology system, mainly including the issuance mechanism and distribution mechanism of economic incentives; the contract layer mainly encapsulates various scripts, algorithms and smart contracts, and is the core of the blockchain The basis of programmable features; the application layer encapsulates various application scenarios and cases of the blockchain. In this model, the chain block structure based on timestamps, the consensus mechanism of distributed nodes, economic incentives based on consensus computing power, and flexible programmable smart contracts are the most representative innovations of blockchain technology.

Blockchain mainly solves the trust and security issues of transactions, so it proposes four technological innovations to address this issue:

1. Distributed The ledger is a transaction accounting system distributed in different places.Multiple nodes of the party complete it together, and each node records a complete account, so they can all participate in supervising the legality of the transaction and can also jointly testify for it.

Different from traditional distributed storage, the uniqueness of blockchain distributed storage is mainly reflected in two aspects: First, each node of the blockchain stores complete data according to the block chain structure. For data, traditional distributed storage generally divides the data into multiple parts for storage according to certain rules. Second, the storage of each node in the blockchain is independent and of equal status, relying on the consensus mechanism to ensure storage consistency, while traditional distributed storage generally synchronizes data to other backup nodes through the central node. [8]

No node can record ledger data independently, thus avoiding the possibility of a single bookkeeper being controlled or bribed to record false accounts. Also because there are enough accounting nodes, theoretically speaking, the accounts will not be lost unless all nodes are destroyed, thereby ensuring the security of the accounting data.

2. Asymmetric encryption and authorization technology. Transaction information stored on the blockchain is public, but account identity information is highly encrypted and can only be accessed with authorization from the data owner. , thus ensuring data security and personal privacy.

3. The consensus mechanism is how all accounting nodes reach a consensus to determine the validity of a record. This is both a means of identification and a means of preventing tampering. Blockchain proposes four different consensus mechanisms, which are suitable for different application scenarios and strike a balance between efficiency and security.

The consensus mechanism of the blockchain has the characteristics of "the minority obeys the majority" and "everyone is equal". "The minority obeys the majority" does not entirely refer to the number of nodes, but can also be the computing power and the number of shares. Or other characteristic quantities that the computer can compare. "Everyone is equal" means that when a node meets the conditions, all nodes have the right to give priority to the consensus result, which will be directly recognized by other nodes and may eventually become the final consensus result. Taking Bitcoin as an example, it uses proof of work. Only when more than 51% of the accounting nodes in the entire network are controlled, it is possible to forge a non-existent record. When there are enough nodes joining the blockchain, this is basically impossible, thus eliminating the possibility of fraud.

4. Smart contracts. Smart contracts are based on these trustworthy and non-tamperable data. Some predefined rules and terms can be automatically executed. Take insurance as an example. If everyone's information, including medical information and risk occurrence information, is true and trustworthy, it will be easy to implement automated claims settlement in some standardized insurance products.

3. Others

The Internet exchanges information, and the blockchain exchanges value. The history of human beings and the history of the Internet can be understood in eight words: if they are separated for a long time, they must be reunited; if they are separated for a long time, they must be reunited. In the era of long-term separation, all network information is scattered on the Internet.It is not easy to mine information. At this time, platforms such as Google and Facebook will appear. The only thing they do is to reorganize all our information. In the Internet era, what the monopoly giants reorganize is information, rather than generating their own information. The information generated is entirely our own. Once the information is reorganized, a new monopoly giant will emerge, so it will be an era of long-lasting separation. Now, due to the emergence of blockchain technology, it has entered an era of integration and division. It is a new multi-centralization. After the new multi-centralization, new value will be generated. These data will be in our own hands, and personal data will generate value. It belongs to oneself. This is the most exciting era of this era.

What is the value of blockchain? A low-cost mechanism to establish trust, establish data rights, and resolve data property rights.

At present, blockchain technology continues to develop, including the current development of single chains to multi-chains, and the technology can be further expanded. I think there may still be disruptions in the future, especially in transactions and other aspects. , especially many disruptive scenarios for existing industries.

The essence of blockchain is to establish trusted information exchange on untrustworthy networks.

One Belt, One Road + One Chain. The bigger thing about blockchain is not to create trust, but to allow trust to be transmitted losslessly, reducing the friction cost of society as a whole, thereby improving the overall efficiency.

Now the blockchain itself is still in its initial stage, so it includes the information transmission and encryption of the blockchain. Quantum encryption and other encryption appear in this process, which actually attacks the encryption algorithm used by the blockchain itself. This phenomenon also occurs from time to time. Including blockchain is also a recognition of assets, a recognition of digital assets, but now many of us use cryptographic algorithms, or as the key for us to decrypt, but if you forget the password, it is very likely that your current assets will be lost. If you lose them, you won't be able to get back your original assets. Therefore, there are still some hidden dangers in asset management, including information transmission and some security aspects. Of course, from a technical perspective, the processing speed of our blockchain itself, or its scalability, is because from the perspective of the working mechanism, the entire ledger must be copied to all participants, so in the blockchain Its operational efficiency and scalability are still relatively limited. We feel that these still need further development in terms of technology.

The underlying technologies of the blockchain platform also form blockchain wallets, blockchain browsers, node elections, mining machines, mining pools, development components, development modules, technical communities and project communities. and a series of ecosystems. The perfection of these ecosystems directly determines the efficiency and effectiveness of the underlying platform of the blockchain.

4. Mundell’s Impossible Triangle

It is impossible to achieve the ultimate in decentralization, efficiency, and security at the same time.

Blockchain technology concept 2

The essence of blockchain is a distributed accounting technology, andThe opposite is centralized accounting technology, which is widely used in our current lives. Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.

Blockchain is an important concept of Bitcoin. It is essentially a decentralized database. At the same time, as the underlying technology of Bitcoin, it is a series of related cryptographic methods. Each data block contains a batch of Bitcoin network transaction information, which is used to verify the validity and anti-counterfeiting of the information and generate the next block.

In a narrow sense, blockchain is a chained data structure that combines data blocks in a sequential manner in chronological order, and is cryptographically guaranteed to be non-tamperable and non-tamperable. Fake distributed ledger.

Broadly speaking, blockchain technology uses block chain data structures to verify and store data, uses distributed node consensus algorithms to generate and update data, and uses cryptography to ensure data transmission and access. It is a new distributed infrastructure and computing method that uses smart contracts composed of automated script codes to program and operate data securely.

The popular understanding of blockchain technology is: connecting the front, back, left and right blocks of "things" into a chain using one technology, but each block The original data of the block cannot be tampered with. It is a "linked module" technology in the field of Internet of Things that allows participants to trust. The application of blockchain technology is inseparable from the Internet and the Internet of Things. It is based on the integration and interaction of the two, but allows participants to remain independent, decentralized, and work together. With this set of value chain co-construction and sharing, technology.

Characteristics of blockchain: decentralization, openness, autonomy, information cannot be tampered with, and anonymity.

Blockchain is a network that can deliver value. The demand for a network that can deliver value is an important reason for the emergence of blockchain technology. Blockchain emerged driven by the need to protect information with ownership or other value. Through public and private key cryptography, distributed storage and other technical means, blockchain ensures on the one hand the efficient transmission of valuable information, and on the other hand ensures that this information will not be easily copied and tampered with during the transmission process.

Understand the connotation of blockchain from the inevitability of its birth. Blockchain is a distributed accounting technology that solves the shortcomings of centralized accounting and solves the problem of distributed consistency. It is also The connected Internet is upgraded to a value network that ensures the safe and efficient transmission of valuable information.

Blockchain Technology Concept 3

Blockchain: Blockchain is like a globally unique account book, or database, which records the history of all transactions in the network.

Ethereum Virtual Machine (EVM): It allows you to write more powerful programs on Ethereum. You can also write scripts on Bitcoin.sequence,. It is also sometimes used to refer to the Ethereum blockchain, which is responsible for executing smart contracts and everything.

Node: You can run a node to read and write to the Ethereum blockchain, that is, using the Ethereum Virtual Machine. Full nodes require downloading the entire blockchain. Light nodes are still under development.

Miner: Mining, that is, the node that processes blocks on the blockchain. You can see some of the currently active Ethereum miners on this page: stats.ethdev.com.

Proof of Work: Miners are always competing to solve some mathematical problem. The first one to solve the problem (calculate the next block) will be rewarded with Ether coins. All nodes then update their own blockchain. All miners who want to figure out the next block have an incentive to stay in sync with other nodes and maintain the same blockchain, so the entire network can always reach consensus. (Note: Ethereum is planning to move to a proof-of-stake system (POS) without miners, but that is outside the scope of this article.)

Ethereum: Abbreviation ETH. A true digital currency that you can buy and use. Here is a chart from one of the exchanges where Ethereum can be traded. At the time of writing, 1 Ether is worth 65 cents.

Gas: Executing programs and saving data on Ethereum consumes a certain amount of Ethereum. Gas is converted from Ethereum. This mechanism is used to ensure efficiency.

DApp: The Ethereum community calls applications based on smart contracts decentralized applications (Decentralized App). The goal of DApp is (or should be) to have a friendly interface for your smart contracts, plus some extras, such as IPFS, a decentralized network that can store and read data, not from the Ethereum team but in a similar spirit ). DApp can run on a centralized server that can interact with Ethereum nodes, or it can run on any Ethereum equal node. (Take a minute to think about this: Unlike ordinary websites, DApps cannot run on ordinary servers. They need to submit transactions to the blockchain and read important data from the blockchain rather than a centralized database. Compared to typical users When logging into the system, the user may be represented as a wallet address and other user data is stored locally. Many things will be structured differently from current web applications.)

Ethereum client, smart contract language

p>

Writing and deploying smart contracts does not require you to run an Ethereum node. Browser-based IDEs and APIs are listed below. But if you are just learning, you should still run an Ethereum node to understand the basic components, and running a node is not difficult.

Clients available for running Ethereum nodes

Ethereum has many client implementations in different languages ​​that interact with the Ethereum network.Interoperable methods, including C++, Go, Python, Java, Haskell, etc. Why do we need so many implementations? Different implementations can meet different needs. For example, the goal of Haskell implementation is to be mathematically verifiable, to make Ethereum more secure, and to enrich the entire ecosystem.

At the time of writing this article, I am using the client geth (go-ethereum) implemented in the Go language. At other times, I also use a tool called testrpc, which uses the Python client pyethereum. Later examples will use these tools.

About mining: Mining is fun, a bit like caring for your houseplant, but also a way to learn about the entire system. Although the current price of Ethereum may not even cover the electricity bill, who knows in the future. People are creating many cool DApps that may make Ethereum more and more popular.

Interactive console: Once the client is running, you can synchronize the blockchain, create a wallet, and send and receive Ethereum. One way to use geth is through the Javascript console. In addition, you can use cURL-like commands to interact with the client through JSON RPC. The goal of this article is to take you through the process of DApp development, so I won’t go into details about this. But we should remember that these command line tools are useful for debugging, configuring nodes, and using wallets.

Running the node on the test network: If you run the geth client on the official network, it will take quite a while to download the entire blockchain and synchronize with the network. You can determine if synchronization has occurred by comparing the last block number printed in the node logs with the latest block listed on stats.ethdev.com. ) Another problem is that running smart contracts on the official network requires real Ethereum. Running the node on the test network does not have this problem. At this time, there is no need to synchronize the entire blockchain. Just create your own private chain, which saves time for development.

Testrpc: Use geth to create a test network. Another faster way to create a test network is to use testrpc. Testrpc can help you create a bunch of test accounts with funds at startup. It also runs faster and is therefore better suited for development and testing. You can start with testrpc, and then as the contract slowly takes shape, move to the test network created by geth - the startup method is very simple, you only need to specify a networkid: geth --networkid "12345". Here is the code repository for testrpc, we will talk about it again below.

Next, let’s talk about the available programming languages, and then we can start the real programming. Solidity is the programming language used to write smart contracts.

There are several languages ​​to choose from when writing smart contracts: Solidity, which is somewhat similar to Javascript, has a file extension of .sol. Serpent, which is similar to Python, has a file name ending in .se. There is also a Lisp-like LLL. Serpent has been popular for a while, but now the most popular and stable one is Solidity, so just use Solidity. I heard you like Python? Use Solidity.

solc compiler: After writing the smart contract with Solidity, you need to use solc to compile it. It is a component from a C++ client implementation. Again, different implementations complement each other. Here is how to install it. If you don't want to install solc, you can also use a browser-based compiler, such as Solidity real-time compiler or Cosmo. The programming sections below will assume you have solc installed.

web3.js API. After the Solidity contract is compiled and sent to the network, you can use Ethereum's web3.js JavaScript API to call it and build web applications that can interact with it.

VI What is the consensus mechanism in blockchain technology

1. What is the consensus mechanism
In a decentralized structural system, due to the The status is equal. When disagreements arise, how to reach consensus becomes a problem.
Therefore, a consensus mechanism that is exquisitely designed and simple to operate is the key to the smooth operation of a distributed system.
In short, the consensus mechanism is an algorithm that reaches consensus on the order of things within a period of time. It is a mechanism for blockchain nodes to reach a consensus across the entire network on block information.

博客主人唯心底涂
男,单身,无聊上班族,闲着没事喜欢研究股票,无时无刻分享股票入门基础知识,资深技术宅。
  • 36655 文章总数
  • 3637265访问次数
  • 3078建站天数