IntersectMBO/ouroboros-consensus

Change `OneEraGenTxId` to just wrap a `ShortByteString`

amesgen opened this issue · 0 comments

Currently, OneEraGenTxId (used for the HFC's GenTxId) is an n-ary sum:

newtype OneEraGenTxId xs = OneEraGenTxId { getOneEraGenTxId :: NS WrapGenTxId xs }

Since #1017, motivated by #1009, we already compare these based on the underlying hash, ignoring the index of the n-ary sum:
-- | This instance compares the underlying raw hash ('toRawTxIdHash') of the
-- 'TxId'.
--
-- Note that this means that transactions in different eras can have equal
-- 'TxId's. This should only be the case when the transaction format is
-- backwards compatible from one era to the next.
instance CanHardFork xs => Eq (OneEraGenTxId xs) where
(==) = (==) `on` oneEraGenTxIdRawHash
-- | See the corresponding 'Eq' instance.
instance CanHardFork xs => Ord (OneEraGenTxId xs) where
compare = compare `on` oneEraGenTxIdRawHash

As mentioned in #1009 (comment), the logical next step is to change OneEraGenTxId to

newtype OneEraGenTxId xs = OneEraGenTxId { getOneEraGenTxId :: ShortByteString }

to get rid of the n-ary sum completely.

This will require changes to the serialization format, and we will need to keep compatibility with the previous format for some time (it might be fine to not do this for Byron).