# Blockchain Note – Common Concepts

### 1. Byzantine failures

There are N generals preparing to attack the city, and the information transmission can only rely on the messenger. Each general has his own idea, but only when more than half of the generals attacked the city together to win, how to finalize the siege time?

Sending only text messages brings two problems:
1) The original text is easily falsified;
2) The addressee cannot verify whether the original text has been tampered with;
One is the digital signature we are familiar with, but this only applies to one-to-one transmission scenarios.
If you want to broadcast the message to the whole army, you have to use the second method: proof of workload.

Put together the summarizing intentions of all the generals on a hill:
General 1: 1 pm tomorrow;
General 2: 3 o’clock tomorrow;
General 3: 3 o’clock tomorrow;
General 4: 5 days after tomorrow;
General 5: 7 days after tomorrow;
Find a lucky number, so that the hash value of “Information + Lucky Number” is “00000000” and send 10 letters to send letters. Even if one of the communications soldiers is intercepted, the other hill general can receive 9 “messages + lucky numbers”. After the hash, there are 8 “0”s. The 8 indicates that the difficulty is already high. The probability of the enemy being cracked is One trillion. So decisively believe and use the same way
General 6: 3 o’clock tomorrow;
General 7: 3 o’clock tomorrow;
General 8: 1 o’clock tomorrow;
General 9: 7 days after tomorrow;
General 10: 3 o’clock tomorrow;
Find a lucky number, so that the hash value of “Information + Lucky Number” is “00000000” and send 10 communication soldiers to send letters.
After a few rounds of confirmation, you can reach an agreement: 3 points to attack the city tomorrow.
Increase the number of communications and increase the difficulty.

Because the enemy knows: First, it takes a long time to find lucky numbers. Secondly, nine soldiers have passed the news in the process of thousands of hashes. Even if I find lucky numbers, I can’t confuse them.

As long as the vast majority of nodes do not do evil, each node tries its best to broadcast its own message, and using the Workload Proof (POW) method, the entire network will form a correct consensus.

We know that designing a system requires fault tolerance, and here the fault is diverse. Most distributed databases can tolerate downtime, network disconnection, and network delays caused by pseudo-down/pseudo-networks. Broken and other errors. This type of problem can be solved simply by resending the +fence token with timeout. In systems that require distributed consistency, you can use the quorum algorithm, such as raft, Paxos, and Zab.

The system of Byzantine fault tolerance means that in an untrusted environment, every single point knows the whole network, and the majority is honest. In this case, even if you don’t know Which point is illegal, and it can also make all the points of integrity reach a consistent system (for example, let hundreds of millions of computers agree: who owns the coin).

The blockchain system is fault-tolerant even in Byzantine error, that is, the system can maintain the correctness of the system when the Byzantine error occurs, and the general distributed database cannot tolerate Byzantine errors (so to ensure that Byzantine errors cannot occur)

### 2. Double Spending Attack

Double Spending refers to a potential defect in the design of a currency that allows certain currencies to pay more than once.
Take the BTG incident as an example. After the hacker temporarily controls the blockchain, he continually initiates and cancels the transaction at the exchange, and turns a certain number of BTGs between multiple wallet addresses. A “money” has been spent. The hacker’s address thus got 388,201 BTGs.
Any currency payment system will inevitably face the challenge of double payment problems. There are two solutions to prevent double payment: centralization and decentralization.
Centralized solution:
Create a trusted third-party agency to identify whether each money has been paid.
Bank is such a third party institution
The centralized solution has a problem: if the center itself is not working, the whole system is easy to misunderstand that the empty check is only one of the double payments, and the other double payment that is more powerful and spreads is the currency.
Decentralized solution:
There is an encryption technique that can be used to avoid third-party verification of transactions because each transaction is recorded in real time on a fully publicized ledger. When someone else pays you a transaction, the transaction is recognized by most people, and everyone recognizes that the transaction is legal, and there is money that cannot be shaken on your account. This technology makes double payment impossible.
Another name for this scheme is Bitcoin. No matter what kind of news you see in the future, the only use of remembering Bitcoin is to solve the double payment problem with decentralized P2P technology.
We propose a solution to solve dual payments using a peer-to-peer network. The network adds timestamps to all transactions via hashing and merges them into an ever-extended, hash-based proof-of-work chain as a transaction record. Unless the full workload proof is redone, the transaction record will not be changed once it is formed.

