Blockchain - 20220330

Writing bugs 2022-04-05 00:33:02 阅读数:794



Use the magic to seize the nature , One mind is better than nature's work .

Blockchain concept

  • Blockchain can be borrowed from cryptography , concatenated And protect serial transactions of content ( Also known as block ).
  • In blockchain , Block content has Difficult to tamper with Characteristics of , Each block contains the encrypted hash of the previous block 、 Corresponding time stamp and transaction data ( Usually use Hash The hash value of tree computation represents ).
  • Connected in series with blockchain Distributed ledger Enables both parties to effectively record transactions , And Permanent inspection .
  • Blockchain is Decentralized distributed ledger

Composition of blockchain system

Blockchain system consists of The data layer 、 The network layer 、 Consensus layer 、 layer 、 Contract layer and application layer form


  • first floor : The data layer , Store the underlying data 、 Asymmetric data encryption And time stamps and other basic data .

  • The second floor : The network layer , Including distributed networking mechanism 、 Data dissemination mechanism 、 Data verification mechanism, etc .

  • The third level : Consensus layer , There are all kinds of consensus mechanism algorithms encapsulated , Determine how bookkeeping is determined , It's about The safety and reliability of the whole system . At present, there are well-known consensus encapsulation mechanisms workload Proof mechanism (PoW,Proof of Work)、 Share authorization certification mechanism (DPoS,Delegated Proof of Stake)、 Proof mechanism of rights and interests (PoS,Proof of Stake) etc. .

  • The fourth level : layer , The economic means used in the blockchain technology system , Including the development of economic incentives Rows and assignments , Most of them appear in the public chain .

  • The fifth floor : Contract layer , Encapsulating script code in blockchain system 、 Algorithms and smart contracts , help Blockchain handles data flexibly .

  • The sixth floor : application layer , It encapsulates various application scenarios and cases , E-commerce shopping 、 News browsing 、 Video watching, etc .

Features of blockchain

Storage structure : block — chain

  • Distributed fault tolerance : Distributed network Extremely robust , It can tolerate the abnormal state of some nodes ;

  • Non tamperability : Consistently submitted data will always exist , Cannot be destroyed or modified ;

  • Privacy protection : Cryptography guarantees data privacy , Even if the data leaks , Can't parse .

    The resulting business may include the following features :

    • Trustworthiness and willfulness : Blockchain technology can provide a natural and reliable distributed ledger platform , No additional third parties are required Agency involvement
    • cost reduction : Compared with traditional technology , Blockchain technology may take time 、 Less labor and maintenance costs
    • Enhance security : Blockchain technology will be conducive to security 、 Reliable audit management and account settlement , Reduce the risk of crime

Blockchain definition

  • Recognized as the earliest (2008 year 10 month 31 Japan ) The descriptive literature on blockchain is Nakamoto Articles written : The currency ( Bitcoin) Design white paper 《 Bitcoin : A Peer-to Peer Electronic Cach System 》, Point out in it : Blockchain is a data structure used to record the history of bitcoin transaction accounts
  • Wikipedia In the definition given above , Compare blockchain to a kind of Distributed database technology , Through maintenance Data blocks Of The chain structure , Can sustain Keep growing Of 、 No tampering Data record of .

The currency (Bitcoin): Safe and reliable decentralized digital currency mechanism

The basic principles of blockchain

Blockchain does not introduce third-party intermediaries , Can provide decentralization 、 No tampering 、 Safety and reliability are guaranteed .

Blockchain includes Three basic concepts

  1. transaction (transaction): An operation on the ledger , Cause a change in the status of the ledger , If you add a transfer record .
  2. block ( block): Record all transactions and status results over a period of time , It is a consensus on the current ledger status .
  3. chain (chain): The blocks are connected in series according to the sequence of occurrence , It is a log record of changes in the status of the whole ledger .

