Blockchain personal library
Dahua blockchain is a book published by Tsinghua University Press in September 2019, written by Zhang Yingping. This book is a blockchain book that comprehensively explains bitcoin, Ethereum, super ledger and EOS, a blockchain development guide from engineer basic skills, development language to smart contract development, and a blockchain engineer guide from technology, project to career development planning
"Dahua blockchain"
"Dahua blockchain" is a blockchain book that pays equal attention to theory and practice, easy to understand and professional. The blockchain technology guide (the first three chapters) mainly explains the concept of blockchain, blockchain applications, bitcoin, Ethereum, super ledger, EOS and other mainstream blockchain technologies. Through learning, each reader can fully understand the implementation principles of mainstream blockchain technologies and understand the future development trend of blockchain. The practical part of development (the last two chapters) starts from the basic skills of blockchain, simulates the development of real blockchain projects, and explains in detail the design, development and deployment of smart contract and DAPP. Through learning, every reader can master the development of blockchain
From the perspective of technology and architecture, I will tell you my understanding of blockchain in common language
what is blockchain? In a word, blockchain is a storage system. To be more specific, blockchain is a distributed storage system without an administrator and each node has all the data
What are the common storage systems like
first, how to ensure high availability
the common storage system usually uses "rendancy" to solve the problem of high availability. As shown in the figure above, if the data can be copied into several copies and rendant to multiple places, high availability can be guaranteed. The data in one place is hung, and there is data in other places. For example, the master-slave cluster of MySQL is the same principle, and the raid of disk is also the same principle
two points need to be emphasized in this place are: data rendancy often leads to consistency problems
1. For example, in the master-slave cluster of MySQL, there is actually a delay in reading and writing, which means there is a inconsistency in reading and writing in a short period of time. This is a side effect of data rendancy
The second point is that data rendancy often reces the efficiency of writing, because data synchronization also consumes resources. If you add two slave libraries, the write efficiency will be affected. The common storage system is to use rendancy to ensure the high availability of dataso the second question, ordinary storage system, can write more
the answer is yes, for example, take this graph as an example:
in fact, MySQL can do a master-slave synchronization of al masters, master-slave synchronization of al masters, two nodes can be written at the same time. If you want to do a multi room multi live data center, in fact, multi room multi live data synchronization. What we should emphasize here is that multi-point writing often leads to the consistency problem of writing conflicts. Take MySQL as an example, suppose that the attribute of a table is self incrementing ID, then the data in the database is 1234 now. If one of the nodes writes and inserts a piece of data, it may become 5, and then these 5 pieces of data are synchronized to another master node, Before synchronization, if another write node inserts a piece of data, a piece of data with self incrementing ID of 5 will be generated. Then, after the generation, synchronize to another node, and the synchronized data will conflict with the two local 5's after it arrives, which will lead to synchronization failure and write consistency conflict. This problem will occur in the case of multi-point writing
how to ensure consistency in multi-point writing
the reform "Swan class" gives you more technical work
Blockchain platforms include Ethereum, Asch and other underlying application development platforms
Ethereum, an open source public blockchain platform with smart contract function, provides decentralized Ethereum virtual machine to process point-to-point contract through its special cryptocurrency ether (ETH)
arch, a decentralized application platform based on side chain technology. Asch is designed to lower the threshold of developers, such as using JavaScript as the application programming language and supporting relational database to store transaction data, which is believed to be very attractive to developers and small and medium-sized enterprises
extended data
in 2008, Nakamoto first proposed the concept of blockchain. In the following years, blockchain has become the core component of electronic currency bitcoin: public account book for all transactions
by using peer-to-peer network and distributed timestamp server, the blockchain database can be managed independently. The blockchain invented for bitcoin makes it the first digital currency to solve the problem of repeated consumption. Bitcoin's design is a source of inspiration for other applications
bitcoin is the absolute mainstream of digital currency, and digital currency is in full bloom. Bitcoin, litecoin, dogecoin, dashcoin are common. In addition to currency application, there are various derivative applications, such as Ethereum, Asch and other underlying application development platforms, as well as NXT, SIA, bitstocks, maidsafe, ripple and other instrial applications
(1) distributed ledger, that is, transaction bookkeeping is completed by multiple nodes distributed in different places, and each node records complete accounts, so they can participate in monitoring the legitimacy of transactions, At the same time, they can testify together
different from traditional distributed storage, the uniqueness of distributed storage of blockchain is mainly reflected in two aspects: one is that each node of blockchain stores complete data according to block chain structure, while traditional distributed storage generally stores data in multiple copies according to certain rules. Second, the storage of each node in the blockchain is independent and has the same status, which relies on the consensus mechanism to ensure the consistency of storage, while the traditional distributed storage generally synchronizes data from the central node to other backup nodes[ 8]
no single node can record the account data separately, so as to avoid the possibility that a single bookkeeper is controlled or bribed to record false accounts. In theory, unless all the nodes are destroyed, the accounts will not be lost, so as to ensure the security of the account data
(2) asymmetric encryption and authorization technology, the transaction information stored on the blockchain is public, but the account identity information is highly encrypted, which can only be accessed under the authorization of the data owner, thus ensuring the data security and personal privacy
(3) consensus mechanism is how to reach a consensus among all accounting nodes to determine the validity of a record, which is not only a means of identification, but also a means of preventing tampering. Blockchain proposes four different consensus mechanisms, which are suitable for different application scenarios and achieve a balance between efficiency and security
the consensus mechanism of blockchain has the characteristics of "the minority is subordinate to the majority" and "everyone is equal", in which "the minority is subordinate to the majority" does not completely refer to the number of nodes, but also can be the computing power, the number of shares or other characteristics that can be compared by computers“ "Everyone is equal" means that when the nodes meet the conditions, all nodes have the right to put forward the consensus results first, and then directly recognized by other nodes, and finally may become the final consensus results. Taking bitcoin as an example, the workload proof is adopted. Only when more than 51% of the accounting nodes in the whole network are controlled can a nonexistent record be forged. When there are enough nodes in the blockchain, this is basically impossible, thus eliminating the possibility of fraud.
(4) smart contract, which is based on these trusted and tamperable data, can automatically execute some pre-defined rules and terms. Take insurance as an example. If everyone's information (including medical information and risk occurrence information) is true and reliable, it is easy to carry out automatic claim settlement in some standardized insurance procts
according to the agreement, as long as the permanent ownership of books shared in fatbook is this platform, and users only have temporary ownership of books, the circulation of books is the circulation of temporary ownership. With the increase of users, the technology becomes more and more mature
fatbook obviously uses blockchain technology. The first one is decentralization, or multi centralization. Everyone is a point and can be managed in a distributed way
another thing is that everyone has the same authority. Everyone can borrow and lend. At the same time, everyone can't operate other people's "bookshelves". They have the same rights.
Let's suppose villagers Lao Wang and Xiao Li. Lao Wang borrowed some money from Xiao Li, who wrote it in an IOU signed by both parties. A few days later, Lao Wang denied the existence of borrowing money and claimed that Xiao Li forged the paper. Xiao Li can't argue because he finds it difficult to prove that Lao Wang actually owes him money
in this example, Lao Wang and Xiao Li are two nodes
now assuming the same scenario, there are many pairs of people trading with each other in the village. The only evidence for each pair is the IOU. If one party fails, it will be difficult to do so. Seeing this scene, the village head came up with a solution. He suggested using a common notebook for the whole village to record all the transactions. Due to the high prestige of the village head, the villagers unanimously decided to let the village head keep this important transaction book. Each transaction, the villagers go to the village head's home, let the village head witness and record, each transaction is written into a notebook, and then safely saved. That notebook can be called a database
because this notebook is very important, the village head locked it in the safe. However, there are always some problems. Sometimes, the village head will accidentally sprinkle ink on the paper, making some transaction records illegible. This is called a single point of failure. The thief knows that there is an important notebook in the safe of the village head's house. He tries his best to steal it. This is called hacking
until one day, the village head's son owed others a lot of money, so the village head secretly deleted his son's debt entry. In this way, the village head's son "does not owe money."
when the villagers knew this, they began to question the fairness and authority of the village head. So some people put forward a new idea:
abolish the power of the village head, which is called decentralization. Let all villagers keep a notebook, and the transaction records are copied and distributed, which is called distributed database. Therefore, if there are n people in the village, there are n notebooks, that is, n nodes. Every time there is a trade between any two people, all the people in the village get together and record it in their notebooks. And no one can cover the sky. This is called decentralization
they also decided that they would never delete the mentioned transactions from their notebooks, which is irreversible. For example, Lao Wang borrowed a sum of money from Xiao Li before, but in the twinkling of an eye, he wants to return the money. Then the transaction book will not delete the previous borrowing record, but write a new repayment record, so there are two records
next, let's try to break this rule. What if we bribe Lao Wang to change his notebook? It's not feasible, because the next time the villagers meet, they find that Lao Wang's notebook is different from everyone else's, so the villagers notice that Lao Wang may be engaged in an indescribable transaction, and decide to abolish Lao Wang's transaction record and kick Lao Wang out of the organization
What if you try to bribe all the villagers? It's too expensive
the characteristic of this model is that greedy people need to pay a lot to attack the rules. He will find it more profitable to follow the rules
a smart child in the village suggested that each transaction data be called "block" and linked into a "chain" in chronological order, which is called blockchain strong>