### 3. 51% Attack

51% of attacks, that is, after someone has mastered the computing power of more than 51% of the whole network, they can preempt a chain of longer, forged transactions like a race. Bitcoin only recognizes the longest chain. So the forged trade will be recognized by all the nodes, and the fake will become true. This is determined by Bitcoin’s consensus mechanism PoW (workload proof).
Double-spending attacks can still occur because Bitcoin uses a consensus mechanism for proof of workload. If A wants to launch a double-spending attack, after transaction 1 and send a broadcast, the other nodes on the network record the transaction, but after generating 6 blocks, it can be determined that the transaction has been successful. After the transaction 1 broadcast, A recorded transaction 2 in its own blockchain and reused the currency of transaction 1. If A masters more than 51% of the computing power, then A can have a large chance to dig out the next 6 blocks and then broadcast again, at which point transaction 2 will be judged successful and transaction 1 will fail. That is, a sum of money spent 2 times, but the money collector of transaction 1 did not receive the money and suffered losses. This is the so-called double spending attack. Of course, if the computing power is not enough 51%, you can also launch a double-spending attack, and there is a possibility of success. The lower the power, the less chance that the double-spending attack will succeed.

### 4. Sybil attack

The witch attack is in the P2P network. Because the node joins and exits at any time, in order to maintain network stability, the same data usually needs to be backed up to multiple distributed nodes. This is the data redundancy mechanism. Sybil attack is an effective means of attacking data redundancy mechanisms.

If there is a malicious node in the network, the same malicious node can have multiple identities. The data that needs to be backed up to multiple nodes is spoofed backed up to the same malicious node (the malicious node masquerades as multiple identities). This is the witch attack. .

How to solve the witch attack?
One method is the proof of work mechanism, that is, to prove that you are a node, not to say that you are not practicing, but to use the proof of computing power, which greatly increases the cost of the attack.
Another method is identity authentication (as opposed to the PoW protocol, the sybil attack is based on the BFT Byzantine fault-tolerant protocol Blockchain needs to be considered, and the corresponding identity authentication mechanism is required).
The authentication mechanism is divided into two categories:

1) Third-party based authentication
Every time a new node is added, it needs to be authenticated with a reliable third-party node.

2) Pure distributed identity authentication
Each new node needs to obtain the authentication of all reliable nodes in the current network. This method uses the public key system authentication method of random key distribution verification. It needs to obtain the authentication of most nodes in the network to join the network.

### 5. CAP theorem

n a distributed system, consistency, availability, and partition tolerance must not be met at the same time.

Consistency (C) refers to the complete consistency of data across the network at the same time.
Availability (A) A part of the node updates the data, the distributed system can respond to the user’s read and write requests based on the latest data.
Partition Tolerance (P) has only two optional parameters: intolerance and tolerance.
Do not tolerate partitioning is better than typing in your word, you don’t have to walk through the network, a computer can get it all; tolerance partition is a distributed system, at least two computers are online, such as the moment you save the word document, if my computer does not Interact with you, you can’t read the text you just wrote.

Distributed systems must tolerate partitioning (P), so consistency (C) and availability (A) are destined to be mutually exclusive

Bitcoin’s slowness makes sense. The reason is CAP theorem: In order to pursue the strict consistency of the entire net book in a distributed system, the availability is of course sacrificed, so it can only wait until the transaction information is deeply penetrated. On, the transaction is available