If we take blockchain as a state machine , Then every transaction is an attempt to change the State , And every time consensus is generated Block of , That is, the participants confirm the result of the state change caused by the transaction in the block .

On the implementation , First, suppose there is a Distributed Data record ledger , This ledger Only... Can be added 、 Deletion is not allowed . The basic structure at the bottom of the ledger is a Linear linked list , This is also its name “ Blockchain ” To dig . The linked list consists of all **“ block ” Series connection form ( Pictured 2-1 Shown ), The following block records the hash value of the leading block ( pre hash ) . New data to be added , Must be placed in a new block . And this piece ( And the transactions in the block ) Is it legal , Can pass Calculation Hash value The way to quickly test out . Any maintenance node Can propose a new legal block , However, it must go through a certain Consensus mechanism ** To reach an agreement on the final selected block .

 Example of blockchain structure

Take bitcoin as an example to understand the working process of blockchain

Take the bitcoin network as an example , You can see how blockchain technology is used .

  • First , Bitcoin client initiates a transaction , radio broadcast Go to the bitcoin network and wait for confirmation . Nodes in the network will Package some received transactions waiting for confirmation ( In addition, it also includes Previous Information such as hash value of block header ), Form a Candidate Block . then , Trying to find a nonce strand ( Random string ) Put it in the block , Make the candidate area Hash result of block Meet certain conditions ( For example, less than a certain value ). This nonce The search of the string takes some time to calculate and try .

  • Once the node is calculated Meet the conditions Of nonce strand , The format of this block is Think it's “ legal ” 了 , Can be To try to broadcast it over the network . Other nodes receive candidate blocks , To verify , It is found that the agreed conditions are indeed met 了 , Just admit that this block is a legal new block , And add it to the blockchain you maintain . When Most nodes When you add blocks to the blockchain structure you maintain , The The block is accepted by the network , Included in the block transaction It's just To be confirmed .

  • Bitcoin's search is based on computing power nonce List of Consensus mechanism be called Proof of workload ( Proof of Work , PoW )*** . at present , To make the hash result meet certain conditions , There are no known fast Heuristics , Only tentative Calculation of violence *. The more times you try ( More work ), The greater the probability .

By adjusting the restrictions on Hash results , The average bitcoin network control is about 10 Minutes to generate a legal block . Work out The nodes of the block will receive the management fee of all transactions in the block and the reward fee fixed by the agreement ( At present, it is 12.5 The currency , Half every four years ), This The process of calculating new blocks is commonly known as dig

Evolution and classification of technology

Blockchain technology has been explored and concerned by everyone since the design of bitcoin network , From the initial service of the digital currency system , Today, in the distributed ledger scenario, it is playing a greater and greater technical potential .

Evolution of blockchain

The currency Blockchain already supports Simple script calculation , But only Digital currency Related treatment . In addition to supporting digital currency , The processing process executed on the blockchain can also be further generalized , I.e Intelligent contract ( smart contract ) . Smart contract can provide more flexible contract functions besides currency trading function , Perform more complex operations .

 Three typical evolution scenarios of blockchain technology

Blockchain and distributed accounting

Modern double entry bookkeeping system ( double entry bookkeeping) By Italian mathematician Luca · Pacio is good for 1494 In 《 Summa de arithmetica, geometrica, proportioni et proportionali ta 》 First formulated in a Book . complex Bookkeeping records the source and destination of each account at the same time , The reconciliation verification function is introduced into the bookkeeping process for the first time , Improve the reliability of the accounting process .

From this point of view , Blockchain is the first digital accounting technology with reconciliation function .

  • Look more broadly at , Blockchain is a kind of De centralization Recording technology
  • Nodes participating in the system , May not belong to the same organization , There is no need to trust each other
  • Blockchain data is generated by All nodes maintain together , Each maintenance node can be copied to obtain A copy of a complete or partial record

