Ethereum smart contract development learning 03 - understanding of blockchain and what is mining

Link block

Block 1 will be recorded in chronological order from the first transaction until the data volume reaches 1 MB, and subsequent transactions will be recorded in block 2 until the data volume reaches 1 MB, and so on. These blocks are data blocks. They are linked one after another. To this 每个区块会根据其内部数据串生成一个特殊的(数字)签名end, . If there is any change in the data in this block, even if only one number is changed, the signature of this block will also change.

Even if the data stored in block 1 changes a number, it will get a completely different signature! As long as the signature of block 1 is added to block 2, the data of block 1 can be associated with block 2. 区块 1 的签名也包含在区块 2 的数据串内, So this signature, like other data in block 2, becomes the data basis of block 2 signature

Immutability of blockchain

If the tamper modifies the data and the signature changes, other users on this chain will know that the data in the block has been changed. In order to maintain the immutability of the blockchain, other users will refuse to synchronize the changed transaction information, and still maintain the original transaction record unchanged, and the entire chain will remain intact.

Data signature (ASH-256), as long as the current bit of data changes, the generated signature will change. Therefore, if the tamperer modifies the data, the 签名将改变original block always remains in the following blocks Sign, at this time the signature changes, the link between the two blocks is broken, and so on, 如果篡改者想要修改某个区块的数据,就必须保证篡改之后的区块仍然都联系在一起,他需要重新计算当前区块以及后面的所有区块的签名it can be considered that it is almost impossible (calculating the signature of a chain requires the miner to have enough computing power, even more than other people in the entire network The total computing power, otherwise he will never catch up with other miners).

Cryptographic hash function: Substituting any data string as an input value into the formula can get a unique 64-bit output value

Mining

并非所有的签名都符合要求. The blockchain protocol will pre-determine some requirements. In order to obtain a qualified block signature, the input data string needs to be changed repeatedly. However, because the transaction data and metadata (block number, timestamp, etc.) need to remain the same, each A section of data of a specific length that can be changed is also added to the block. When you want to add a block to the chain, you can continuously change this piece of data until you find a qualified signature, and then determine the specific value of this piece of data. This piece of data is the nonce of the block. The nonce is not predetermined data, but a string of completely random numbers that should be found out according to actual needs.

In summary, the block contains: 1. transaction data; 2. the signature of the previous block; 3. nonce. This 通过反复更改 nonce、对区块数据进行哈希运算、寻找合格签名的过程就叫做 挖矿is what miners do. Miners invest a lot of electricity, convert it into computing power, and continue to substitute nonce for hashing until a qualified signature (output) is found. The more computing power a miner has in his hands, the faster the hash calculation, and the higher the probability of finding a qualified signature first. This is a process of trial and error.

How to prevent miners from adding forged transaction data to the blockchain?

Only the person in charge of the private key can spend the funds in the corresponding address, and the miner does not know your private key, and others can only verify whether a transaction is initiated by you through your public key. So fake transactions are not feasible

Guess you like

Origin blog.csdn.net/weixin_43958804/article/details/108636606