Blockchain Technology and Application - Study Notes 1 [Introduction]

Hello everyone, I am Bittao. This series mainly optimizes and integrates the notes I made when I was learning blockchain technology. A large number of notes are from the video course: "Blockchain Technology and Application" open class by Teacher Xiao Zhen from Peking University. Teacher Xiao's class made me regain the feeling of thirst for knowledge, and I enjoyed the process of learning this class very much. When I saw that the difficulty of the blockchain is automatically adjusted according to the interval between blocks; When I hear interesting stories about chain thieves; when I hear: don’t be limited by the thinking of academia, don’t be limited by the thinking of programmers , when it’s better to have no books than to believe in books... It makes me feel happy, Can't stop! I still remember that one night, after seeing the ingenious design of BTC, I directly took the case on the spot, which was wonderful! It is recommended that students who are interested in blockchain listen to this course, seize the opportunities of the times, and create a better future together.

Note: This series of notes tries to explain the details of basic knowledge, but still requires knowledge of data structures and a certain programming foundation.

Table of contents

(The series of notes are being updated...the catalog will be integrated after the update)

1. Background

Blockchain technology originated from the "Bitcoin-Whitepaper" published by Satoshi Nakamoto in 2008, and in 2009 he founded the BTC (Bitcoin) network and developed the first block, ie 创世区块. Some people call this technology the next generation of value Internet WEB 3.0, a great invention and compare it with the industrial revolution. Others say it is a Ponzi scheme, a tool for cutting leeks, and worthless. Although the first application of blockchain technology is indeed BTC, behind it covers a large number of cross-integration of computer, distributed, cryptography and other technologies. At the current stage, we should face up to the application of blockchain technology. No need to be overly flattered, and no need to be dismissive. At present, blockchain technology is developing at a high speed, and the upper layer applications based on blockchain technology have great value. I hope everyone will remain rational and not miss such a valuable technology as the blockchain.
insert image description here
In the 14th Five-Year Plan, the blockchain has become one of the seven digital industries, and it is a technology that the country focuses on development. A number of supporting policies have been introduced one after another, ushering in development opportunities. The industrial ecology of the blockchain is also becoming more prosperous, and more and more companies have joined the industrial construction. Blockchain is solving specific business problems, and large-scale applications are coming. The integration and development of technologies such as IOT communication with other technologies is profoundly changing the production relationship in industrial collaboration. Consolidate the infrastructure of trusted links in the digital economy, and the digital wave of industrial collaboration has arrived. This will stimulate the industrial economy, burst out new vitality, and release a huge new impetus for the industry.

2. The meaning of blockchain

Blockchain, as the underlying technology of BTC, is essentially a decentralized database. It refers to a technical solution for collectively maintaining a reliable database through decentralization and trustlessness. Blockchain technology is a technical solution that does not rely on third parties and stores, verifies, transmits and communicates network data through its own distributed nodes. Therefore, from the perspective of financial accounting, some people regard blockchain technology as a distributed, open and decentralized large-scale network accounting book. Anyone can use the same technical standards to add their own information at any time, extending The blockchain continues to meet the data entry needs brought about by various demands.

In layman's terms, blockchain technology refers to a way for all people to participate in bookkeeping. There is a database behind all systems, and the database can be regarded as a large ledger. Then who will keep this account book becomes very important. At present, whoever owns the system is responsible for keeping accounts. The account book of WeChat is kept by Tencent, and the account book of Alipay is kept by Ali. But now in the blockchain system, everyone in the system can have the opportunity to participate in bookkeeping. If there is any data change within a certain period of time, everyone in the system can keep accounts, and the system will judge the person who is the fastest and best in accounting during this period, write the contents of his records into the ledger, and write this During a period of time, the content of the ledger is sent to all other people in the system for backup. In this way, everyone in the system has a complete ledger. In this way, we call it blockchain technology.
insert image description here
Blockchain technology is considered to be the most disruptive technological innovation since the invention of the Internet. It relies on cryptography and mathematically ingenious distributed algorithms. On the Internet where trust cannot be established, it can be used without the intervention of any third-party center. The participants reached a consensus and solved the problem of reliable delivery of trust and value at a very low cost.

