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 serialization of OneEraGenTxId to treat it as though it's simply a ShortByteString #1311

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

fraser-iohk
Copy link
Contributor

@fraser-iohk fraser-iohk commented Nov 19, 2024

Description

This PR changes the serialization of OneEraGenTxId so that it's serialized and deserialized as an era-independent ShortByteString rather than as an era-tag-prefixed ShortByteString. As part of this, I've had to make a breaking change to the representation of TxId (GenTx ByronBlock), since there is now no way to identify which kind of Byron-era transaction ID we're deserializing – TxId, CertificateId, UpId, or VoteId – and these are all now represented simply in ByronGenTxId as a Hash.

As this is a breaking change to the wire format, there's a new protocol version and a corresponding branch on ouroboros-network here: fraser-iohk/one-era-gen-tx-id-protocol-version-bump

@fraser-iohk fraser-iohk force-pushed the fraser-iohk/one-era-gen-tx-id-bytestring branch 2 times, most recently from 46a029e to e0cd631 Compare November 21, 2024 01:25
@fraser-iohk
Copy link
Contributor Author

what should happen in the case that the blessed GenTxId era is disabled in the config? should we pick another era arbitrarily? should there be a way to order fallbacks?

          *** Failed! Falsified (after 15 tests):
          WithVersion (HardForkNodeToClientEnabled HardForkSpecificNodeToClientVersion4 (EraNodeToClientEnabled ByronNodeToClientVersion1 :* EraNodeToClientEnabled ShelleyNodeToClientVersion6 :* EraNodeToClientEnabled ShelleyNodeToClientVersion9 :* EraNodeToClientEnabled ShelleyNodeToClientVersion1 :* EraNodeToClientEnabled ShelleyNodeToClientVersion5 :* EraNodeToClientDisabled :* EraNodeToClientEnabled ShelleyNodeToClientVersion5 :* Nil)) (HardForkGenTxId {getHardForkGenTxId = S (S (S (Z (WrapGenTxId {unwrapGenTxId = txid: TxId {unTxId = SafeHash "fb4ea1312616d1a61645991aa8012a3aca2178e121759fb833177201080c5673"}}))))})
          DeserialiseFailure 0 "HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = \"Babbage\"})"
          When deserialising 5820fb4ea1312616d1a61645991aa8012a3aca2178e121759fb833177201080c5673
          Use --quickcheck-replay="(SMGen 1921722396195416107 8896093690400693515,14)" to reproduce.
          Use -p '/Roundtrip.SerialiseNodeToClient.roundtrip GenTxId/' to rerun this test only.

@fraser-iohk fraser-iohk force-pushed the fraser-iohk/one-era-gen-tx-id-bytestring branch from e0cd631 to 78c7730 Compare November 21, 2024 01:30
@amesgen
Copy link
Member

amesgen commented Nov 21, 2024

what should happen in the case that the blessed GenTxId era is disabled in the config? should we pick another era arbitrarily? should there be a way to order fallbacks?

What about picking an era that is supported by all CardanoNodeToXVersions, eg Shelley should work I think?

Related: The next Network release (#1314) will have IntersectMBO/ouroboros-network#5002, such that we can remove all old CardanoNodeToClientVersions that do not support all currently known eras.

@fraser-iohk fraser-iohk force-pushed the fraser-iohk/one-era-gen-tx-id-bytestring branch from 78c7730 to 21b5d07 Compare November 21, 2024 10:43
@fraser-iohk
Copy link
Contributor Author

yeah, I saw the changes in network and kinda feel like this is irrelevant since we're dropping support for older NodeToClientVersions. does picking Shelley have any other risks that would be relevant? I did think about messing with the Arbitrary instances to always pick a sensible era instead

@amesgen
Copy link
Member

amesgen commented Nov 21, 2024

does picking Shelley have any other risks that would be relevant?

I can't think of anything; everything that uses our code shouldn't care about this at all due to #1017; and I don't think that external services (like custom tx submission clients) do either.

@@ -530,9 +567,10 @@ instance CardanoHardForkConstraints c
, (NodeToClientV_17, CardanoNodeToClientVersion13)
, (NodeToClientV_18, CardanoNodeToClientVersion14)
, (NodeToClientV_19, CardanoNodeToClientVersion15)
, (NodeToClientV_20, CardanoNodeToClientVersion16)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we merge this PR before the next node release, we don't need to add NodeToClientV_20, as NodeToClientV_19 hasn't been released yet, so it can be used to enable this change.

@@ -164,8 +166,41 @@ instance SerialiseHFC xs

instance SerialiseHFC xs
=> SerialiseNodeToClient (HardForkBlock xs) (GenTxId (HardForkBlock xs)) where
encodeNodeToClient = dispatchEncoder `after` (getOneEraGenTxId . getHardForkGenTxId)
decodeNodeToClient = fmap (HardForkGenTxId . OneEraGenTxId) .: dispatchDecoder
encodeNodeToClient cc v (HardForkGenTxId (OneEraGenTxId txid)) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we talked about this recently, IIRC we concluded that OneEraGenTxId should wrap a ShortByteString directly instead of an n-ary sum as described in #1028, right?

@fraser-iohk fraser-iohk force-pushed the fraser-iohk/one-era-gen-tx-id-bytestring branch 2 times, most recently from b48b130 to 424139e Compare November 28, 2024 12:18
@fraser-iohk fraser-iohk force-pushed the fraser-iohk/one-era-gen-tx-id-bytestring branch from 424139e to 37690bd Compare November 28, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants