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

Made some preparations for Conway era #3216

Merged
merged 1 commit into from
Jan 23, 2023
Merged

Made some preparations for Conway era #3216

merged 1 commit into from
Jan 23, 2023

Conversation

Soupstraw
Copy link
Contributor

@Soupstraw Soupstraw commented Dec 15, 2022

Description

This PR makes some changes in preparation for the Conway era. The changes are based on IntersectMBO/formal-ledger-specifications#40.

Rule graph

   BBODY
    |
    |-------------------------------|
    v                               v
   TICK                            LEDGERS
    |                               |
    |---------|                     |
    v         v                     v
   RUPD     ~NEWEPOCH~            ~LEDGER~
              |                     |
              |----------|          |--------|-------------------|-----------|
              v          v                   v                   v           v
            ~EPOCH~     +ENACTMENT+         DELEGS              UTXOW       +TALLY+
              |                              |                   |
              |---------|------------|       v                   |
              v         v            v      DELPL                v
             SNAP      POOLREAP    -UPEC-    |                  UTXO
                                             |--------|          |
                                             v        v          v
                                            POOL     DELEG     ~UTXOS~

-..- Removed
+..+ Added
~..~ Modified

New typeclasses

This PR turns some data types into typeclasses. PPUPState and PPUPPredFailure are now closed type families parametrized by era. This makes it easy to swap out fields of those types in Conway and future eras. I also added a new type family TallyState which has a nullary constructor NoTallyState in all eras before Conway.

Changes to rules

The old PParam update logic got replaced with governance actions and with that I got rid of the UPEC rule and added TALLY and ENACTMENT rules. The TALLY rule has been implemented as specified in the formal specification. ENACTMENT is just a stub for now.

Conway transaction body

Since protocol parameters are no longer a part of TxBody, I added a getter for the PParamsUpdate in the transaction body that returns an empty update starting from conway. This got rid of some protocol version constraints and made it possible to reuse some functions from previous eras.

Ledger state

The ledger state datatype now has a tally state. In pre-Conway eras this field uses the datatype of ShelleyTallyState which only has a nullary constructor, but in the Conway era it is a map of governance action ID to governance action state, which stores information about the governance action and all the votes that the action has received.

This PR also adds an EraTallyState class that specifies the type instance of TallyState in that era and also provides a way to create an empty TallyState of that type.

resolves #3147
resolves #3148
resolves #3159

Checklist

  • Commit sequence broadly makes sense
  • Commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Any changes are noted in the changelog
  • Code is formatted with ormolu (which can be run with scripts/ormolise.sh
  • Self-reviewed the diff

@Soupstraw Soupstraw force-pushed the jj/conway-tally branch 6 times, most recently from 5eb57d7 to d9d983e Compare December 19, 2022 16:14
@Soupstraw Soupstraw force-pushed the jj/conway-tally branch 7 times, most recently from f2e169f to c591901 Compare January 3, 2023 14:23
@Soupstraw Soupstraw force-pushed the jj/conway-tally branch 12 times, most recently from f829af1 to 6f2be71 Compare January 9, 2023 11:56
@Soupstraw Soupstraw marked this pull request as ready for review January 9, 2023 11:56
@Soupstraw Soupstraw requested review from lehins and aniketd January 9, 2023 11:56
@Soupstraw Soupstraw changed the title Add TALLY rule to conway Made some preparations for Conway era Jan 9, 2023
@Soupstraw Soupstraw requested a review from JaredCorduan January 9, 2023 12:54
@Soupstraw Soupstraw force-pushed the jj/conway-tally branch 2 times, most recently from 00c3395 to a9bfac5 Compare January 13, 2023 13:54
@Soupstraw Soupstraw requested a review from lehins January 13, 2023 13:54
@Soupstraw Soupstraw force-pushed the jj/conway-tally branch 17 times, most recently from f650268 to 626de04 Compare January 19, 2023 15:01
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

I haven't matched it to the spec, but I think @JaredCorduan already did that and I am sure we'll be going through the rules in the end again anyways. Implementation wise it looks great. Few minor remarks, like redundant constraints and such, but nothing terribly important.

There was a couple of prior comments that were marked as resolved, but in fact weren't resolved, so I unresolved them. I am sure it was an accident, but mentioning it just in case.

Massive work, great job @Soupstraw!

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Ledger.hs Outdated Show resolved Hide resolved
eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs Outdated Show resolved Hide resolved
eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs Outdated Show resolved Hide resolved
eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs Outdated Show resolved Hide resolved
eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Epoch.hs Outdated Show resolved Hide resolved
@JaredCorduan
Copy link
Contributor

I haven't matched it to the spec, but I think @JaredCorduan already did that and I am sure we'll be going through the rules in the end again anyways.

yes to both!

Massive work, great job @Soupstraw!

💯 ☝️

@Soupstraw Soupstraw force-pushed the jj/conway-tally branch 3 times, most recently from a7c8167 to 5d4c8e3 Compare January 23, 2023 11:10
Made `PPUPState` and `PPUPPredFailure` into type families so that we can
switch out the concrete instances in Conway and future eras.

Added `EraTallyState` type family so that we don't have to make
`LedgerState` into a type family and we can just set the tally state to
a unit in pre-Conway eras.
@Soupstraw Soupstraw merged commit 551eaab into master Jan 23, 2023
@iohk-bors iohk-bors bot deleted the jj/conway-tally branch January 23, 2023 16:53
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.

Conway era mapping Updated NEWEPOCH transition replace PPUP transition
4 participants