Compared with the traditional accounting technology , The blockchain based distributed ledger should include the following features :

  • Maintain one Growing chain , only Probably Add records , And the records of what happened No tampering
  • De centralization , Or polycentrism , Consensus can be reached without centralized control , Try to use Distributed
  • adopt cryptography A mechanism to ensure that transactions cannot be denied and destroyed
  • As far as possible Protect the privacy of user information and records


Depending on the participants , It can be divided into public (public) chain 、 union (consortium) Chain and private (private) chain

  • The chain of public : seeing the name of a thing one thinks of its function , Anyone can participate in the use and maintenance of , Such as The currency Blockchain , Information is Completely open Of ;
  • If further introduced Licensing mechanism , Private chain and alliance chain can be realized :
    • The chain of private : Managed by a centralized manager , Only a few people inside can use , Information is not public
    • League chain : Between the two , Several organizations work together to maintain a blockchain , The use of the blockchain must Must be With permission Of Limit access to , Relevant information will be protected , Such as Supply chain institutions or banking alliances

according to Use purpose and scenario Different , It can also be divided into Digital currency For the purpose of Currency chain , With Record property rights by Purposeful Property right chain , With For the purpose of crowdfunding Of Crowdfunding chain etc. , There are also applications that are not limited to specific scenarios General chain .

Most existing blockchain implementations include at least The network layer 、 Consensus layer 、 Smart contract and application layer Isostructure , The realization of alliance chain often introduces certain Authority management mechanism


Blockchain is mainly applied in

financial service :

Blockchain technology can provide... For financial services It works 、 Credible proof of ownership , as well as A fairly reliable contract assurance mechanism .

The potential advantages of blockchain include Reduce transaction costs 、 Reduce the risk of cross organizational transactions etc. . The Blockchain applications in the field are currently the most concerned , Many banks and financial trading institutions around the world are the main promoters . Some investment institutions are also applying blockchain technology to reduce management costs and control risks . On the other hand , it is to be noted that Possible problems and risks .

for example , DA08 Such crowdfunding experiments , Remind users to be cautious at both business and operational levels ;

Credit investigation and ownership management :

The digital management of credit investigation and ownership is the dream of large social platforms and insurance companies .

At present, the main technical problems in this field include the lack of sufficient data and analysis capacity ; Lack of reliable platform Support and effective data integration management .

Blockchain is considered to facilitate data trading and flow , Provide Safe and reliable Support for . The threshold of credit investigation industry is relatively high , We need multiple resources to jointly promote ;

Resource sharing :

With Airbnb Companies represented by sharing economy will welcome decentralized applications , Sure Reduce management costs .

The topics in this field are relatively concentrated , Large design space , Attracted a lot of investment attention ;

Trade management :

Blockchain technology can help Automated International Trade and Logistics supply chain Cumbersome procedures and processes in the field .

The trade management scheme designed based on blockchain will bring benefits to the participating multi-party enterprises Great convenience .

in addition , Digitization of sales and legal contracts in trade Cargo monitoring and inspection Real time payment And other directions may become a breakthrough for start-ups ;

The Internet of things :

The Internet of things is the foundation of the era of big data , Blockchain technology is the foundation of the Internet of things era

The Internet of things is also a field suitable for the application of blockchain technology , It is expected that there will be a large number of Applications appear , especially lease 、 logistics And so on , They are all suitable scenarios for combining blockchain Technology .

But at this stage , Due to the technical limitations of the Internet of things, large-scale applications will not appear in the short term .

ACID principle

ACID Principle means : Atomicity ( Atomicity )、 Consistency ( Uniformity )、 Isolation ( Isolation, )、 Durability ( persistence ), Abbreviations for four features are used .

ACID It is also a well-known principle of description consistency , Usually occurs in Distributed database field .

say concretely , ACID The principle describes Distributed database Consistency needs to be met , At the same time, it allows you to pay the price of availability .

