A brief introduction to blockchain

A brief introduction to blockchain

[TOC]

Overview

​ This project aims to understand the blockchain, including concepts, principles and understanding of open source project platforms that can be learned and used. This article is from the integration of the articles of many predecessors. It is hereby declared that the links to the referenced articles are at the end of this article.

Blockchain Concepts and Principles

  • Blockchain is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. The so-called consensus mechanism is a mathematical algorithm that realizes the establishment of trust between different nodes and the acquisition of rights and interests in the blockchain system.

  • Blockchain is essentially a decentralized distributed database. Anyone who sets up their own server and accesses the blockchain network can become a node of this huge network. (The original link quoted in the figure below is in the article at the bottom of the article)

    Block chain network structure diagram

  • The essence of blockchain is a database, and the basic unit of storage is "block". A block is divided into two parts:

    1. block header

      The block header stores the header information of the block, including the hash value (PreHash) of the previous block, the hash value (Hash) of the block body, and the timestamp (Timestamp), etc.

    2. block body

      • The block body stores the detailed data (Data) of the block. This data contains several lines of records, which can be transaction information or some other information.
  • A blockchain is a chain structure composed of many blocks

    • MD5 is a typical hash algorithm, which can convert a string of plaintext of any length into a string of fixed-length (128bit) strings, which is the hash value. In the blockchain, a more complex hash algorithm called SHA256 is used. After a series of complex calculations, the latest data information will eventually be converted into a hash value string with a length of 256 bits through this hash algorithm, which is the Hash in the block header.
    • There is a one-to-one correspondence between blocks and Hash, and Hash can be used as the unique identifier of a block. Hash and PreHash are used to associate different blocks. The PreHash of each block is equal to the Hash value of the previous block.

  • Mining is the process of calculating the hash value of the latest data and generating new blocks.

    • The process of calculating the latest Hash value is not a simple one-time operation, but requires a large number of tentative calculations. For example: Hash = SHA-256 (Hash of the last block + basic information of the new block + transaction record information + random number) , the key calculation difficulty here is the generation of random numbers. In order to increase the computational difficulty of Hash, the obscure blockchain inventor requires that the first 72 bits of the Hash structure must be all 0. This probability is too small.
    • Since (the Hash of the last block + basic information of the new block + transaction record information) is fixed, whether you can obtain a Hash that meets the requirements depends entirely on the value of the random number. Miners must go through a lot of calculations and repeatedly generate random numbers to try to "hit luck" in order to obtain the correct Hash and succeed in mining. At the same time, the block header also contains a dynamic difficulty coefficient. When the hardware computing power in the world is getting faster and faster, the difficulty coefficient of the blockchain will also rise, so that the entire network can only generate a new area every 10 minutes on average. Piece.

Application of blockchain

  • The most famous application of blockchain is [Bitcoin]
    • The concept of Bitcoin (BitCoin) was originally proposed by Satoshi Nakamoto in 2008, and then based on this idea, the open source software was designed and released and the P2P network built on it. Bitcoin is a P2P form of digital currency. Peer-to-peer transmission means a decentralized payment system. What is a P2P network? Traditional currencies are issued by the central bank, and all personal savings are managed by the bank, which is a typical centralized system. Bitcoin, on the other hand, is deployed on a decentralized network composed of many peer-to-peer nodes around the world. Every node is qualified to record and issue this digital currency.
    • The underlying data storage of Bitcoin is based on blockchain technology. Each Bitcoin transaction corresponds to a row in the block body data, and each row in the transaction record contains timestamps, transaction details, and digital signatures.
    • The Bitcoin protocol stipulates that miners who mine new blocks will be rewarded with 50 bitcoins from 2008, and then halved every 4 years, currently 12.5 bitcoins in 2018. This is how the new bitcoins in circulation are born.

The pros and cons of blockchain

  • Advantage:
    • decentralization
      • The blockchain does not depend on a central node, and the data of the entire system is jointly maintained by all peer nodes in the entire network, which can store and verify data. In this way, unless an attacker hacks more than half of the nodes in the entire network, the entire system will not be damaged.
    • Information cannot be tampered with
      • The data in the block cannot be tampered with. Once the data is tampered with even a little bit, the hash value corresponding to the entire block will change accordingly. It is no longer a valid hash value, and the blocks linked later will also be Then broke.
  • Disadvantage:
    • Excessive consumption of energy
      • To generate a new block, a large amount of server resources must be performed for a large number of unnecessary trial calculations, which consumes a lot of power.
    • network latency of information
      • Taking Bitcoin as an example, any transaction data needs to be synchronized to all other nodes, and the synchronization process will inevitably be affected by the network transmission delay, which will take a long time.

