Skip to content

Added Dijkstra era #5030

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

Merged
merged 1 commit into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ jobs:
- cardano-ledger-conway
- cardano-ledger-conway-test
- cardano-ledger-core
- cardano-ledger-dijkstra
- cardano-ledger-mary
- cardano-ledger-shelley
- cardano-ledger-shelley-ma-test
Expand Down
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ packages:
eras/babbage/test-suite
eras/conway/impl
eras/conway/test-suite
eras/dijkstra
eras/mary/impl
eras/shelley/impl
eras/shelley/test-suite
Expand Down
32 changes: 32 additions & 0 deletions docs/NewEra.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
### Adding a new era to `cardano-ledger`

First you need to crate a new sub-package in the `eras` directory.
It's easiest to just copy the `.cabal` file from the previous era and then make
some changes to that. Change the name of the project to `cardano-ledger-<era>`
and update the description/synopsis.

Next you'll want to add a datatype to represent the new era (e.g. `ConwayEra`).
Then copy over the entire test suite from the previous era and substitute the
era types for the newly added era type. Once the tests are in place, the type
checker will guide you to add all the necessary type family and type class
instances. You might need to make some of the tests era-generic. See which tests
don't yet take an era type annotation and modify those test if possible. The tests
that can be made era-generic should be moved to the `testlib` of the era where
they were first introduced, and any era-specific tests should reside in the test
suite package of that era.

Add the `Cardano.Ledger.<era>.Core` module and re-export the `Core` module from
the previous era. Use the `Core` module from the current era whenever you need
to import anything from the core module. Do the same for
`Cardano.Ledger.<era>.State`.

It's a good idea to re-use the data types defined in the previous era at first.
You might need to use `coerce` in a couple of places to change the era parameter
when translating these types. Also, there might be some constraints that expect
the era to be exactly the previous era, you will probably be able to generalize
these functions and type class instances to make them compatible with the new era.

For `EraRule` instances use the same rules as in the previous era.

Make sure to update `.github/ci/haskell.yml` so that the job also runs the test
suite of the newly added era.
19 changes: 18 additions & 1 deletion eras/conway/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,26 @@

## 1.20.0.0

* Add:
* `alonzoToConwayUtxosPredFailure`
* `alonzoToConwayUtxosEvent`
* `getConwayScriptsNeeded`
* `getConwayMinFeeTxUtxo`
* `getConwayMinFeeTx`
* `conwayRedeemerPointer`
* `conwayRedeemerPointerInverse`
* `transMintValue`
* `transTxBodyId`
* `transVotingProcedures`
* `transProposal`
* `transTxCertV1V2`
* `transPlutusPurposeV1V2`
* `guardConwayFeaturesForPlutusV1V2`
* `transTxInInfoV3`
* Remove era parametrization from `GovPurposeId`, `GovRelation`
* Move to `testlib` the `DecCBOR` instance for `TxBody ConwayEra`
* Add `ReferenceInputsNotDisjointFromInputs`
- Remove `ConwayNewEpochPredFailure` and replace it with `Void`. #5007
* Remove `ConwayNewEpochPredFailure` and replace it with `Void`. #5007
* Added to `PParams`: `ppCommitteeMaxTermLength`,`ppCommitteeMinSize`,`ppDRepActivity`,`ppDRepDeposit`,`ppDRepVotingThresholds`,`ppGovActionDeposit`,`ppGovActionLifetime`,`ppGovProtocolVersion`,`ppMinFeeRefScriptCostPerByte`,`ppPoolVotingThresholds`
* Moved `ConwayEraPlutusTxInfo` class from `Context` module to `TxInfo`
* Removed `Cardano.Ledger.Conway.Plutus.Context` module
Expand Down
40 changes: 15 additions & 25 deletions eras/conway/impl/cardano-ledger-conway.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,15 @@ library testlib
Test.Cardano.Ledger.Conway.Binary.Cddl
Test.Cardano.Ledger.Conway.Binary.Regression
Test.Cardano.Ledger.Conway.Binary.RoundTrip
Test.Cardano.Ledger.Conway.BinarySpec
Test.Cardano.Ledger.Conway.CDDL
Test.Cardano.Ledger.Conway.CommitteeRatifySpec
Test.Cardano.Ledger.Conway.DRepRatifySpec
Test.Cardano.Ledger.Conway.Era
Test.Cardano.Ledger.Conway.Genesis
Test.Cardano.Ledger.Conway.GenesisSpec
Test.Cardano.Ledger.Conway.GoldenSpec
Test.Cardano.Ledger.Conway.GovActionReorderSpec
Test.Cardano.Ledger.Conway.Imp
Test.Cardano.Ledger.Conway.Imp.BbodySpec
Test.Cardano.Ledger.Conway.Imp.CertsSpec
Expand All @@ -144,9 +150,13 @@ library testlib
Test.Cardano.Ledger.Conway.Imp.UtxoSpec
Test.Cardano.Ledger.Conway.Imp.UtxosSpec
Test.Cardano.Ledger.Conway.ImpTest
Test.Cardano.Ledger.Conway.Plutus.PlutusSpec
Test.Cardano.Ledger.Conway.Proposals
Test.Cardano.Ledger.Conway.SPORatifySpec
Test.Cardano.Ledger.Conway.Spec
Test.Cardano.Ledger.Conway.Translation.TranslatableGen
Test.Cardano.Ledger.Conway.TreeDiff
Test.Cardano.Ledger.Conway.TxInfoSpec

visibility: public
hs-source-dirs: testlib
Expand All @@ -163,6 +173,7 @@ library testlib

