Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: 1t0ph20 on March 17, 2017, 02:50:23 PM



Title: Compact Blocks: How are blocks validated in high bandwidth mode?
Post by: 1t0ph20 on March 17, 2017, 02:50:23 PM
Hi! Quick clarifying question.

Compact blocks can be used in both high-bandwidth mode and low-bandwidth mode. In high-bandwidth mode, peer A (sending to B) validates just the block header then relays cmpctblock.

My question is what if the rest of the block is invalid? If the majority of the network was using compact blocks in high-bandwidth mode, wouldn't this mean many only partially validated blocks circulating the network?

Thanks!


Title: Re: Compact Blocks: How are blocks validated in high bandwidth mode?
Post by: achow101 on March 17, 2017, 03:26:23 PM
No. The partially validated block may propagate but nodes will still validate it fully and then reject the block if it is invalid. Relaying a block before validation does not mean that the block will never be validated by the node; the node will still validate it fully.


Title: Re: Compact Blocks: How are blocks validated in high bandwidth mode?
Post by: 1t0ph20 on March 17, 2017, 04:15:47 PM
Thank you for the reply.  A follow up then, how are the compact blocks uncompressed (if you get relayed a cmpctblock)?


Title: Re: Compact Blocks: How are blocks validated in high bandwidth mode?
Post by: achow101 on March 17, 2017, 04:19:47 PM
Thank you for the reply.  A follow up then, how are the compact blocks uncompressed (if you get relayed a cmpctblock)?
The compact block contains shortened versions of the transaction ids in a block. The node, when it receives the cmpctblock message, will calculate the shortened txids of all of the transactions that it has in its mempool. It retrieves the transactions that have matching shortened txids from the mempool in order to rebuild the full block. If it cannot find a transaction, it will request it from the peer that sent it the cmpctblock message. In this way the block is relayed without needing to actually send all of the data for the block when the block is relayed; most, if not all, of the transactions in the block will likely be found in the node's mempool and can be rebuilt from there.


Title: Re: Compact Blocks: How are blocks validated in high bandwidth mode?
Post by: 1t0ph20 on March 17, 2017, 06:12:30 PM
Great explanation! Thank you!