Problem: To send a MSG_BLOCK reply from disk, a node currently decodes the block and serializes it again without witnesses.
For MSG_WITNESS_BLOCK, it already sends the stored bytes directly.
Serving MSG_BLOCK efficiently also matters for the proposed witnessless initial block download. #36476
Fix: For MSG_BLOCK replies from disk on non-Signet chains, read the block into an owned byte buffer and check the header’s proof of work and expected hash.
Walk the serialized transactions directly and strip their witnesses in place.
Signet still uses ReadBlock to verify the Signet solution.
Header checks now run before transaction parsing, so if both the header and transaction data are corrupt, the node may log a different error.
Performance:
| Block | Before | After | Speedup |
|---|---|---|---|
block413567 |
3.204 ms | 0.369 ms | 8.7× |
| Same block with synthetic witnesses | 8.944 ms | 1.026 ms | 8.7× |
The synthetic fixture adds a 512-byte witness item and an empty item to every input.
Related work: This extends the path that sends witness blocks directly from disk. #13151 Earlier work identified unnecessary transaction hashing when serving historical blocks. #13011 discussion · #13098 The implementation also builds on bulk block reads. #31551