build-depends:
FailT,
aeson,
base,
bytestring,
cardano-data:{cardano-data, testlib},
Expand All @@ -173,6 +184,7 @@ library testlib
cardano-ledger-conway,
cardano-ledger-core:{cardano-ledger-core, testlib},
cardano-ledger-shelley:{cardano-ledger-shelley, testlib},
cardano-slotting:testlib,
cardano-strict-containers,
containers,
cuddle >=0.4,
Expand Down Expand Up @@ -237,17 +249,7 @@ test-suite tests
other-modules:
Paths_cardano_ledger_conway
Test.Cardano.Ledger.Conway.Binary.CddlSpec
Test.Cardano.Ledger.Conway.BinarySpec
Test.Cardano.Ledger.Conway.CommitteeRatifySpec
Test.Cardano.Ledger.Conway.DRepRatifySpec
Test.Cardano.Ledger.Conway.GenesisSpec
Test.Cardano.Ledger.Conway.GoldenSpec
Test.Cardano.Ledger.Conway.GoldenTranslation
Test.Cardano.Ledger.Conway.GovActionReorderSpec
Test.Cardano.Ledger.Conway.Plutus.PlutusSpec
Test.Cardano.Ledger.Conway.SPORatifySpec
Test.Cardano.Ledger.Conway.Spec
Test.Cardano.Ledger.Conway.TxInfoSpec

default-language: Haskell2010
ghc-options:
Expand All @@ -264,22 +266,10 @@ test-suite tests

build-depends:
HUnit,
aeson,
base,
cardano-data,
cardano-ledger-allegra,
cardano-ledger-alonzo,
cardano-ledger-alonzo:testlib,
cardano-ledger-babbage,
cardano-ledger-binary:{cardano-ledger-binary, testlib},
cardano-ledger-alonzo:{cardano-ledger-alonzo, testlib},
cardano-ledger-binary:testlib,
cardano-ledger-conway,
cardano-ledger-core,
cardano-ledger-core:testlib,
cardano-ledger-shelley,
cardano-slotting:testlib,
cardano-strict-containers,
containers,
data-default,
microlens,
plutus-ledger-api,
cardano-ledger-core:{cardano-ledger-core, testlib},
testlib,
5 changes: 3 additions & 2 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ module Cardano.Ledger.Conway.Governance (
reCommitteeStateL,
DefaultVote (..),
defaultStakePoolVote,
translateProposals,

-- * Exported for testing
pparamsUpdateThreshold,
Expand Down Expand Up @@ -287,7 +288,7 @@ cgsFuturePParamsL :: Lens' (ConwayGovState era) (FuturePParams era)
cgsFuturePParamsL =
lens cgsFuturePParams (\cgs futurePParams -> cgs {cgsFuturePParams = futurePParams})

govStatePrevGovActionIds :: ConwayEraGov era => GovState era -> GovRelation StrictMaybe era
govStatePrevGovActionIds :: ConwayEraGov era => GovState era -> GovRelation StrictMaybe
govStatePrevGovActionIds = view $ proposalsGovStateL . pRootsL . to toPrevGovActionIds

conwayGovStateDRepDistrG ::
Expand Down Expand Up @@ -398,7 +399,7 @@ toConwayGovPairs cg@(ConwayGovState _ _ _ _ _ _ _) =
, "futurePParams" .= cgsFuturePParams
]

instance EraPParams ConwayEra => EraGov ConwayEra where
instance EraGov ConwayEra where
type GovState ConwayEra = ConwayGovState ConwayEra

curPParamsGovStateL = cgsCurPParamsL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ data EnactState era = EnactState
, ensPrevPParams :: !(PParams era)
, ensTreasury :: !Coin
, ensWithdrawals :: !(Map (Credential 'Staking) Coin)
, ensPrevGovActionIds :: !(GovRelation StrictMaybe era)
, ensPrevGovActionIds :: !(GovRelation StrictMaybe)
-- ^ Last enacted GovAction Ids
}
deriving (Generic)
Expand All @@ -167,23 +167,23 @@ ensTreasuryL = lens ensTreasury $ \es x -> es {ensTreasury = x}
ensWithdrawalsL :: Lens' (EnactState era) (Map (Credential 'Staking) Coin)
ensWithdrawalsL = lens ensWithdrawals $ \es x -> es {ensWithdrawals = x}

ensPrevGovActionIdsL :: Lens' (EnactState era) (GovRelation StrictMaybe era)
ensPrevGovActionIdsL :: Lens' (EnactState era) (GovRelation StrictMaybe)
ensPrevGovActionIdsL = lens ensPrevGovActionIds (\es x -> es {ensPrevGovActionIds = x})

ensPrevPParamUpdateL ::
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'PParamUpdatePurpose era))
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'PParamUpdatePurpose))
ensPrevPParamUpdateL = ensPrevGovActionIdsL . grPParamUpdateL

ensPrevHardForkL ::
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'HardForkPurpose era))
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'HardForkPurpose))
ensPrevHardForkL = ensPrevGovActionIdsL . grHardForkL

ensPrevCommitteeL ::
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'CommitteePurpose era))
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'CommitteePurpose))
ensPrevCommitteeL = ensPrevGovActionIdsL . grCommitteeL

ensPrevConstitutionL ::
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'ConstitutionPurpose era))
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'ConstitutionPurpose))
ensPrevConstitutionL = ensPrevGovActionIdsL . grConstitutionL

instance EraPParams era => ToJSON (EnactState era) where
Expand Down
Loading