区块链order节点,区块链每个节点记录全部数据
近年来,随着区块链技术的发展,区块链order节点也变得越来越重要。order节点是区块链网络中的一种特殊节点,它负责排序交易,并将交易数据写入区块链。
order节点的主要功能是排序和记录交易,每个节点都会记录全部的交易信息,以保证数据的完整性和可靠性。order节点还会检查交易的完整性,防止交易数据被篡改或遗漏。
order节点有助于提高数据安全性,它可以防止黑客篡改交易数据,确保交易数据的完整性和可靠性。此外,order节点还可以提高交易的效率,因为它可以将交易数据分配到不同的节点,从而提高网络的吞吐量。
另外,order节点还可以帮助提高网络的可用性,因为它可以将交易数据分发到不同的节点,从而保证网络的可用性。
总之,order节点是区块链网络中不可或缺的一部分,它可以提高数据安全性、交易效率以及网络可用性,为区块链应用提供了坚实的基础。
请查看相关英文文档
Ⅰ What is Blockchain
In the simplest terms, a blockchain is a distributed ledger.
To understand what this means, we first have to look at its opposite: a centralized ledger. Because blockchain technology started with finance, we will also introduce it below using banks as an example.
The following is our process for using bank debit card transactions:
You can swipe your card to purchase goods in stores.
The merchant sends a statement to your bank for the agreed upon amount.
Your bank will verify that you may have authorized the purchase.
The bank sends the money to the merchant.
Finally, the bank records this information in its ledger.
There’s a lot of technology involved here, but that’s basically it. The last step is important - the bank records all transactions made by the customer. This ledger goes all the way back to the first transaction the bank made.
This ledger is kept, maintained and regulated by the bank. You can read it in your online bank account, but you can't change it. The bank has complete control. If it decides to make a change, there's nothing you can do about it.
Crucially, if hackers were able to access a bank’s ledger, that could cause a lot of problems. They can change the account balance to make it look like certain transactions never occurred, etc.
This is why distributed ledgers are so cool.
Blockchain Network Visualization
If a bank operates on a distributed ledger, each member of the bank will have a copy of the ledger, and whenever any member of the bank When they make a purchase, they tell every other member of the bank.
Each member will validate the transaction and add it to the ledger (the added records are called "blocks"). This has some important benefits, as there is no centralized authority that can manipulate records. Hackers accessing one ledger won't be a big problem because other ledgers can easily verify it.
On the other hand, it requires a lot of work. In short, the second system is blockchain (at least in financial scenarios).
As mentioned above, blockchain is a decentralized list of transactions. If I send Xiao Ming 2 Bitcoins, I send a message to everyone in the network saying "I am sending Xiao Ming 2 Bitcoins" and they all record the transaction.
The future of blockchain, how will it change our lives?
One thing that is important about blockchain is that it is a public resource and no one really owns it because everyone owns it.
Blockchain is not just science fiction. We don't need to careUnderstand the mechanisms behind this technology, but you need to understand that it may completely change our lives in the next 20 years.
This may sound bold, but remember, 20 years ago we were browsing the Internet on Netscape, using state-of-the-art Motorola flip phones, and buying our first DVD players. At that time, if we imagined that a computer could be held in our hands and that we could buy cars, make payments, and watch movies, it would have been considered a fantasy.
Although the impact of blockchain may not be as obvious as the Internet, nor as tangible as mobile phones, blockchain will effectively solve many worries in daily life. Such as intermediaries cheating people, transaction delays, etc. In our current lives, middlemen are everywhere and we take them for granted as a part of life. If one day these intermediaries cease to exist, you will find that the world will become a different place.
Imagine that by 2040, blockchain may become a mature and widely used technology. When one day you can't live without the blockchain just like you can't live without the Internet now, you will be surprised to find that this decentralized accounting technology has simplified the complexity and become a part of your lifestyle
Ⅱ Bitcoin Mining and Consensus (2)
The third step of the Bitcoin consensus mechanism is to independently verify each new block through each node in the network. When a new block is propagated in the network, each node performs a series of tests to verify it before forwarding it to its peers. This ensures that only valid blocks are propagated across the network.
Independent verification also ensures that blocks generated by honest miners can be included in the blockchain and receive rewards. Blocks produced by miners who behave dishonestly will be rejected, which not only causes them to lose rewards, but also wastes opportunities to find solutions to the proof of work, thus causing losses in their electricity bills.
When a node receives a new block, it will verify the block against a long list of criteria. If it does not pass the verification, the block will be rejected. These criteria are available in the Bitcoin Core client's CheckBlock function and CheckBlockHead function
It includes:
Why don't miners record a transaction for themselves to get thousands of Bitcoin?
This is because each node verifies blocks according to the same rules. An invalid coinbase transaction will invalidate the entire block, which will cause the block to be rejected and, therefore, the transaction will not become part of the ledger. Miners must construct a perfect block, based on rules shared by all nodes, and mine according to the correct proof-of-work solution, and they spend a lot of electricity mining to do this. If they cheat, all that power and effort will be wasted. This isWhy independent verification is an important part of decentralized consensus.
The final step in Bitcoin's decentralized consensus mechanism is to assemble blocks into the chain with the largest proof of work. Once a node validates a new block, it will attempt to connect the new block to the existing blockchain, assembling them.
Nodes maintain three types of blocks: the first is connected to the main chain, the second is branched from the main chain (standby chain), and the last is in the known chain No known parent block found. During the verification process, once any non-compliance with the standards is found, the verification will fail, and the block will be rejected by the node, so it will not be added to any chain.
At any time, the main chain is the blockchain that has accumulated the most difficulty. In general, the main chain is also the chain that contains the most blocks, unless there are two chains of equal length and one of them has more proof of work. The main chain will also have some branches, and the blocks in these branches are "sibling" blocks to the blocks on the main chain. These blocks are valid but not part of the main chain. The purpose of retaining these branches is that if at some point in the future one of them is extended and exceeds the main chain in difficulty value, subsequent blocks will reference them.
If a node receives a valid block but its parent block is not found in the existing blockchain, then the block is considered an "orphan block". Orphan blocks will be stored in the orphan block pool until their parent blocks are received by the node. Once the parent block is received and connected to the existing blockchain, the node will remove the orphan block from the orphan block pool and connect it to its parent block, making it part of the blockchain. When two blocks are mined within a short time interval, nodes may receive them in reverse order. At this time, the orphan block phenomenon will occur.
After selecting the blockchain with the highest difficulty, all nodes finally reach a consensus across the entire network. Temporary differences in the chain will eventually be resolved as more proof of work is added to the chain. Mining nodes "vote" to choose which blockchain they want to extend. When they mine a new block and extend a chain, the new block itself represents their vote.
Because the blockchain is a decentralized data structure, different copies cannot always be consistent. Blocks may arrive at different nodes at different times, resulting in nodes having different full views of the blockchain.
The solution is that each node always chooses and tries to extend the blockchain that represents the largest cumulative proof of work, that is, the longest or greatest cumulative work chain. . By accumulating the workload of each block on the chain, the node obtains the total amount of proof of work required to establish the chain. As long as all nodes choose the blockchain with the longest accumulated work, the entire Bitcoin network will eventually converge toConsistent status. Forks are temporary differences that occur between different blockchains. When more blocks are added to a fork, this problem will be solved.
Note that the blockchain forks described in this section occur automatically due to transmission delays in the global network.
However, inverted triangle blocks are not discarded. It is linked to the parent block of the star chain and forms the backup chain. Although node
This is a chain re-consensus, as these nodes are forced to modify their position on the blockchain and include themselves in the longer chain. Any miners working on extended star-inverted triangles will now stop doing so because their candidates are "orphans" because their parent "inverted triangle" is no longer the longest chain.
Transactions within the "inverted triangle" are reinserted into the mempool for inclusion in the next block because the block they are in is no longer in the main chain.
The entire network returns to a single chain state, star-triangle-rhombus, with the "rhombus" becoming the last block in the chain. All miners immediately start working on candidate blocks with "diamond" as the parent block to extend this star-triangle-diamond chain.
Theoretically, the fork of two blocks is possible. This happens when miners who are opposed to each other due to the previous fork discover two different blocks almost at the same time. solution.
However, the chance of this happening is very low. Single block forks happen every week, while double block forks are very rare. Bitcoin’s block interval is designed to be 10 minutes, which is a compromise between faster transaction confirmation and lower probability of forks. Shorter block generation intervals will allow transaction settlement to be completed faster, and will also lead to more frequent blockchain forks. In contrast, longer intervals reduce the number of forks but result in longer liquidation times.
Since 2012, Bitcoin mining has developed a solution to the limitations of the basic structure of the block header. In the early days of Bitcoin, miners could mine a block by traversing the random number (Nonce) to obtain a hash that meets the requirements.
After the difficulty increases, miners often still fail to produce a block after trying 4 billion values. However, this is easily solved by reading the timestamp of the block and calculating the elapsed time. Because the timestamp is part of the block header, its changes allow miners to traverse it again with different random values. As mining hardware reaches speeds of 4GH/sec, this approach becomes increasingly difficult because the nonce values are used up within a second.
When ASIC mining machines appeared and quickly reached TH/secondAfter the hash rate is reached, the mining software needs more space to store nonce values in order to find valid blocks. You can move the timestamp a little further, but moving it too far in the future will cause the block to become invalid.
Block headers require a new "revolution" in information sources. The solution was to use coinbase transactions as a source of additional randomness. Since coinbase scripts can store 2-100 bytes of data, miners started using this space as a source of additional randomness, allowing them to explore a much larger block header. range of values to find valid blocks. This coinbase transaction is contained in a merkle tree, which means that any changes to the coinbase script will result in changes to the Merkle root.
8 bytes of extra nonce, plus 4 bytes of "standard" nonce, allow miners to try 2^96 (8 followed by 28 zeros) possibilities per second without having to Modify timestamp. If future miners pass through all the above possibilities, they can also solve it by modifying the timestamp. Likewise, there is more extra space in the coinbase script to prepare for future nonce expansion.
Bitcoin’s consensus mechanism means that it is very difficult for miners (or mining pools) to try to cheat or destroy it using their own computing power, at least in theory. As we said before, the consensus mechanism of Bitcoin relies on the premise that the vast majority of miners, out of consideration for maximizing their own interests, will maintain the entire Bitcoin system through honest mining. However, when one or a group of miners with a large amount of computing power in the entire system appears, they can destroy the security and reliability of the Bitcoin network by attacking the Bitcoin consensus mechanism.
It is worth noting that a consensus attack can only affect the future consensus of the entire blockchain, or at most, it can affect the consensus of several blocks in the near past (up to 10 blocks in the past). And over time, the entire Bitcoin blockchain becomes less and less likely to be tampered with.
In theory, a blockchain fork can become very long, but in fact, the computing power required to achieve a very long blockchain fork is very, very large. The currency blockchain is gradually growing, and past blocks can basically be considered to be unable to be tampered with by forks.
At the same time, consensus attacks will not affect the user's private key and encryption algorithm (ECDSA).
Consensus attacks also cannot steal Bitcoins from other wallets, pay Bitcoins without a signature, redistribute Bitcoins, change past transactions, or alter Bitcoin holding records. The only impact a consensus attack can have is affecting the most recent blocks (up to 10) and affecting the generation of future blocks through denial of service.
A typical scenario of consensus attack is the "51% attack". Imagine such a sceneScene, a group of miners control 51% of the computing power of the entire Bitcoin network, and they unite to attack the entire Bitcoin system. Since this group of miners can generate the vast majority of blocks, they can intentionally create block chain forks to achieve "double spending" or block specific transactions or attack specific wallet addresses through denial of service.
Blockchain fork/double-spend attack refers to the attacker not recognizing a recent transaction and reconstructing a new block before this transaction, thereby generating a new fork and then achieving Double payment. With the guarantee of sufficient computing power, an attacker can tamper with the last 6 or more blocks at once, thereby making the transactions contained in these blocks that should not be tampered disappear.
It is worth noting that double-spending can only be performed on transactions that occur in a wallet owned by the attacker, because only the owner of the wallet can generate a legitimate signature for a double-spending transaction. An attacker performs a double-spend attack on his own transaction, which is profitable if he can invalidate the transaction so that he will not be paid for an irreversible purchase.
The attacker Mallory bought a triptych painting (The Great Fire) depicting the great Satoshi Nakamoto from Carol’s gallery. Mallory traded with Carol by transferring Bitcoin worth US$250,000. After waiting for one instead of six transactions to be confirmed, Carol safely wrapped the painting set and handed it to Mallory. At this time, one of Mallory's associates, Paul, a man from a mining pool with a large amount of computing power, started a 51% attack when the transaction was written into the blockchain.
First, Paul used the computing power of his mining pool to recalculate the block containing the transaction, and replaced the original transaction with another transaction in the new block (for example, directly transferred to Mallory's another wallet instead of Carol's), thereby enabling a "double spend". This "double-spend" transaction uses the same UTXO as the original transaction, but the payee is replaced with Mallory's wallet address.
Then, Paul used the mining pool to calculate an updated block based on the forged block. In this way, the block chain containing this "double payment" transaction was higher than the original block chain. a block. At this point, the higher-level forked blockchain replaced the original blockchain, and the "double-spend" transaction replaced the original transaction for Carol. Carol neither received the $250,000 worth of Bitcoins, nor the original one. Three priceless paintings were also taken away by Mallory in vain.
During the entire process, other miners in the Paul mining pool may not have noticed anything unusual about this "double payment" transaction from beginning to end, because the mining program is running automatically and will not always Monitor every transaction in every block.
In order to avoid this type of attack, merchants selling bulk goods should wait until the transaction has received 6 confirmations from the entire network before delivering the goods. Alternatively, merchants should use a third-party multi-signature account to conduct transactions, and also wait until the transaction account has received multiple confirmations from the entire network before delivering the goods. The more confirmations a transaction has, the harder it is to be tampered with by an attacker through a 51% attack.
For bulk commodity transactions, it is convenient and efficient for buyers and sellers to use Bitcoin to pay, even if the goods are shipped 24 hours after payment. After 24 hours, the number of network-wide confirmations of this transaction will reach at least 144 (which can effectively reduce the possibility of being attacked by 51%).
It should be noted that a 51% attack does not require an attacker to have at least 51% of the computing power to launch it. In fact, even if it owns less than 51% of the system With enough computing power, you can still try to launch this kind of attack. The reason why it is named a 51% attack is simply that when the attacker's computing power reaches the 51% threshold, his attack attempt will almost certainly succeed.
In essence, a consensus attack is like the computing power of all miners in the system being divided into two groups, one group is the honest computing power, and the other group is the attacker's computing power. Both groups are There is a scramble to calculate new blocks on the blockchain, only for the attacker’s computing power to calculate carefully constructed blocks that include or exclude certain transactions. Therefore, the less computing power the attacker has, the less likely he is to win in this showdown.
From another perspective, the more computing power an attacker has, the longer the forked block chain he deliberately creates may be, and the recent blocks may be tampered with or the future may be controlled by him. There will be more blocks. Some security research organizations have used statistical models to conclude that a computing power of 30% of the entire network is enough to launch a 51% attack. The rapid increase in the computing power of the entire network has made it no longer possible for the Bitcoin system to be attacked by a single miner, because it is no longer possible for a miner to occupy even 1% of the computing power of the entire network.
To be added
To be added
Ⅲ Introduction to Blockstack
1. Overview
Blockstack is a decentralized application The new Internet, equipped with a comprehensive set of open source development tools to build and bootstrap a decentralized ecosystem of applications and protocols. Users own their data, the browser is all they need to get started, and Blockstack is the “Google” of blockchain.
Blockstack is a blockchain browser application that integrates decentralized data, decentralized applications, and decentralized user data.
In the so-called distributed Internet, users have ownership of their identities, and data is bound to their identities and stored on their own private devices or in the cloud, thus eliminating dependence on third-party institutions. And developers can develop pointsDistributed applications run locally, call the user's API, and access user data with the user's permission, eliminating the need to consider data storage issues. In this way, Blockstack returns data sovereignty to users. User data is kept by users and no third party can access user data without user permission. Since users have data sovereignty, they can transfer it as they wish without being restricted by the platform.
2. Implementation Principle of Blockstack
Blockstack builds an isolated naming system on top of the underlying blockchain. The underlying blockchain is used to record the status changes of "name-value" pairs. Using the consensus protocol of the blockchain, various operations in the naming system (such as naming registration, update, transfer, etc.) can be The entire network reaches a consensus and cannot be tampered with.
Blockstack adopts the idea of separating the data plane and the control plane to separate naming control and naming related data.
The control plane includes the underlying blockchain and the virtual chain above it, which defines the protocol for registering names and creating name-identity bindings.
The data plane is responsible for data storage, mainly including
(1) zone file used to find data through hash value or URL
(2) External storage (Dropbox, S3, IPFS, etc.). Data is signed by the key pair corresponding to the name to which it is bound. The client reads data from the data plane and verifies its integrity and authenticity using the data hash in the zone file and the name owner's public key.
This idea of separation of the data plane and the control plane makes Blockstack not attached to any specific blockchain, which means that users can choose different blockchains according to their own needs
/>
3. Levels of Blockstack
In order to realize naming and storage functions, Blockstack has four levels: the blockchain layer and virtual chain layer of the control plane, and the routing layer and data storage layer of the data plane. . The specific implementation is shown in the figure below
1. Blockchain Layer
The blockchain layer is at the bottom and mainly provides two services:
(1) Blockstack Each operation is encoded in the transaction record of the underlying blockchain, and the blockchain layer is responsible for storing the sequence of operations of Blockstack;
(2) Provide consensus for the order of operations written to the blockchain.
2. Virtual chain layer (Virtualchain Layer)
The virtual chain layer is the core of Blockstack, defining various operations of Blockstack nodes, and only Blockstack nodes can perceive this layer. Although simple blockchain nodes can read the original text of the operation, But it cannot be parsed.
The virtual chain layer also defines rules for accepting and rejecting Blockstack operations. For example, a registered naming operation is accepted only if no other user has registered the name yet.
3. Routing Layer
Blockstack separates the routing request (how to find the data) from the actual data storage, which gives the user a choice of data storage. You can choose commercial cloud storage (such as Amazon S3, or Dropbox) or your own private storage or p2p storage system.
Routing information is stored in zone files, which are almost identical in form to DNS zone files, as shown in the figure above. The virtual chain binds the name to the hash value of the zone file and stores it in the control plane, while the zone file itself is stored in the routing layer (the current implementation is to store it in a distributed hash table). Users can fully trust the routing layer because users can compare the zone file with the hash value of the control plane at any time to verify whether the zone file has been modified.
4. Storage Layer
The storage layer is where users actually store data. All data will be signed by the key pair corresponding to the name owner. Through this off-chain storage method, users can store data of any size, and because the hash value of the data is stored in the control layer, users do not have to worry about data being tampered with.
There are two ways to store data in the storage layer: volatile storage and non-volatile storage. The difference between the two mainly lies in whether the zone file is modified at the same time when modifying the data. It is suitable for situations where the data often needs to be modified, and when the data is rarely modified.
5. Naming system
Blockstack uses a four-layer structure to implement a distributed naming system. The name belongs to the address of the underlying blockchain and the corresponding private key. Like Namecoin, users need to pre-order (preoder) before they can register (register) their name. The first user to successfully write scheduled operations and registration operations to the blockchain can gain ownership of a name. After the name is registered, the user can use the update command to send updated data to the name. Users can also use the transfer operation to transfer the name to another address. Revoke) command can temporarily terminate the operation of this name.
4. Summary
Blockchain technology has brought exciting prospects to the Internet. The distributed naming and storage system allows users to retain absolute control over their identities and data. Third-party programs that want to access user data require user authorization. Although the Blockstack project is not yet very mature, its design ideas and concepts are very consistent with the future development direction of the Internet, and it is also a model for the implementation of blockchain technology.
https://zhuanlan.hu.com/p/29823215
IV Components of Blockchain
The components of Blockchain are as follows:
Openness: The system data of the blockchain is open and transparent, and everyone can participate. For example, when renting a house, you can know the previous rental information of the house. There have been no problems, and of course some personal and private information here is encrypted.
Autonomy: The blockchain adopts consensus-based specifications and protocols (such as a set of open and transparent algorithms), and then each node operates according to this specification, so that everything is completed by machines , there is no human element. This changes trust in people to trust in machines, and any human intervention has no effect.
The information cannot be tampered with: If the information is stored in the blockchain, it will be saved permanently and there is no way to change it. As for the 51% attack, it is basically impossible to achieve.
Anonymity: There is no personal information on the blockchain, because it is all encrypted and is a string of letters and numbers, so your various ID card information and phone number will not appear. Numbers are being resold.
IV Ethereum Technology Series - Ethereum Data Structure
This article will introduce to you the data structure of Ethereum. In the last article, we mentioned that in order to implement smart contracts, Ethereum This feature uses an account-based model. Let’s take a look at the data structure in Ethereum.
Since it is an account-based model, we need to find the status of the account through the account address. Just like you can find various information about you in the bank through your bank card number. The simplest idea is of course a simple hash table where the key is the account address and the value is the account status. But there is a problem here that cannot be solved.
How do light nodes verify the legitimacy of accounts?
As we said in the previous article, there are two types of nodes in the blockchain, full nodes and light nodes. Light nodes only store block headers, so how can light nodes verify whether the account is legal?
This idea is consistent with the md5 verification we usually use. We will perform a hash operation on the information in the block to obtain the unique determination of the information in the block.The value is the same in all nodes of the blockchain.
In this process, we use a data structure Merkle Tree (hash tree). Let's first look at the schematic diagram of the Merkle Tree (hash tree).
The last article mentioned that the linked list (hash chain) in the blockchain is different from our usual linked lists in that the pointer is changed from the address to the hash pointer. The same is true here, hash tree and binary tree There are 2 differences
1. Change the address to a hash value
2. Only leaf nodes store data
Back to the previous question How do light nodes verify whether an account or transaction is on the chain?
The entire process is shown in the figure above
1. Light nodes need to determine whether an account is legal
2. Light nodes only store block headers , so when you get an account, you will send a request to the full node
3. The full node stores all account status and returns the hash value in the account path that needs to be calculated to the light node< br />
4. The light node calculates the root hash value locally. If the calculation result is consistent with its own storage, the account is legal. If it is inconsistent, the account is illegal.
Is this the data structure of account information in Ethereum?
There are two problems with directly using such a data structure to store account information
Difficulty in searching
The generated hash value is uncertain
The first problem should be easier to find. The complexity required to find an account in this tree is O(n), because there is no order.
The second problem is actually caused by disorder. In disordered combination, the hash values generated by each node for the same batch of accounts are inconsistent, which makes it impossible to reach a consensus.
Since both problems are related to order, can we solve the problem by using a hash sorting tree, similar to a binary sorting tree?
Using a sorted tree will bring about another problem
Insertion difficulties
Because the tree must be maintained in order, it is likely to cause Big changes to the tree structure.
Another data structure dictionary tree is used in Ethereum. Unlike hash trees, dictionary trees should be used in many places. Let’s take a brief lookThe structure of a dictionary tree.
The dictionary tree can better solve the two shortcomings of the hash tree: 1. Difficulty in searching; 2. The generated hash value is uncertain and one of the shortcomings of the sorted binary tree is the difficulty of insertion.
But in the dictionary tree, we can see that the depth of the tree may be very deep due to some elements.
At this time we can further optimize and compress the same path. This is a compressed dictionary tree.
Combining the hash tree and the compressed dictionary tree, you can get the final data structure of the Ethereum storage account - MPT.
Just change the pointers in the compressed dictionary tree from addresses to pointers, and store the data in the leaf nodes.
After introducing the data structure of the status tree, we next discuss a question, what is the scope of the account status stored in the block. There are 2 options.
Only the account status of transactions generated in the block at that time is saved.
Save all global accounts.
We can look at these two methods, which are nothing more than a balance between space and time. Saving only the transactions generated in the current block means lazy loading (finding accounts only when needed). This cost is very high in the blockchain because the account you are looking for has never traded before, which will traverse the entire blockchain. Although another method of saving global accounts seems to consume a lot of space, it is fast to search, and we can optimize the space problem through other methods. So in the end, Ethereum chose the second method of reporting an error to all global accounts in every block.
Let’s take a look at how the state tree is saved in Ethereum.
You can see that although each block in Ethereum saves all accounts, it will point the unchanged account status to the previous node, and only store the changed status. This can Optimize space usage to the greatest extent.
After introducing the more complex state trees in Ethereum, we continue to look at the other two trees in Ethereum, the transaction tree and the receipt tree.
First, let me introduce why transaction tree & receipt tree are needed.
1. Transaction tree
/> Although Ethereum is an account-based model, just like a bank, it not only stores the balance of the bank card, but also stores how each money in the card came from and how it was spent. The transaction tree stores all transactions included in the current block.
2. Receipt tree
Since the introduction of smart contracts has added a lot of complexity, Ethereum uses a receipt tree to store some additional information about transaction operations. For example, the execution log during the transaction process is included in the receipt tree for easy query. There is a one-to-one correspondence between the receipt tree and the transaction tree. There is a receipt for every transaction that occurs.
Unlike the state tree, the transaction tree and the receipt tree only maintain transactions that occur in the current block, because when a transaction occurs in the block, there is no need to search for another transaction, which means that it may be traversed before. Search operation of the entire blockchain.
Due to the fast block generation speed in Ethereum, we will face the problem of difficulty in traversing a large amount of data when we query some eligible transactions. The introduction of Bloom filters in the receipt tree can help us effectively alleviate this difficulty.
The Bloom filter performs a hash operation on each element in the large set and maps it to a smaller set. At this time, when another element comes to determine whether it is in the large set, there is no need to traverse the entire set. For a large set, perform a hash operation to find whether it exists in a small set. If it does not exist, it is definitely not in the large set. If it exists, it cannot explain any problems.
As shown in the figure above, the Bloom filter can only prove that an element is not in the set, but cannot prove that an element is in the combination.
If we want to find a certain transaction in many blocks in Ethereum, we can use the Bloom filter to filter out blocks where the target transaction definitely does not exist, and then enter the receipt tree Continue to use the Bloom filter to filter, and the remaining transactions are the possible target transactions, and you can compare them one by one.
We introduced the core data structures of Ethereum, state tree & transaction tree & receipt tree. They all use the same data structure - hash compression dictionary tree. However, the status tree maintains a global account tree, and the transaction tree and receipt tree maintain transactions or receipts within this block.
After introducing the data structure, we will use several articles to introduce some core algorithms in Ethereum, such as consensus mechanism, mining algorithm, etc.
VI Blockchain Technology
Background: After the birth of Bitcoin, it was discovered that the technology was very advanced, and blockchain technology was discovered. Bitcoin and blockchain technology were discovered at the same time.
1.1 The purpose of the birth of Bitcoin:
① Currency transactions are recordedRecords, that is, ledgers;
② Disadvantages of centralized institutions’ accounting—can be tampered with; Yi Chaofa
Bitcoin solves the first problem: anti-tampering—hash function p>
1.2 Hash function (encryption method)
① Function: Convert a string of any length into a fixed-length (sha256) output. The output is also called a hash value.
② Features: It is difficult to find two different x and y such that h(x)=h(y).
③Application: md5 file encryption
1.3 Blockchain
①Definition
Block: Split the general ledger into zones Block storage
Blockchain: On each block, add a block header. It records the hash value of the parent block. By storing the hash value of the parent block in each block, all blocks are connected in order to form a blockchain.
②How does the blockchain prevent transaction records from being tampered with?
After the blockchain is formed, tampering with any transaction will cause the hash value of the transaction block to be different from that of its sub-blocks. , tampering was discovered.
Even if you continue to tamper with the hash value in the sub-block header, the hash value in the sub-block will be different from that in the grandchild block, and the tampering will be discovered.
1.4 The essence of blockchain
①The essence of Bitcoin and blockchain: a big ledger visible to everyone, only recording transactions .
②Core technology: Through cryptographic hash function + data structure, it ensures that the ledger records cannot be tampered with.
③Core function: Create trust. Fiat currency relies on government credibility, and Bitcoin relies on technology.
1.5 How to trade
① To conduct transactions, you need an account number and password, corresponding to the public key and private key
Private key: a string of 256-bit binary numbers , no application is required to obtain it, and you don’t even need a computer. You can generate the private key by tossing a coin 256 times.
The address is converted from the private key. The address cannot reverse the private key.
The address is the identity, which represents the ID in the Bitcoin world.
After an address is generated, it can only be known by everyone if it enters the blockchain ledger.
②Digital signature technology
Signature function sign (Zhang San’s private key, transfer information: Zhang San transfers 10 yuan to Li Si) = signature of this transfer
< p> Verify Korean verify (Zhang San’s address, transfer information: Zhang San transfers 10 yuan to Li Si, this transferAccount signature) = TrueZhang San uses his own private key to sign this transaction through the signature function sign().
Anyone can verify whether the signature was issued by Zhang San himself who holds Zhang San's private key by verifying the Korean vertify(). It returns true, otherwise it returns false.
sign() and verify() are cryptographically guaranteed not to be cracked. ·
③Complete the transaction
Zhang San will provide the transfer information and signature to the entire network. Under the premise that the account has a balance, after verifying that the signature is true, it will be recorded in the blockchain ledger. Once recorded, Zhang San's account will be reduced by 10 yuan, and Li Si's account will be increased by 10 yuan.
Supports one-to-one, one-to-many, many-to-one, and many-to-many transactions.
In the Bitcoin world, private keys are everything! ! !
1.6 Centralized Accounting
① Advantages of Centralized Accounting:
a. No matter which center keeps accounts, don’t worry too much
< p> b. Centralized accounting, high efficiency②Disadvantages of centralized accounting:
a Denial of service attack
b Stop service after getting tired
p>c Central institutions are vulnerable to attacks. For example, destroying servers and networks, committing self-intrusion, legal termination, government intervention, etc.
All attempts at confidential currencies with centralized institutions in history have failed.
Bitcoin solves the second problem: how to decentralize
1.7 Decentralized accounting
①Decentralization: Everyone can keep accounts. Everyone can keep a complete ledger.
Anyone can download open source programs, participate in the P2P network, monitor transactions sent around the world, become an accounting node, and participate in accounting.
② Decentralized accounting process
After someone initiates a transaction, it is broadcast to the entire network.
Each accounting node continues to monitor and continue transactions across the entire network. When a new transaction is received and the accuracy is verified, it is put into the transaction pool and continues to be propagated to other nodes.
Due to network propagation, the transactions of different accounting nodes at the same time are not necessarily the same.
Every 10 minutes, one person is selected from all accounting nodes in a certain way, and his transaction pool is used as the next block and broadcast to the entire network.
ItsIts node deletes the transactions that have been recorded in its own transaction pool based on the transactions in the latest block, continues accounting, and waits for the next selection.
③ Features of decentralized accounting
A block is generated every 10 minutes, but not all transactions within these 10 minutes can be recorded.
The accounting node that obtains the accounting rights will be rewarded with 50 Bitcoins. After every 210,000 blocks (approximately 4 years), the reward is halved. The total amount is about 21 million, and it is expected to be mined in 2040.
Recording the reward of a block is also the only way to issue Bitcoin.
④ How to allocate accounting rights: POW (proof of work) method
Compete for accounting rights by calculating mathematical problems on several accounting points.
Find a random number that makes the following inequality true:
There is no other solution except traversing the random numbers starting from 0 and trying your luck. The process of solving the problem is also called mining.
Whoever solves the problem correctly first will get the accounting rights.
If a certain accounting node finds the solution first, it will announce it to the entire network. After other nodes verify that it is correct, a new round of calculation will start again after the new block. This method is called POW.
⑤ Difficulty adjustment
The generation time of each block is not exactly 10 minutes
As Bitcoin develops, the computing power of the entire network does not increase.
In order to cope with changes in computing power, the difficulty will be increased or decreased every 2016 blocks (about 2 weeks), so that the average time for each block to be generated is 10 minutes.
#欧易OKEx# #BTC[超话]# #digital currency#
Ⅶ How does the blockchain prevent data tampering?
Block Chain is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
Different from traditional distributed storage, the uniqueness of blockchain distributed storage is mainly reflected in two aspects: First, each node of the blockchain Complete data is stored according to the block chain structure. Traditional distributed storage generally divides the data into multiple parts for storage according to certain rules. Second, the storage of each node in the blockchain is independent and has equal status, relying on the consensus mechanism to ensure the consistency of storage, while traditional distributed storage generally synchronizes data to other backup nodes through the central node.
No node can record ledger data independently, thus avoiding the possibility of a single bookkeeper being controlled or bribed to record false accounts. Also because there are enough accounting nodes, theoretically speaking, the accounts will not be lost unless all nodes are destroyed, thereby ensuring the security of the accounting data.
Transaction information stored on the blockchain is public, but account identity information is highly encrypted and can only be accessed with authorization from the data owner, thus ensuring data security and personal privacy. .
Blockchain proposes four different consensus mechanisms, which are suitable for different application scenarios and strike a balance between efficiency and security.
Based on the above characteristics, this data storage technology can perfectly prevent the possibility of data tampering. In reality, it can also be applied to many fields. It is better than our electronic certificate storage technology in electronic contract signing. provides a safer and more reliable guarantee.
Ⅷ What is blockchain mining and what does it do? Detailed introduction to blockchain and virtual currency
When Bitcoin was first released, people discovered that it was decentralized and not It is controlled by any center; it is completely open, except for the encryption of transaction information, the entire system information is highly transparent, and the technology is open source; security, as long as you cannot control %51 of all nodes, you cannot modify the data arbitrarily, which makes it relatively safe ; Independence, the entire model and Bitcoin do not rely on any third party, all nodes verify and exchange data within the system without any intervention
Here we explain in detail what blockchain technology is, to put it bluntly It’s block + chain, so what is “block”? What is a "chain" again?
A block is a ledger. Transaction accounting is completed by multiple nodes distributed in different places, and each node records a complete account, so they can all participate in supervising the legality of the transaction, and at the same time Can jointly testify for it
Each block contains the cryptographic hash of the previous block, the corresponding timestamp, and the transaction data (usually a hash value calculated using the Merkle tree algorithm) represents), this design makes the block content difficult to tamper with. Distributed ledgers connected by blockchain technology can effectively record transactions between two parties and permanently verify the transaction.
The function of the hash function h(): convert a string of any length into a fixed-length (for example, 256 bits) output. The output is also called a hash value. This output is irreversible
It is difficult to find two different x and y such that h(x) = h(y), that is, two different inputs, There will be different output. Theoretically, two different inputs may have different outputs, but this is almost impossible. For example, if an infinite space is mapped to a finite space, there must be a many-to-one situation. The theory exists, but there are no rules. It is guaranteed that you cannot find this result through any mathematical inference. Why is it 256 bits here? Isn't it longer? Because 256 bits are secure enough.
Split the ledger into blocks. For example, a piece of paper in a book is a block. Each block records transactions within a period of time, such as 10 minutes
We compare each piece of paper to a block, and add a part of content on each block. We call it the block header, which records the hash value of the parent block. Through each block Store the hash value of the parent block, and connect all blocks smoothly to form a blockchain
Record the hash value of block 1 to the block header of block 2, and do this every time The block header of each block records the hash value of the parent block, and each block is linked in order. This is called a blockchain. The first block has no block header and is also called the genesis block
The blockchain is a ledger. Only when transactions occur in the ledger will the money in your account increase. If you need to make a transaction, you first need an account number and password. Just like your bank card has an account number and password, others can make a transfer to you. The account password on the block ledger is the public key and private key
Lao Wang (who already has a private key and a public key) wants to transfer 10 BTC to Zhang, which requires some operations
It is proved that Lao Wang himself issued the transfer signature function Sign (Lao Wang’s private key + Transfer information: Lao Wang transferred 10 BTC to Zhang San) = signature of this special account
The verification is that Lao Wang himself issued the transfer verification function Verify (Lao Wang’s address + Transfer details: Lao Wang transferred 10 BTC to Zhang San) + Signature of this transfer) = true
Once the transfer is recorded in the block, no one can change it. Zhang San will increase it by 10 BTC, and Lao Wang will decrease it by 10 BTC accordingly. The entire operation is automatic, such as your wallet The app will help you do this. The app knows your private key, you tell the wallet the transaction content, the wallet signature is announced to the entire network, and it waits for others to verify the transaction
Centralized accounting The efficiency will be higher. Banks, governments or Alipay will keep accounts for you, which is very reliable, because they can't touch your money unless they have your private key
There are some disadvantages in centralized accounting< /p>
In decentralization, everyone can keep accounts, and everyone can keep a complete ledger. Anyone can download open source programs, participate in Bitcoin's p2p network, monitor transactions sent from all over the world, become an accounting node, and participate in accounting. Suppose Xiaoyi releases a transaction and broadcasts it to the entire network, and accounting node A listens. When this transaction arrives, A verifies that the transaction bit is true and puts it into the transaction pool to continue to spread to other nodes. Because it is spread through the network, the transaction pools of different accounting nodes are not necessarily the same at the same time. Every 10 minutes, from all accounting nodes Among the nodes, select one according to a certain method. After verifying that the transaction of this node is true, then compare the transaction records in the transaction pool of this selected node with the transaction records in the transaction pool of your own (A) node. The comparison is completed. Afterwards, you will be selected in the trading pool.The transactions recorded by the accounting node are deleted, and the other accounting nodes continue to record and wait for the next selection. Every 10 minutes is a cycle. During this 10 minutes, all accounting nodes record accounts normally, and another node is selected after 10 minutes. Treat the transactions in its transaction pool as a new block. This block comes from the transaction pool of an accounting node I randomly selected among all the accounting nodes, and so on.
The transaction is not blocked. The recording is completed. Only when the transaction becomes a certain block, the transaction is truly completed. This is a complete accounting process of decentralization. Your transaction will not be recorded immediately because the p2p network propagation takes time. If the node of the selected block has not received your transaction, the transaction will be not done. A block is generated every 10 minutes, but not all transactions within 10 minutes can be recorded. 10 minutes is just an average value
Due to the characteristics of decentralized accounting, accounting nodes with accounting rights will receive a 50BTC reward every ten minutes, which is about the same for every 210,000 blocks. In 4 years, the reward is halved. Bitcoin has been halved twice since its issuance. Then a new block is generated every ten minutes. The reward for this accounting node is 10.5 BTC. If it is halved every 4 years, the total number of BTC can be calculated. The amount is approximately 21 million, and it is expected to be mined in 2040. Recording the reward of a block is also the only way to issue Bitcoin. When BTC is mined, the only income that the accounting node can obtain is the transaction fee.
Accounting nodes compete for accounting rights through questions,
Find a certain random number that makes the equation invalid
SHA256 hash function (random number + parent block hash value + Transactions in the transaction pool) A certain specified value)
There is no other solution except traversing the random numbers starting from 0 and trying luck. The process of solving the problem is also called mining, so the accounting node that solves this problem is also called mining. It’s called a miner. The faster you traverse random numbers, the greater the possibility of getting the accounting rights. This traversal speed is called computing power by mine bosses. In order to obtain this computing power, mine bosses will Purchase more mining machines with higher computing power
Whoever solves the problem correctly first will get the accounting rights. Accounting node A is the first to find the solution, which is announced to the entire network. After other nodes verify that it is correct, node A obtains the block, gains 12.5 BTC, and restarts a new round of calculation after the new block. This method is called (POW) allocating accounting rights
It usually takes about 10 minutes to solve this random number. 10 is not absolute, because the process of solving this problem is a process of luck. In response to changes in computing power in the future, Bitcoin will increase or decrease the difficulty every 2016 blocks, about two weeks, so that the average block generation time is ten minutes
Each block contains BeforeA block's encrypted hash, corresponding timestamp and transaction data (usually represented by a hash value calculated using the Merkle tree algorithm), this design makes the block content difficult to tamper with. Distributed ledgers connected by blockchain technology can effectively record transactions between two parties and permanently verify the transaction.
Different from traditional stored data, each node of the blockchain stores complete data according to the block chain structure. Each node of the blockchain is independent and has equal status, relying on The consensus mechanism ensures storage consistency, while traditional distributed storage generally synchronizes data to other backup nodes through a central node.
Mahjong is a traditional Chinese blockchain project. A group of four miners work together. The miner who first collides with the correct hash value of 13 numbers can obtain the accounting rights and be rewarded.
Many people say that blockchain is a scam and Bitcoin is a scam. This may be a scam, but this technology has been widely recognized and applied. The cryptography knowledge involved in blockchain can only be used by ordinary people. Even if you don’t understand it, the most important thing is to look at the problem from a relatively rational perspective. Don’t let the wind be the rain.
There is something incredible about this technology. It maintains absolute order without a center or supervision. This is the trust that only needs to be established by everyone’s consensus. Bitcoin created this consensus, and in the blockchain In the world everyone is fair and equal.
IX Nodes in the blockchain network include
Nodes in the blockchain network include mobile phones, mining machines, servers, etc.
Nodes refer to computers in the blockchain network. Blockchains are participated by a large number of individuals or family users. Each individual or family is a node of the blockchain.
Blockchain is composed of small blocks. Everyone who forms a block node does not know each other, but they trust each other because they also have a common purpose, which is to obtain the rewards of the mechanism.
- 上一篇: 区块链跟金融有关系吗知乎,区块链跟金融有关系吗
- 下一篇: 芝麻区块链