Home  >  Article  >  Bitcoin full node synchronization too slow? SPV mechanism that can verify payments without using a full node

Bitcoin full node synchronization too slow? SPV mechanism that can verify payments without using a full node

DDD
DDDforward
2024-03-06 13:22:22368browse

Since its birth, Bitcoin has been criticized for wasting power resources, but its powerful computing power is a necessary process, and it is difficult to find a better way to replace it.

As it has been around for longer and longer, more and more people are participating in transactions on its underlying technology blockchain, and the content of the distributed ledger has expanded rapidly, SAToshi NakamotoThe storage amount of 1 MB set for a block limits the transaction process and transaction speed.

Therefore, downloading the entire ledger has become a headache. Can you not download the entire ledger, but only find the parts that are relevant to you? In other words, find a filter and keep the useless stuff out.

So the SPV mechanism appeared.

01. SPV mechanism

##The full name of SPV is "Simplified Payment Verification", common translation For simple payment verification. Its purpose is to verify whether a certain transaction exists, but it cannot verify the legality of the transaction. This requires a two-step operation. The first step is to confirm whether the transaction payment has been verified. The second step is to calculate how many confirmations have been obtained.

Satoshi Nakamoto mentioned this concept in his paper:

It is still possible to verify transactions when not running a full node. Users only need to keep the longest chain All block header data on.

To put it simply:

If Xiao Hei transfers a Bitcoin to Da Bai, how can Da Bai know that the transaction of the coin has been completed? It is impossible to find witnesses in a decentralized system.

According to the traditional method: Dabai needs to download all the blockchain ledgers, and then find Xiaohei’s account. First, check whether it has such a Bitcoin before, and whether it has been transferred to Dabai. Record. Just the first step caused Dabai's storage capacity to explode.

The block capacity of each Bitcoin is 1 MB, and the block header is only 80 KB, so you only need to download the block header to save a lot of space.

What exactly are block headers and block bodies?

Compare the block header to a person's head, which stores the block's header information, such as hash value, timestamp, etc.; while the block body is similar to a person's entire body, storing Detailed data of this block, such as specific transaction information. The block header is included in the block body.

That is to say, although a block header has a hash value, after downloading the block header, Dabai still cannot know which block the transaction is recorded in.

At this time, you need to find the full transaction ID with the transaction ID. The node checks to see if it exists and in which block it is.

02. SPV payment verification process

Hey, what if the miners and Xiaohei join forces to deceive Dabai?

This is where the SPV mechanism comes in handy.

If the miners say that Xiao Hei has turned around, he has not.

Then in order to lie, he must forge more transactions so that these transactions can get the same hash value as in his own block header. However, due to the technical characteristics of hashing, it is difficult to achieve the same hash value of the changed data as the original data.

In short, the entire transaction process of SPV is as follows:

The first step is to confirm whether the transaction payment has been verified

. First calculate the transaction hash value of the payment to be verified, save the block header from the blockchain network to the local, and then obtain the Merkel tree hash authentication path corresponding to the payment to be verified from the blockchain.

Compare whether the obtained hash value is consistent with your own. If they are consistent, it proves that the payment is genuine and valid.

The second step,

verify how many confirmations

have been obtained. Based on the position of the block header, the number of confirmations that the payment has received is determined. After completing these two steps, the transaction payment verification is completed.

03. Summary

The SPV mechanism not only

saves storage space

, but also reduces the waste of P2P network bandwidth, allowing ordinary users to complete the download without It can also be operated without data, and it also brings great convenience to auditing accounts. However, since SPV does not have complete block data, it cannot verify that the transaction does not exist. This situation can easily lead to double spending, and random link nodes may also be maliciously attacked by the network.

Do you think there are any other advantages and disadvantages of SPV?

Welcome to share your views in the message area.

The above is the detailed content of Bitcoin full node synchronization too slow? SPV mechanism that can verify payments without using a full node. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:zhihu.com. If there is any infringement, please contact admin@php.cn delete