Skip to content

Conversation

@ninioArtillero
Copy link
Collaborator

@ninioArtillero ninioArtillero commented Nov 13, 2025

Description

Closes tweag/cardano-conformance-testing-of-consensus#52

This PR creates a separate module to accommodate the (orphan) instances needed to serialize/deserialize a GenesisTest as JSON; we take this approach to avoid spreading changes throughout the codebase during this phase of development.

As specified in our design, conformance-test-runner consumes a test file that specifies (at least) a PointSchedule to run.
It turns out our peer simulator would need access to the whole of a GenesisTest data, which will contain the PointSchedule in particular.

In #3, the relevant instances were introduced for the PointSchedulealone. All this changes are moved into the aforementioned module.

@ninioArtillero ninioArtillero force-pushed the ninioArtillero/json-instances branch from f098597 to 110bd18 Compare November 13, 2025 19:34
@ninioArtillero ninioArtillero force-pushed the ninioArtillero/json-instances branch from 2a1c03c to fde4cf8 Compare November 17, 2025 19:40
@ninioArtillero ninioArtillero marked this pull request as ready for review November 17, 2025 19:42
Comment on lines +125 to +136
instance (ToJSON a, ToJSON b) => ToJSON (AnchoredSeq v a b) where
toJSON anchoredSeq =
object
[ "anchor" .= anchor anchoredSeq
, "sequence" .= toOldestFirst anchoredSeq
]

instance (Anchorable v a b, FromJSON a, FromJSON b) => FromJSON (AnchoredSeq v a b) where
parseJSON = withObject "AnchoredSeq" $ \obj -> do
a <- obj .: "anchor"
s <- obj .: "sequence"
pure $ fromOldestFirst a s
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I used the AnchoredSeq interface to implement the instances, instead of going down to StrictFingerTree as suggested. The reason being that I found no way of deconstructing it and leverage the StrictFingerTree instance.

Comment on lines +17 to +18
-- Note that most of the constraints in this instance declarations are caused
-- by the abstraction of the block type parameter.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At this point I've just made this compile. Still need to test that we can DO serialize a concrete block (the TestBlock I guess).

Copy link
Collaborator

@isovector isovector left a comment

Choose a reason for hiding this comment

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

looks great!

(ToJSON (HeaderHash blk), HasHeader blk, ToJSON schedule, ToJSON blk) =>
ToJSON (GenesisTest blk schedule)
where
toEncoding = genericToEncoding defaultOptions
Copy link
Collaborator

Choose a reason for hiding this comment

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

why does this instance have toEncoding but the others do not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Figure I would be returning later to implement a custom instance, so it's like a little queue.

@ninioArtillero ninioArtillero added this pull request to the merge queue Nov 18, 2025
Merged via the queue into develop with commit 7148f94 Nov 18, 2025
1 check passed
@ninioArtillero ninioArtillero deleted the ninioArtillero/json-instances branch November 18, 2025 19:47
isovector pushed a commit that referenced this pull request Nov 19, 2025
# Description

Closes tweag/cardano-conformance-testing-of-consensus#52

This PR creates a separate module to accommodate the (orphan) instances
needed to serialize/deserialize a `GenesisTest` as JSON; we take this
approach to avoid spreading changes throughout the codebase during this
phase of development.

As specified in our design, `conformance-test-runner` consumes a test
file that specifies (at least) a `PointSchedule` to run.
It turns out our peer simulator would need access to the whole of a
`GenesisTest` data, which will contain the `PointSchedule` in
particular.

In #3, the relevant instances were introduced for the
`PointSchedule`alone. All this changes are moved into the aforementioned
module.
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