From the perspective of the formation of blockchain, it has the following characteristics:

  • Decentralization, without third-party intervention, realizes peer-to-peer transactions and interactions between people.
  • The information cannot be tampered with. Once the data information is written into the block, it cannot be changed or revoked. For example, if bitcoin transaction information is written into the bitcoin system, no one can change it.
  • Open and transparent, within a very short period of time, block information will be copied to all blocks in the network to achieve data synchronization across the network, and each node can trace back all past transaction information of both parties.
  • De-credit, the asymmetric encryption technology used in the blockchain can realize de-credit, and transactions can be conducted between nodes without trust.

The blockchain system adopts a decentralized organizational form. The entire system is very flat and there is no centralized authority or hierarchical structure management organization. The self-adaptation of the entire system is achieved through distributed inter-node games, ensuring the overall integrity of the system. stability. Blockchain is currently generally regarded as an 颠覆性emerging technology, and its greatest innovation lies in reconstructing the trust relationship between weak credit subjects, thereby avoiding the previous way of relying on centralized intermediaries with high credit. This way of rebuilding the credit system is not based on individuals or authoritative institutions, but relies on consensus algorithms and cryptography, which is open and transparent.

The blockchain can even help to establish a global decentralized credit system, so that value transfer can be as convenient as Internet information transfer. Based on this method, a new economic ecosystem can be rebuilt. Taking the clearing and settlement business of the financial industry as an example, traditional centralized databases cannot solve the problem of multi-party mutual trust, so that each participant needs to independently maintain a set of databases that carry their own business data. These databases are actually islands of information , causing the clearing and settlement process to consume a lot of manual reconciliation, and the current clearing and settlement time is the fastest and needs to be calculated in days. If there is a database system that is unanimously trusted by multiple parties, it can significantly reduce labor costs and shorten the settlement cycle.

The blockchain is currently considered by the industry to be one of the core elements of the industrial revolution. Its decentralization, disintermediation, and tamper-resistant, traceable, safe and reliable characteristics, as well as its development prospects and profound impact on society have been widely recognized.

3. Classification of Blockchain Technology System

Generally speaking, the industry will divide the blockchain into three types: public chain, alliance chain and private chain according to the degree of blockchain centralization.

The public chain usually has no restrictions on the nodes that join the network. Nodes can join or exit the network freely. Each node has equal rights to participate in the operation of the entire blockchain platform. At the same time, the blockchain network of the public chain is also completely decentralized. distributed organizational structure. It is precisely because of the flexibility of this organizational structure that higher requirements are put forward for the network expansion capability of the blockchain system, the number of nodes that can be supported, and the scalability, fault tolerance, and efficiency of the consensus mechanism. In the public chain, each node shares the ledger of the entire blockchain system, which undoubtedly poses a huge challenge to the privacy and security of the system. Finally, certain incentives must be given to the nodes to promote the continuous maintenance of the nodes and contribute to the continuous operation of the entire network. Bitcoin and Ethereum are typical public chains.

The consortium chain weakens the completely decentralized nature of the public chain, and achieves partial centralization or multi-centralization in exchange for better performance and lower maintenance costs, so as to better meet the needs of enterprises for blockchain platforms. expectations. Nodes in the alliance chain usually belong to different organizations or alliances. Nodes that want to join need to be authorized by centralized or higher-authority nodes. The maintenance rules of the blockchain need to be coordinated and customized by the participants of the alliance chain. The consortium chain is suitable for application scenarios such as sharing data services between organizations with frequent data exchange in a small range, such as cross-border remittance settlement and other services. Hyperledger is a very typical alliance chain platform.

A private chain is a centralized blockchain platform that meets specific needs. It does not provide external services or selectively open a few interfaces, and focuses on meeting the internal data management and auditing of the organization.

Bitcoin, Ethereum, Hyperledger, three typical technical architecture systems:
insert image description here

Network layer

The most important function of the P2P protocol of the blockchain network is inter-node communication, which connects nodes distributed in different geographical locations through the network and P2P protocol. The content transmitted between nodes is mainly transaction data and block data. In the blockchain network, nodes monitor the data broadcast in the network at all times. When receiving new transactions and new blocks from neighboring nodes, they will first verify whether these transactions and blocks are valid, including digital signatures in transactions, Proof of work in the block, etc., only verified transactions and blocks will be processed (new transactions are added to the block being built, and the new block is linked to the blockchain) and forwarded to prevent the continuation of invalid data spread.

