Skip to content

Conversation

geo2a
Copy link
Contributor

@geo2a geo2a commented Jul 25, 2025

Fixes tweag/cardano-peras#65

Changes

  • Changes in the HFC types:
    • EraParams now keeps track of an optional Peras round length.
    • Bound now keeps track of an optional Peras round number.
    • In the Serialise instances for EraParams and Bound, the encoders generate different CBOR depending on whether of not the Peras-relate components are present. The decoders act differently depending on the length of the CBOR list.
    • The EraSummary, while not modified directly, is now Peras-aware via EraParams and Bound:
      • in a valid summary, Peras round length must divide the epoch size. See the changes in EraSummarys haddock and in invariantSummary's implementation.
  • Changes in the HFC time translation queries:
    • Two new top-level queries are exposed from Ouroboros.Consensus.HardFork.History.Qry:

      perasRoundNoToSlot :: PerasRoundNo -> Qry SlotNo
      slotToPerasRoundNo :: SlotNo -> Qry PerasRoundNo
    • add a roundtrip test that ensures that converting Peras round number to a slot and then back is an identity is added into the Test.Consensus.HardFork.Summary module.

    • add a Peras-specific test into Test.Consensus.HardFork.History module.

Suggested review order

Even though this PR affects many files, the bulk of the changes is localised. I suggest the following review order:

  • First review the datatype and codec changes in ouroboros-consensus/Ouroboros/Consensus/HardFork/History/EraParams.hs and ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/History/Summary.hs
  • Proceed to review the time translation query changes in ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/History/Qry.hs
  • Then review the newly added tests in consensus-test/Test/Consensus/HardFork/History.hs and consensus-test/Test/Consensus/HardFork/Summary.hs

@geo2a geo2a force-pushed the geo2a/peras-issue-65-hfc-time-translation branch 3 times, most recently from 92a6a38 to c4855c3 Compare July 25, 2025 11:44
@amesgen amesgen changed the title Make the HFC aware of Peras roudns Make the HFC aware of Peras rounds Jul 29, 2025
@geo2a geo2a force-pushed the geo2a/peras-issue-65-hfc-time-translation branch 2 times, most recently from 14af58e to a5270ce Compare July 29, 2025 10:36
@geo2a geo2a force-pushed the geo2a/peras-issue-65-hfc-time-translation branch 3 times, most recently from 1ef48a5 to 0f53af2 Compare August 7, 2025 10:39
(ledgerReachesEra2 reachesEra2)
$ property True
)
Reflection.give HardFork.EraParamsWithoutPerasRoundLength $
Copy link
Member

Choose a reason for hiding this comment

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

Drive-by comment: Why does this need to show up here (and lots of other places)? We didn't have to do this when preserving compatibility for GenesisWindow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, is is not needed here. I got entangled in typeclasses and I'm in the process of getting disentangled.

One difference from GenesisWindow is that PerasRoundLength unfortunately needs to be mentioned in era bounds (the Bound type), so their serialization needs to change as well. Hence, there will be bit a little more calls to given, but I'll work on minimizing their amount and removing the redundant ones.

@geo2a geo2a force-pushed the geo2a/peras-issue-65-hfc-time-translation branch 4 times, most recently from 5e21004 to 07b1213 Compare August 7, 2025 14:26
@geo2a geo2a force-pushed the geo2a/peras-issue-65-hfc-time-translation branch 7 times, most recently from 6ce05b1 to 9b35a39 Compare September 2, 2025 15:10
- Add `PerasRoundLength`
- HFC: translate between Peras rounds and slots
@geo2a geo2a force-pushed the geo2a/peras-issue-65-hfc-time-translation branch from 9b35a39 to 06465a9 Compare September 2, 2025 15:16
@geo2a geo2a marked this pull request as ready for review September 2, 2025 16:16
@geo2a geo2a requested a review from amesgen September 2, 2025 16:16
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.

2 participants