ACID The features are as follows :

  • Atomicity: Each operation is Atomic , Or success , Or not ;
  • Consistency: Database The state is consistent , No intermediate state ;
  • Isolation: Various operations are connected with each other Don't affect each other ;
  • Durability: state The change is lasting , It won't fail .

The currency -BitCoin

The currency ( BitCoin , BTC) It's based on blockchain technology A kind of . Digital currency realizes , Bitcoin network is the first large-scale network in history 、 A long tested digital money system .

Bring your own trust 、 Distributed bitcoin tamper proof accounting network

Bitcoin network has the following features in function :

  • De centralization : It means that no independent individual can destroy transactions in the network , Any transaction request requires The consensus of most participants ;
  • anonymity : The account address in bitcoin network is anonymous , Unable to associate from transaction information to specific individuals , But it also means It's hard to audit ;
  • Inflation prevention : Calculate by issuing bitcoin , Circulation is halved every four years , Total cap by 2100 over , Can't be overloaded .

Bitcoin principle and design

Bitcoin network is a Distributed point-to-point The Internet , Miners in the network through “ dig ” To complete the transaction record Record the bookkeeping process , Maintain the normal operation of the network .

Provide a blockchain Publicly visible bookkeeping , This book does not record the balance of each account , It's about using To record the historical information of transactions that have occurred . This design can avoid replay attack , That is, a legal transaction is re sent many times, causing an attack .

The etheric fang -Ethereum

** The etheric fang ( Ethereum)** The initial goal of the project is to create a Intelligent contract The platform of ( Platform for Smart Contract), The platform supports Turing's complete application , According to the agreed logic of smart contract Automatic execution , Ideally, there will be no fault shutdown 、 review 、 cheat , And third-party intervention .

Ethereum platform currently supports Golang、 C++、 Python And other clients implemented in multiple languages . Because of its core implementation yes Based on bitcoin network The core idea of , Therefore, it is very similar to bitcoin network in many design features .

The official website of Ethereum project is, Code is hosted in .


The bottom layer of Ethereum blockchain is also a network similar to bitcoin P2P network platform , Intelligent contract Running on the network In the Ethereum virtual machine . The Internet is itself Publicly accessible Of , Anyone can access and participate in the maintenance of data in the network , Provide resources for running Ethereum virtual machines .

Of TaiFang blockchain Technical characteristics It mainly includes :

  • Support Turing's complete smart contract , A programming language is designed Solidity And virtual machines EVM;
  • The hash function with high memory demand is selected , Avoid strong computing power miner 、 Pit attack ;
  • Uncle block ( uncle block) Incentives , Advantages of reducing ore pool , And reduce the block generation interval ( 10 Minutes down Down to 15 About seconds );
  • Adopt account system and world status , instead of UTXO, Easier to support more complex logic ;
  • adopt Gas Limit the number of code execution instructions , Avoid circular execution attacks ;
  • Support PoW Consensus algorithm , And plan to support more efficient PoS Algorithm .

Core concepts of Ethereum

1、 Intelligent contract

  • ** Intelligent contract (Smart Contract)** Is the most important concept in Ethereum , That is to conclude and run various contracts by means of computer programs .
  • Smart contracts run as ** Ethereum virtual machine ( Ethereum Virual Machine, EVM)** Application in , Sure Accept transaction requests and events from outside , Run pre written code logic by triggering , Further generate new transactions and events , You can further call other smart contracts .
  • The execution result of the smart contract may update the ledger status on the Ethereum network .
  • These changes are due to Consensus in Ethereum network , Once confirmed Cannot be forged or tampered with .

2、 Account :

Use accounts to record system status , Each account stores balance information 、 Smart contract code and internal data storage . Ethereum supports the transfer of data between different accounts , To achieve more complex The logic of .