consensus layer

The decentralized blockchain is managed and maintained by multiple parties, and its network nodes can be provided by any party. When there is no access mechanism, some nodes may not be trusted, so it needs to support more complex Byzantine Fault-Tolerant (Byzantine Fault-Tolerant, BFT), like Hyperledger Fabric, has added an access mechanism, and only authorized nodes can join the network, so a more efficient fault-tolerant RAFT algorithm is adopted. However, in the public chain scenario, there is no node access mechanism, and the number of nodes is much higher than that of the alliance chain scenario, so the BFT algorithm is not applicable. At the same time, in order to solve the problem of sybil attack (sybil attack) that may be caused by the free entry and exit of nodes, Bitcoin applies the Proof of Work (PoW) mechanism. It is a proof-of-work algorithm based on a hash function. Bitcoin requires that only nodes that have completed a certain calculation workload and provided proof can generate blocks. Each network node uses its own computing resources to perform hash operations to compete for block accounting rights. As long as the computing power controlled by trusted nodes in the entire network If the resource is higher than 51%, it can prove that the entire network is safe.

A Sybil attack is when an attacker disrupts the reputation system of a web service by creating a large number of pseudonymous identities and using them to gain disproportionately large influence.

data layer

Bitcoin, Ethereum, and Hyperledger have their own characteristics in terms of blockchain data structure, data model, and data storage. In the design of the data model, Bitcoin adopts a transaction-based data model. Each transaction is composed of an input indicating the source of the transaction and an output indicating the destination of the transaction. All transactions are linked together through input and output, making each transaction unique. Traceability; Ethereum and Hyperledger Fabric need to support general-purpose applications with rich functions, so an account-based model is adopted, and the current balance or status can be quickly queried based on the account.

In the design of data storage, because the blockchain data is similar to the pre-written log of the traditional database, it is usually stored in the log file format; because the system requires a large number of hash-based key-value retrievals (such as retrieving transactions based on transaction hashes) data, retrieve block data based on block hash), index data and state data are usually stored in the Key-Value database, such as Bitcoin, Ethereum and Hyperledger all store index data in the LevelDB database.

smart contract layer

A smart contract is a digital agreement that uses algorithms and programs to compile contract terms, deploys on the blockchain, and can be automatically executed according to the rules. Due to the limitations of early computing conditions and the lack of application scenarios, smart contracts have not received widespread attention from researchers. It was not until the emergence of blockchain technology that smart contracts were redefined. The blockchain realizes decentralized storage, and the smart contract realizes decentralized computing on the basis of it.

Bitcoin script is a set of instructions embedded in Bitcoin transactions. Due to the single type of instructions and limited implementation functions, it can only be regarded as the prototype of smart contracts. Ethereum provides Turing-complete scripting languages ​​Solidity, Serpent, and the sandbox environment Ethereum Virtual Machine (Ethereum Virtual Machine) EVMfor users to write and run smart contracts. The smart contract of Hyperledger is called Chaincode, which uses Docker container as the sandbox environment. The Docker container contains a set of signed basic disk images and runtimes and SDKs of Go and Java languages ​​to run Go and Java. Chaincode written in the Java language.

application layer

The applications on the Bitcoin platform are mainly digital currency transactions based on Bitcoin. In addition to Ethereum-based digital currency transactions, Ethereum also supports decentralized applications (Decentralized Application, Dapp). Dapp is a web front-end application built with JavaScript, and communicates with smart contracts running on Ethereum nodes through JSON-RPC. communication. Hyperledger is mainly oriented to enterprise-level blockchain applications and does not provide digital currency. Its applications can be built based on SDKs in Go, Java, Python, Node.js and other languages, and communicate with the Smart contracts communicate.

In simple terms, the network layer ensures the connectivity of nodes, the consensus layer ensures the consistency of data between nodes, the data layer efficiently organizes various data in the blockchain, and the smart contract layer defines a set of rules by users to generate For specific logical data, the application layer is used to provide various services externally.

Guess you like

Origin blog.csdn.net/u012558210/article/details/132645885