Bitcoin Forum
November 17, 2024, 04:36:14 PM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: "How does it work?"How do full nodes generate Merkle path?  (Read 204 times)
accelerating (OP)
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
October 17, 2018, 03:41:00 AM
 #1

How do full nodes generate Merkle path(MP)?

As you see. Full nodes generate a MP and give it to a SPV node which request it for verify a transaction when full nodes get the request.

How to get a MP? I don't see any more information. And that's my naturally guess: it's like getting it for the first time, from the leaf nodes ,hash and hash... , until the Merkle root. Then getting the path as required.

Is that true? Each time a request is received from a SPV node, there is a operation involve all the leaf nodes? Is there any other way to reduce computation?

Thanks for your time.
Heisenberg_Hunter
Legendary
*
Offline Offline

Activity: 1584
Merit: 1280


Heisenberg Design Services


View Profile WWW
October 17, 2018, 07:08:43 AM
 #2

Merkle Paths are mostly used by Light Wallets for verifying weather a particular transaction is included in the particular block.

How to get a MP? I don't see any more information. And that's my naturally guess: it's like getting it for the first time, from the leaf nodes ,hash and hash... , until the Merkle root. Then getting the path as required.

Is that true? Each time a request is received from a SPV node, there is a operation involve all the leaf nodes?
Once the Light Wallet requests the Full Node for the Path, it receives a response with the block header and the particular transactions along with merkle paths. A full node is the one that generates the merkle path. Consider that once the block is picked up, the transaction is double hashed and the double hashed data is stored in each leaf node. Then 2 leaf node hashes are picked up and hashed again resulting in another leaf. This hashing is continued till the merkle root is achieved. Since these are double hashed until achieving merkle root, the size of a root  will always be 32 bytes. This root hash is stored along with the block header.

Once the Light Wallet requests the Block for verifying the transaction using the bloomfilter,  the Full Node responds with a MSG_MERKLEBLOCK message. It contains the block header with the merkle path. Light Wallet then verifies the transaction and blocks. Since the Light Wallets just receive few Kb's of data rather than the whole block size, they are lesser in size.

Quote
Is there any other way to reduce computation?
I don't think so there is a way to reduce the computation happening. Correct me if I am wrong.
ABCbits
Legendary
*
Offline Offline

Activity: 3066
Merit: 8091


Crypto Swap Exchange


View Profile
October 17, 2018, 07:19:39 AM
Merited by Isildur (official) (1)
 #3

How do full nodes generate Merkle path(MP)?
--snip--
How to get a MP? I don't see any more information. And that's my naturally guess: it's like getting it for the first time, from the leaf nodes ,hash and hash... , until the Merkle root. Then getting the path as required.

Basically get all transaction hash in a block and do the merkle tree operation.

Full nodes only send necessary/part of merkle tree to verify the transaction.

This image/ilustration might help you : https://cdn-images-1.medium.com/max/1600/0*lR_IMzUjQUJgXq5A.png

Is that true? Each time a request is received from a SPV node, there is a operation involve all the leaf nodes? Is there any other way to reduce computation?

AFAIK full nodes client store such information to prevent re-computation, but each full nodes client use have different method/implementation.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!