There are two types of Ethereum accounts : Contract account ( Contracts Accounts) And external accounts (Externally Owned Accounts, or EOA):

  • Contract account : Store the executed smart contract code , Can only be activated by external accounts ;
  • External accounts : Ether owner account , Corresponding to a public key . The account includes nonce 、 balance 、 storageRoot 、 codeHash Etc , Controlled by individuals .

When the contract account is called , Store... In it Intelligent contract In the virtual machine at the miner's place Automatic execution , And consume A certain amount of fuel . Fuel is purchased through ether in an external account .

3、 transaction :

transaction ( Transaction), In Ethereum, it refers to... From one account to another The message data . The message data can be Ethernet or contract execution parameters .

Ethereum uses transactions as the smallest unit of operations .

Each transaction includes the following fields :

  • to : Target account address ;
  • value: You can specify the number of etheric coins transferred ;
  • nonce: Transaction related string ;
  • gasPrice: The cost of executing a transaction Gas Price ;
  • startgas: Maximum transaction consumption Gas value ;
  • signature: Signature information

Similar to bitcoin network , When sending a transaction , Users need to pay a certain transaction fee , By Ethernet Pay and consume .

at present , Ethereum network can support the transaction rate exceeding that of bitcoin network ( It can reach dozens of strokes per second ).

4、 Ether money :

Ether money (Ether) Is the currency in Ethereum network .

Ether is mainly used to buy fuel , Pay to miners , The cost of maintaining the smart contract of Ethereum network . The smallest unit of ether is wei, An ether is equal to 1018 individual wei.

Etheric coins can also be generated by mining , Ethereum miners who successfully generate new blocks can obtain 5 An etheric reward , And the fuel cost included in the transaction within the block . Users can also buy Ethereum directly through the trading market .

5、 fuel :

fuel ( Gas), Control the upper limit of a transaction execution order .

Each execution of a contract order consumes a fixed amount of fuel . When a transaction has not been executed, it ends , And when the fuel is consumed , Contract execution is terminated and rolled back .

Intelligent contract

actually , Participants will not be in EVM Write new code when requesting calculations on . Instead, the application developer will program ( Reusable code snippets ) Upload to EVM In storage , The user then requests the execution of these code fragments through different parameters . The programs we upload to the network and executed by the network are called smart contracts .

Simply speaking , You can think of a smart contract as a vending machine : After calling the script with specific parameters , If certain conditions are met , Will perform some operations or calculations . for example , If the caller sends ether to a specific recipient , Digital asset ownership can be created and distributed through a simple seller smart contract .

Any developer can create smart contracts and publish them on the Internet , And use blockchain as its data layer , Pay for the Internet . then , Any user can call the smart contract to execute their code , And pay the network again .

therefore , Through smart contracts , Developers can arbitrarily build and deploy user oriented complex applications and services , For example, the market 、 financial instruments 、 Games etc. .

Super ledger

Who wants to wear a crown , Must inherit its weight ( Uneasy lies the head that wears a crown )

2015 year 12 month , By the flagship organization of the open source world Linux The base Gold will lead , 30 Initial business member ( Include IBM、 Accenture、Intel 、 J . P.Morgan 、 R3 、 DAH 、 DTCC 、 FUJITSU 、 field TACHI 、 SWIFT 、 Cisco etc. ), common Announced Hyperledger The joint project was established .

The super ledger item is transparent 、 Open 、 De centralization Enterprise level distributed ledger technology provides open source reference implementation , And push Blockchain and Distributed ledger Related agreements 、 Development of codes and standards .

The official website of the project is

Hyperledger The basic principle of :

  • Pay attention to modular design : Include transaction 、 contract 、 Uniformity 、 identity 、 Storage And other technical scenarios ;
  • Pay attention to code readability : Ensure that new functions and modules can be easily added and expanded ;
  • A sustainable evolutionary path : With the deepening of requirements and more application scenarios , New and evolving projects .
版权声明:本文为[Writing bugs]所创,转载请带上原文链接,感谢。