Derive the block.headers cp_height proof from the last returned header. - #955
Conversation
e3ebdb5 to
2e57c67
Compare
|
The documented precondition Both reference implementations apply it to the returned count. ElectrumX clamps to The effect of the stricter reading is that a request whose served range lies at or below the checkpoint is rejected when the unserved remainder would have exceeded it, and that a request extending past the chain top is rejected rather than clamped. Deriving the proof from the last returned header without moving the guard leaves two different notions of "last" in the same function. This applies the requirement to the height actually proven. The check follows the header index query, because the returned count can be reduced by both the configured maximum and the chain top, so no pre-clamp test is equivalent; it precedes all header serialization, as it does in Fulcrum. The guard cannot be dropped in favor of the query's own Coverage of the chain-top case surfaced libbitcoin/libbitcoin-database#941: |
blockchain.block.headerscomputes thecp_heightbranch from the requested last header, while the returned set is clamped tomaximum_headersand may shorten further under a reorg. The branch then proves a header absent from the response.The protocol defines
branchas the merkle branch of the last returned header, present only when the returned count is non-zero. Both now derive fromlinks.size(). The request bounds check is unchanged: the protocol statesstart_height + (count - 1) <= cp_heightin requested terms.Test: a request over
maximum_headersproves the last returned header, not the requested one. Fulcrum returns the same branch for both.