The getImmutableBlockPoint callback in Cardano.Network.LedgerPeerConsensusInterface.LedgerPeersConsensusInterface receives a Point RawBlockHash, where RawBlockHash wraps a ShortByteString of arbitrary length apparently.
On the consensus side, in ouroboros-consensus-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/Node.hs, when we use getImmutableBlockPoint, we have to convert that raw hash into a block-specific HeaderHash blk. Previously ConvertRawHash was very lax about hash length, and hashSize value was not enforced by conversion methods from/to HeaderHash.
With [Peras 25.5] PR we are improving the ConvertRawHash class to be more explicit about expected hash length, and ensure the hash length invariant is respected during conversions (FTR, the old functions are still available but have been prefixed by unsafe to indicate that they do not enforce the invariant).
So, ideally, in getImmutableBlockPoint, when the RawBlockHash size doesn't match the expected one for HeaderHash blk, we would like to be able to return a proper error value instead of a fatal error.
Suggestion
Add a constructor ImmutableBlockInvalidHashSize Int Int to GetImmutableBlockPointError type in Cardano.Network.LedgerPeerConsensusInterface
The
getImmutableBlockPointcallback inCardano.Network.LedgerPeerConsensusInterface.LedgerPeersConsensusInterfacereceives aPoint RawBlockHash, whereRawBlockHashwraps aShortByteStringof arbitrary length apparently.On the consensus side, in
ouroboros-consensus-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/Node.hs, when we usegetImmutableBlockPoint, we have to convert that raw hash into a block-specificHeaderHash blk. PreviouslyConvertRawHashwas very lax about hash length, andhashSizevalue was not enforced by conversion methods from/toHeaderHash.With [Peras 25.5] PR we are improving the
ConvertRawHashclass to be more explicit about expected hash length, and ensure the hash length invariant is respected during conversions (FTR, the old functions are still available but have been prefixed byunsafeto indicate that they do not enforce the invariant).So, ideally, in
getImmutableBlockPoint, when theRawBlockHashsize doesn't match the expected one forHeaderHash blk, we would like to be able to return a proper error value instead of a fatalerror.Suggestion
Add a constructor
ImmutableBlockInvalidHashSize Int InttoGetImmutableBlockPointErrortype inCardano.Network.LedgerPeerConsensusInterface