Solutions to improve availability:
First, the expansion: the original two lanes into eight lanes, so that more information flow can be carried in a unit of time, the crystallization of this scheme forks out the bitcoin cash BCH.
The second is offline trading: when the miners are busy, they will not routinely charge the small amount of transactions at the bottom of the box. This is because the incentives caused by insufficient incentives are insufficient. The high-frequency small transactions will be transferred by the “small bank”. The crystallization of this solution is the lightning network.

Impossible triangle

Figure 1. Impossible Triangle of blockchain

### 6. What is Mining?

The core principle of Bitcoin is “blockchain”. Each block corresponds to a bill. Linking all blocks is a blockchain. Any transaction information and transfer records are recorded in the blockchain.
At every other point in time, the Bitcoin system generates a random code on the system node. All computers on the Internet can look for this code. Whoever finds this code will generate a block and get a bitcoin. The process is what people often say about mining.
There is also a mechanism in the Bitcoin system, that is, Bitcoin has a limited amount, and the total amount of Bitcoin will generate 10,500,000 BTC in the first four years, halving the output every four years, and generating 5,250,000 BTC in the fourth to eighth years. In 8-12 years, there were only 2,625,000 BTC, and so on. To the end, the total number of bitcoins generated is close to 21,000,000 BTC.

### 7. What is hard-fork?

The hard fork is that the old node does not accept the block generated by the new node, causing the network to split into a new chain and the fork of the old chain.

Figure 2. Hard Fork

The soft fork is the block that the old node accepts from the new node (although there may be some potential risk). If the new node is dominant, the branch game will cause the network to be finally assigned to the new chain.

Figure 3. Soft Fork

### 8. UTXO (Unspent Transaction Output)

UTXO is the basic unit in Bitcoin transactions. Once a UTXO is created, it cannot be continued to be split. It can only be spent as input to the next transaction. After spending, it will generate a new UTXO, so that the currency can be realized again and again. Value transfer.
So the account balance we see in the Bitcoin wallet is actually calculated by the wallet by scanning the blockchain and aggregating all UTXOs belonging to that user.
So, when we are saying that someone owns a bitcoin, what we are actually saying is that in the current blockchain record, the UTXO collection address for several transactions is the person’s wallet address. The sum of these UTXOs is 1 bitcoin.

For example, a wallet has a 10 dollar, a 5 dollar, a 1 dollar, a total of 16 dollar. The balance of an account in Bitcoin is also calculated based on this account UTXO.
When you spend 12 dollar to buy something, you can take 10 dollar and 5 dollar, and then get 3 dollar to change, then 10 dollar and 5 dollar before this time because it has already been spent, it is no longer UTXO, new The change of 3 dollar becomes the new UTXO, plus the untouched 1 yuan UTXO, the current balance is 4 dollar. The new transaction was recorded on a new block, but did not change the data of the historical block.
Bitcoin uses the blockchain linked back and forth to record all transaction records. When the previous UTXO appears in the input of subsequent transactions, it means that the UTXO has been spent, no longer UTXO.

From the perspective of financial system design, this approach is somewhat “transactional clearing separation”. The blockchain system only processes all transactions, but needs to clear and view the balance and other information, which is handled by the blockchain node itself.

Bitcoin’s UXTO system follows two rules:
1. Except for CoinBase, all sources of funding must come from the UXTO of one or more of the previous transactions;
2. The total input of any transaction must be equal to the total output, and the equation must be balanced on both sides.

Each bitcoin transaction is actually made up of several transaction inputs and outputs. The transaction input is the source of funds, the transaction output is the direction of the funds, and each transaction has to spend a part of the transaction input, which is the unspent transaction output (UTXO). Each transaction input can be traced back to the previous UTXO until the initial mining income.

The bitcoin transaction created by the mining result is the first transaction in each block, also known as the coinbase transaction, which is created by the miner and has no previous transaction output.

The difference between UTXO system and account system:
1). UTXO only needs to watch the last transaction, and the account system must add all the increase and decrease operations to obtain the correct balance after looking at the historical full data. The efficiency difference between the two will become larger and larger with time;

