Description
During IBD, headers are initially supplied to the node at the headers only stage, in order to determine the most advanced selected tip quickly.
The blocks download stage later asks for the full blocks. However currently the headers too are redownloaded despite already being available.
The reasoning for this is mostly due to simplicity and legacy logic from Bitcoin, where headers are incredibly small. In Kaspa the headers consist of multiple parents' hashes instead of 1, and moreso contain higher level parents' hashes as well. Headers are still small compared to body, but no longer negligibly small, resulting in a small but unnecessary elongation of IBD time and extra bandwidth consumption.
Optimization proposal
Implement a new p2p message to provide block body only, with structure roughly like:
struct block_body{ hash: Hash, txs: Vec<Transaction>, }
,
and have nodes receiving this message construct the block body on their own and match and verify it with the already available header.