Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change OneEraGenTxId to just wrap a ShortByteString #1028

Open
amesgen opened this issue Mar 27, 2024 · 0 comments
Open

Change OneEraGenTxId to just wrap a ShortByteString #1028

amesgen opened this issue Mar 27, 2024 · 0 comments
Assignees

Comments

@amesgen
Copy link
Member

amesgen commented Mar 27, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏗 In progress
Development

No branches or pull requests

2 participants