2). UTXO can cut old historical data in the future, while the account system can not discard old data. The former blockchain can control the overall size, while the latter can only continue to expand.

What problems did UTXO solve?
Digital currency cannot transfer ownership by physical transfer just like metal currency (such as gold). That is, when A gives a gold to B, A will no longer own the gold. After A transfers a digital currency to (signature) B, A can still transfer the same transaction to C, because A masters the private key, both signatures are valid signatures, which constitutes a “double spending.” Therefore, there must be a mechanism to ensure that each transaction can only be used once, that is, only the signature of the “not used” transaction can be a valid signature.

UTXO solves the double spending problem and realizes the value transfer.

### 9. What is the average TPS (transaction per second) of BTC? And why?

The size of one ledger per block is 1MB
Generate such a block every 10 minutes
The size of transactions per block is 250B

Number of transactions per block: 1 M / 250 = 4194
Number of transactions processed per second: 4194 / (10 * 60 ) = 6.99 = 7 TPS

### 10. What is Blockchain?

The blockchain is essentially a decentralized distributed ledger database, which itself is a string of data blocks generated using cryptography, each of which contains information that is validly validated for multiple Bitcoin network transactions.
1. A blockchain is a distributed database placed in a non-secure environment.
2. The blockchain uses cryptographic methods to ensure that existing data cannot be tampered with.
3. The blockchain uses a consensus algorithm to reach consensus on new data.
A system with the above three properties is a blockchain.

### 11. What problem did blockchain solved?

1. Double spending attack
2. Byzantine failures

### 12. What applications should apply to blockchain?

Figure 5. Blockchain Applications

Figure 6. DApp Applications

### 13. What is EDA (Emergency Difficulty Adjustment) ?

Bitcoin’s average block time is 10 minutes. This 10 minutes is adjusted by the Mining Difficulty Adjust Algorithm.
Bitcoin’s blockchain system does not know how many miners (computing power) are currently mining. It can only guess how many miners are mining by speeding out the blocks. If the block is faster than expected (the average block time is less than 10 minutes in a period of time), it means that the calculation power is much more, it is necessary to increase the difficulty of mining and reduce the miner’s speed.

### 14. After a few years of bitcoin mining, who will pay for the miners?

1). Financial tool
As mentioned earlier, if you simply rely on asset transfer claims to support BTC transactions, it is destined to be low-frequency. But BTC, the leader in the cryptocurrency world, will be the first currency to go online with various financial instruments. At that time, the physical settlement of futures will bring relatively frequent transfer claims, and at the same time bring about an increase in the price of the currency.

2). Strategic assets
As the amount of block awards continues to decrease, the profits of miners will become increasingly thin. Aside from the BCH factor, it is indeed slowly reaching the state of Nash equilibrium, thus adjusting the mining cost and benefit ratio to a reasonable range.
But whether or not a lot of things exist does not depend solely on whether this thing has huge profits. For example, traditional kindergartens have a profit of only 6-7% per year, but many traditional investors with low risk appetite are still particularly keen.
In the future, miners’ fees may be only 10%-15% annualized. However, if each country recognizes the value of BTC, it is an important investment target. That BTC is a very stable investment for many heavy capital. That mining cost is no longer so important.

3). Side chain
If the BTC has a lot of side chains in the future, the BTC will be transformed into a settlement layer. Although a single side chain, such as the lightning network, will reduce the number of transactions on the chain, if the BTC mounts a lot of side chains and handles a large number of settlements, the amount may be considerable. After all, BTC’s current security is still the highest. Therefore, it is not surprising to mount N side chains in the future. The side chain system represented by RSK is eager to try. Maybe ten years later, we will see a completely different BTC, and we don’t know.

