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

serialization for ShelleyGenesis #1927

Merged
merged 1 commit into from
Oct 21, 2020
Merged

serialization for ShelleyGenesis #1927

merged 1 commit into from
Oct 21, 2020

Conversation

JaredCorduan
Copy link
Contributor

This PR adds ToCBOR and FromCBOR instances for ShelleyGenesis.

I've included round trip property tests and a unit test that maybe counts as a golden test.

closes #1925

Copy link
Contributor

@mrBliss mrBliss left a comment

Choose a reason for hiding this comment

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

LGTM

example :: ShelleyGenesis C
example = exampleShelleyGenesis

b16 = "83a50081824a9db8a41713ad20245f4e00018182510075c40f44e1c155bedab80d3ec7c2190b0a02185e030a05a149e0dab80d3ec7c2190b1864a10082824873ed39075e40d2a6507b208423b1e15f5173ed39075e40d2a682489ac25c873e2248cc507b208423b1e15f519ac25c873e2248ccf6"
Copy link
Contributor

Choose a reason for hiding this comment

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

This works, but good luck finding out what changed when it fails 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea, that's true. Perhaps we should compare the cbor tokens instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

We do something fancy in consensus: we store the bytes in a file, but convert to CBOR in case of a mismatch. We also deal with nested CBOR and actually return a diff of the CBOR. See https://github.com/input-output-hk/ouroboros-network/blob/95c9cd29ed889abe170ab2e9c6e8523b02432f03/ouroboros-consensus-test/src/Test/Util/Serialisation/Golden.hs#L87-L93

I don't think all that is needed here, though. Moreover, we really don't expect the ShelleyGenesis to change anymore 🙂.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, that's much nicer! In order to unblock IntersectMBO/ouroboros-network#2694 I think it makes sense to merge this once CI is happy. and we can make the tests failures easier to read if it becomes a problem. Indeed I do not expect the shelley genesis to change :)

@nc6 nc6 merged commit 846aa00 into master Oct 21, 2020
@iohk-bors iohk-bors bot deleted the jc/serialize-shelley-genesis branch October 21, 2020 08:18
iohk-bors bot added a commit to IntersectMBO/ouroboros-network that referenced this pull request Oct 23, 2020
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.

ToCBOR and FromCBOR instances for ShelleyGenesis
3 participants