Mainstream blockchain technology platform (for reference)

Blockchain platforms mainly include: Bitcoin, Ethereum, Hyperledger Fabric, Sawtooth Lake, R3 Corda, Chain, BigchainDB. Developers can learn and use blockchain for applications based on these open source projects.

bitcoin

  • Bitcoin, as the first and most successful and important model project of the blockchain so far, has been running for more than eight years without any serious security and operation and maintenance accidents. Its stability and strength can be called contemporary software. System paradigm.
  • Bitcoin Bitcoin Core is an open source software with high code quality and good documentation. From the perspective of learning blockchain principles and mastering core technologies, Bitcoin Core is the best entry point to learn authentic blockchain technology. .
  • Bitcoin Core is written in C++ and uses some C++11 and Boost library mechanisms. You can also connect with the thriving Bitcoin technology community.
  • As a typical blockchain 1.0 system, whether Bitcoin is the best technology platform to support other types of blockchain applications is controversial. In addition, not everyone has the ability and necessity to be proficient in the underlying technology of the blockchain, so for those who rush into the blockchain field, the straightforward learning goals are Ethereum and Hyperledger Fabric.
  • Links for reference: https://bitcoin.org/en/bitcoin-core/

Ethereum

  • Smart contract development with Solidity on Ethereum is the easiest way to get into blockchain development, no one.
  • The ideal of Ethereum is very grand. Because it is equipped with a powerful Turing-complete smart contract virtual machine, it can become the mother platform of all blockchain projects and a big turtle that supports the entire blockchain world. Developing a Bitcoin-like cryptocurrency on Ethereum is an uncompromisingly small goal. Generally, experienced developers can get started in half a day to a day under the guidance of the documentation. The question is, what happens after getting started? Can you conquer the world by writing Solidity? This is greatly doubtful. We can also say the other way around, if Ethereum + Solidity is the ultimate solution for the blockchain, why are there so many blockchain technology schools? In particular, Ethereum does not seem to leave a way out for giant centralized organizations in the real world, and this completely uncompromising revolutionary attitude may also become an obstacle to the promotion of Ethereum.
  • The current development of the Ethereum project is not going well. A more prominent problem is that there are too many projects and the power is scattered, resulting in uneven project quality. But despite this, compared with other blockchain 2.0 platforms, the development environment provided by Ethereum is the simplest and most complete. It is absolutely necessary for beginners to learn Ethereum to establish the most "authentic" understanding of blockchain and smart contracts.
  • Links for reference: https://www.ethereum.org/

Hyperledger Fabric

  • The third branch of the mainstream blockchain technology platform is Fabric, which is the first and most well-known incubation project of Hyperledger.
  • Fabric first came from IBM's Open Blockchain project. By November 2015, IBM handed over the 44,000 lines of Go language code that had been developed at that time to the Linux Foundation and incorporated it into the Hyperledger project. During a hackathon in March 2016, Blockstream and DAH merged their respective code into Open Blockchain, which was later renamed Fabric. So far, Fabric and Sawtooth Lake provided by Intel are listed as the first-level incubation projects of Hyperledger, but the former has received far more attention than the latter.
  • From a technical point of view, Fabric has a good idea, focusing on meeting the needs of enterprises for commercial use, such as solving the problem of transaction volume. As we all know, the biggest shortcoming of Bitcoin is its upper limit of 7 transactions per second, which is completely unable to meet practical needs. The goal of Fabric is to achieve 100,000 transactions per second, which is close to the instantaneous peak of the double 11 transaction volume just past, which can fully meet the industry-level applications under normal conditions. Fabric is developed in Go language and also provides APIs in multiple languages. It is particularly worth mentioning that Fabric makes full use of container technology, for example, its smart contracts run in containers. This is also a benefit that the Go language brings to Fabric, because the static compilation and deployment feature of the Go language is very suitable for developing programs in containers.
  • Fabric also has some features. For example, its membership service can set up node access review, which is a typical consortium chain feature. Another example is that its consensus algorithm is customizable. Fabric comes with PBFT consensus algorithm implementation, but the algorithm efficiency of PBFT is O(n²), where n is the number of nodes. Therefore, it is no problem to use PBFT in a consortium chain with a limited number of nodes, but it is too inefficient to use in a public chain.
  • The disadvantage of Fabric is that the system is relatively complex. Although there are documents, developers who lack experience have a great difficulty in learning. However, due to its clear positioning and catering to the mentality of many companies, there are already many institutions that have developed consortium chain projects in the industry based on Fabric secrets.
  • Links for reference: https://cn.hyperledger.org/