4). Expansion
Although the problem of expansion has been tossed, it has ended in failure. But what happened in the past does not mean that it will happen again in the future.
If it is 2030, will BTC still remain in the 1M block?
Perhaps at a key time in the future, BTC will expand successfully. By then, more and more people will regard BTC as a “digital gold” that can be both awkward and fancy. Just as hundreds of years ago, people treated gold the same way. Perhaps more and more people in the future will use BTC to do things that do not require instant verification of payment, such as paying taxes, buying a car, buying a house, and securing assets.

### 15. Cross-Chain

Multi-chain is a node that can run multiple chains. You can understand that each chain has its own independent ledger data (that is, block data). The transactions on different chains are executed in parallel. You can refer to Hyperchain and RChain. The concept of namespace, not to elaborate here.

The side chain is a sub-chain derived from the main chain, and its purpose is also to solve the problem of low throughput and high delay in the current blockchain. For example, the public chain represents Ethereum, think about hundreds of DApps every day. It runs above, but it can only have 15 tps per second. For some decentralized game applications, such a low tps will only lead to a worse user experience, such as the ether cat…. The hole is wide open, these DApps that require thousands of tps are placed on their own independent blockchain (side-chain), which can have thousands of users, and the side-chains use other more efficient consensus algorithms as needed (eg Instead of the inefficient PoW algorithm, the side-chain will periodically interact with the main chain, such as the Ethereum public chain, to move anything of value to the main chain to ensure security so that the transaction can be determined more quickly. Transaction costs are lower. You can refer to the Ethereum second-tier expansion solution – Plasma.

Cross-chain, ie different blockchains, can communicate in order to achieve value interconnection in the blockchain world.

In short, whether it is multi-chain, side chain or cross-chain, its purpose is to solve one of the three major problems of the blockchain – scalability.

### 16. Side-Chain

The side chain refers to a block chain embedded between two main chains, which is equivalent to a bridge and connects the main chain data. The generalized side chain refers to the cross-chain technology, which can exchange the two main chains in the practical application of information and value between the chain, often one is the clearing chain, one is the application chain, and the side chain is in the middle clearing chain similar to the people. Bank, responsible for liquidation of funds. The most recognized clearing chain is bitcoin

How does the side chain connect the clearing chain and the application chain? The core logic is not complicated:
1). The key of the clearing chain exists on the side chain.
2). Establish a fast payment channel on the side chain
3). Recharge the funds on the clearing chain to the application chain.

Generalized side chain, which contains three modes: notary, narrow side chain, hash lock.

A notary public refers to a trusted intermediary by a third party or institution, and is a centralized solution, generally used in the private chain or alliance chain;
A narrow side chain refers to a chain that has all the functions of the main chain but is not known by the main chain. Specifically, the block header of the main chain is written to the side chain, and the same consensus algorithm is used for the side chain and the main chain. For example, there is a narrow side chain that connects Bitcoin and the Ethereum network, and uses Bitcoin to run smart contracts on Ethereum.
Hash lock refers to the use of hash technology to lock assets and complete transactions without the need for a trust intermediary. The most famous case of Hash Lock comes from Bitcoin Lightning Network.

The Bitcoin Lightning Network was launched by Poon and Dryja in 2015. Its idea is particularly simple: kicking the transaction outside the Bitcoin blockchain is equivalent to connecting Bitcoin to Alipay and building a fast chain. Payment channel.

Case:
There is no direct connection between A and C, but A, C is connected with B. Therefore, A can pay C to B. However, there is a trust problem at this time: If A gives B to B, and B does not give C, what should I do? At this time, A needs a random number s to help. The random number s is equivalent to a password, and A tells B the hash value H of the random number s. B can only get the money of A by H, so he can only give money to C in the channel established by himself and C, but C can’t get the money.
At this time, A tells C the random number s, and the C hash random number s. If it is equal to H, the money from B to C is taken. After B’s money is taken by C, B also sees s, and takes s to A to give B money.
Trust with the hash lock, and finally let the three parties clear.

If the lightning network can run, the most likely to become B is the major exchanges, they will evolve into transit nodes, some people will lock bitcoin, and the exchange established channels, can improve the efficiency of the entire network.
Four mainstream cross-chain technologies:
1. Notary schemes
2, side chain / relay (Side-chains/relays)
3, Hash-locking (Hash-locking)
4, distributed private key control (Distributed private key control)

Sharing is actually a traditional database technology that divides large databases into smaller, faster, and easier-to-manage parts called data fragmentation (Vitalik Buterin calls it Universe Universes), but applies it to the area. The blockchain can be quite complicated.
Ethereum’s shards, in simple terms, divide the blockchain network into smaller, component-based networks that can handle transactions to achieve a payment system that processes thousands of transactions per second. Set up a blockchain. There are a hundred different universes in this blockchain system. Each universe is a separate account space.
Users can have an account in a universe, and the user-initiated transaction will only affect the transaction-related universe.
If the side chain is “external grafting” to the main chain, then the fragmentation is to “internal division” of the main chain. Obviously, the latter is more difficult to implement than the former.

### 18. Public/Private/Consortium Blockchain

There are three major categories: Public Blockchain, Private Blockchain, and Consortium Blockchain.
The highest degree of decentralization is the public chain. This public blockchain, represented by Bitcoin and Ethereum, is not controlled by third-party agencies. All people in the world can read data records in the chain, participate in transactions, and compete for new blocks. The program developer has no right to interfere with the user, and each participant (ie, the node) can freely join and exit the network, and perform related operations as desired.

The private blockchain is completely reversed. The write permission of the network is completely controlled by an organization or organization. The data read permission is regulated by the organization, either open to the outside or has a certain degree of access restrictions. In simple terms, it can be understood as a weakly centralized or multi-centered system. Because the participating nodes are strictly limited and less; compared with the public chain, the private chain has a relatively short time to reach consensus, faster transaction speed, higher efficiency and lower cost. However, this type of blockchain is more suitable for use within specific organizations, such as the Linux Foundation.

The alliance chain is a blockchain between the public chain and the private chain, which can achieve “partial decentralization.” Each node in the chain usually has an entity or organization corresponding to it; participants participate in the operation of the blockchain by authorizing to join the network and form a stakeholder alliance. To a certain extent, the alliance chain also belongs to the category of the private chain, but the degree of privatization is different. To this end, it also has the characteristics of lower cost and higher efficiency, and is suitable for B2B transactions such as transactions and settlements between different entities.

### 19. What is Oracle?

When you need data that you don’t want to get yourself (or you can’t get!), you need to communicate with a third party like the oracle. there are many reasons.
On the one hand, you may not be able to trust an entity when signing a Bitcoin multi-signature transaction. Let’s say you want a fund to be transferred under certain conditions. Instead of entrusting it to yourself (without entrusting any third party) or entrusting it to a third party for execution (you won’t trust him because he may behave badly), it is better to force multiple signatures with bitcoin to dispatch the transaction approval process. To different signatories (predictive machines?).
The method of using N/M multi-signature transactions is to ensure that each oracle has only one private key, so that the predictor can It believes that the correct time to sign, but the transaction will only be valid when N of the M oracles agree on signing a transaction. This is much more powerful than trusting a single third party, because the chosen predictor may be competing, so the probability of all fraud is low.
The idea of ​​a distributed oracle network has been around for many years, but it is difficult to find consensus on a cross-prophecy communication protocol (Is Orisi one of them?). Finding parties who are willing to join the network is more difficult because of the need to build a good incentive, and we don’t know how to design interactions with this network of predictors. In addition, one of the main limitations may be the data source for which you want to get data, some of which may not be used externally without permission (we’ll discuss this later in more detail).
A predictive marketplace such as Augur or Gnosis is a good and reliable indicator of the changing mood (or knowledge!) of the crowd for the future. Forecasting markets are often referred to as oracles, but predictive markets have different meanings and coverage over the oracles discussed above.
There is another point worth discussing. Do we just want to use the oracle as a price push? In this case, the oracle is just a data source, and most of the time it won’t have any association with the blockchain. Financial institutions often refer to “Bloomberg” or “Reuters” as oracles, but the real meaning is that financial institutions simply use them as data sources. As a real prophetic opportunity to interact with the blockchain, many complex problems arise, which are unwilling to be burdened by some data sources (additional complexity and cost). However, once the appropriate data source and formula are selected, the predictor can access Bloomberg data. Calling “data sources” “prophecy machines” is a misuse of terminology.
For the convenience of description, we define these three types:
1) data source
2) Inquire
3) Prophet / Predictor Network
The data source is the source of the information you are looking for. Depending on your actual query, the data source can be anything. Some examples include “Augur” (view future events/facts), “Bloomberg” (find finance) Data), “Bitcoin blockchain” (find address balance, OP_RETURN content of a transaction or any other blockchain data), “WolframAlpha” (find response to a given Wolfram Alpha query) or .. “network” ? Getting web data sources or API data is the easiest and most common way to get data.
Queries are formulas that you can understand for your chosen data source to provide you with the data you want.
The oracle network is responsible for connecting you to the data source.