Small sect

The three mainstream platforms developed by the above-mentioned blockchains far exceed other platforms in terms of activity, attention and participation. But as the saying goes, don’t bully the poor, and some platforms that are still unknown at the moment cannot be ignored.

  • Sawtooth Lake:

    • Another first-level incubation project of Hyperledger, Sawtooth Lake, is a blockchain platform developed by Intel. It is an idea blockchain project with a very meticulous design. It aims at digital financial asset management, with a clear overall structure and a high degree of modularity, so it has strong customizability. Conceptually, the concept of "transaction family" is created, and it also supports two consensus mechanisms, PoET and Quorum. When the number of nodes is large (public chain environment), using the SGX extension provided by the 6th generation Intel Core CPU provides a mechanism called Proof of Elapsed Time (PoET) to form consensus, which is similar to that adopted by Bitcoin. PoW is also a "lottery lottery" consensus algorithm, but it eliminates the possibility of "cheating" through ASIC-specific hardware, and eliminates the hidden danger of excessive concentration of computing power in Bitcoin. The reliability is guaranteed by Intel CPU hardware. It is a public chain A very valuable consensus mechanism in the system. On the other hand, when the number of nodes is small and controlled, Sawtooth Lake can adopt the Quorum consensus mechanism, which is a consensus mechanism proposed and verified by Ripple, which is very suitable for the consortium chain scenario, so that Sawtooth Lake turns into a very useful consortium chain up.

    • Sawtooth Lake is developed in Python and provides a Java SDK. Due to the popularity of these two languages, it should actually have a large potential developer population. In fact, R3 CEV has tested Sawtooth Lake and conducted successful securities trading experiments. At present, its main problem is the lack of attention, and I wonder if Intel has enough patience and perseverance to stick to it. If Intel's strategy is clearer and more supportive, I suggest you pay more attention to it.

    • Links for reference: https://sawtooth.hyperledger.org/docs/core/releases/latest/index.html

  • Rope:

    • It is a distributed ledger project that has attracted much attention. R3 is a blockchain enterprise supported by dozens of banks and financial institutions, raising hundreds of millions of dollars. Corda is the core of the R3 distributed ledger system and is also officially open source.
    • Developed in Kotlin, JetBrain's original niche language, Corda opens its doors to the Java world, which is commendable. In addition, the more important feature of Corda is its posture of comprehensive compromise and comprehensive cooperation with big banks and large central institutions in the existing world, which is in stark contrast to the image of the Ethereum revolution's innocence and reasonable rebellion. Corda has a number of unique considerations in the design, which is to interface with existing business rules. For example, in almost all other blockchain platforms, each transaction is visible to each node, and it can only be verified if it is visible, and consensus can only be reached if it can be verified, so the network-wide visibility of transactions is logical. However, for transactions between financial institutions in the real world, only the parties involved in the transaction can see the transaction details. A transaction between ICBC and CCB is absolutely unnecessary for China Merchants Bank to see. To interface with this reality, Corda has designed a different mechanism that sacrifices the global visibility of transaction verification, ensuring that only the parties involved in the transaction can see and verify the transaction itself. But on the other hand, banking business is a heavily regulated business. You can’t put aside the splendid Basel Accord just because you use the blockchain system. How should the functions of the regulators be reflected? This is not considered much in other blockchain systems. Corda has designed unique Notary and Oracle nodes, leaving room for the entry of the regulatory system. If you taste it carefully, these are beautiful differences reserved for big institutions in the real world. These design considerations undoubtedly greatly enhance the chances of Corda being adopted by large existing financial institutions. But all this looks very good, but the current implementation of Corda is basically a sleight of hand, and many of the ideas are in a TODO state.
    • Reference link: https://www.corda.net/zh-hant/
  • Two other blockchain schools worth naming are Chain and BigchainDB. The former cooperates with Visa, and the latter is a distributed ledger developed based on RethinkDB. Both have their own ideas and characteristics, and have also received considerable investment. It is not ruled out that there will be great development in the future.

This article refers to the original text, the link is as follows, hereby declare

If there is anything inappropriate, please criticize and correct me. My link is as follows:

https://my.oschina.net/llzhang/blog

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325390795&siteId=291194637