Figure 7. Oraclize structure

### 20. Solutions to improve TPS

1) Expansion. At present, the common expansion schemes have state channel and side-chain technology, because these two schemes seem to be relatively mature at present, the main principle of such schemes is actually very simple, that is, the non-essential calculations are not placed in the main block. On the chain, but the final result is confirmed by the main chain. This calculation is not all placed on the main chain, the equivalent of the main chain is liberated, then the speed is naturally faster. Bitcoin expansion and Genaro’s hybrid consensus mechanism are all enhanced by TPS.

2) Reduce the complexity of consensus algorithms. The lower the complexity of the algorithm, the shorter the time to complete the calculation under the same hardware conditions. Genaro is using this method to enhance TPS, and Genaro uses SPoR instead of PoW. SPoR is a proof of data retrievability and does not require a lot of computational power and does not increase over time.

3) Reduce the number of nodes per synchronization. From a technical point of view, reducing the number of nodes per synchronization has a huge impact on TPS. Tested in seven data centers distributed on five continents, the highest performance is achieved when there are only two nodes (Validator/verifier), and TPS will decrease as nodes increase.

4) Sharding. Sharding is a common method in the database, namely parallel computing. Blockchain is essentially a way to store data, so using database optimization is a good idea. So when running some basic operations, using parallel operations, then time is naturally saved.

### 21. TheDAO Attack

The DAO project is a crowdfunding project initiated by blockchain internet of things company Slock.it. Originally, the company only wanted to use DAO (Decentralized Autonomy) to run its own system, the Universal Sharing Network (USN). Later, I found out that this mechanism is also suitable for other projects, so I decided to create The DAO, which means “the mother of DAO”. After being attacked by a smart contract, Ethereum hardly forked out ETH.

Callback
Solidity has a thing called a callback function that has no name, no parameters, no return value, and is triggered under the following conditions:
(1) When the contract is called, if no other function can match the called function or the function that is not specified at all
(2) When the contract receives an ether transfer without a contract
Please note: If you transfer to a contract address, there must be a callback function in the contract, otherwise the transfer will be rejected.
The difference between send and call
Both addr.send(123) and addr.call.value(123)() can be used to transfer 123wei to msg.sender, but
Send: callback function can use up to 2300gas
Call: Pass all the remaining gas of this contract to the contract that accepts the transfer, which means that the contract accepting the transfer can perform more functions with gas.
Conclusion: Use transfer or send, don’t use call

### 22. DAO（Distributed Autonomous Organization)

DAO is sometimes referred to as DAC (Distributed Autonomous Corporation). Whether it is DAO or DAC, it refers to an organizational form that can operate autonomously without intervention and management through a series of open and fair rules. These rules often come in the form of open source software, and everyone can become a participant in the organization by buying shares in the organization or providing services.