Skip to content

Commit 1b87737

Browse files
committed
Added Dijkstra era
1 parent 82c3d9b commit 1b87737

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3201
-140
lines changed

.github/workflows/haskell.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ jobs:
202202
- cardano-ledger-conway
203203
- cardano-ledger-conway-test
204204
- cardano-ledger-core
205+
- cardano-ledger-dijkstra
205206
- cardano-ledger-mary
206207
- cardano-ledger-shelley
207208
- cardano-ledger-shelley-ma-test

CONTRIBUTING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,35 @@ To change the local build directory, redo step 3 _without leaving_ the `nix deve
345345
```
346346
in the `cabal.project` file.
347347

348+
### Adding a new era to `cardano-ledger`
349+
350+
First you need to crate a new sub-package in the `eras` directory.
351+
It's easiest to just copy the `.cabal` file from the previous era and then make
352+
some changes to that. Change the name of the project to `cardano-ledger-<era>`
353+
and update the description/synopsis.
354+
355+
Next you'll want to add a datatype to represent the new era (e.g. `ConwayEra`).
356+
Then copy over the entire test suite from the previous era and substitute the
357+
era types for the newly added era type. Once the tests are in place, the type
358+
checker will guide you to add all the necessary type family and type class
359+
instances.
360+
361+
Add the `Cardano.Ledger.<era>.Core` module and re-export the `Core` module from
362+
the previous era. Use the `Core` module from the current era whenever you need
363+
to import anything from the core module. Do the same for
364+
`Cardano.Ledger.<era>.State`.
365+
366+
It's a good idea to re-use the data types defined in the previous era at first.
367+
You might need to use `coerce` in a couple of places to change the era parameter
368+
when translating these types. Also, there might be some constraints that expect
369+
the era to be exactly the previous era, you will probably be able to generalize
370+
these functions and type class instances to make them compatible with the new era.
371+
372+
For `EraRule` instances use the same rules as in the previous era.
373+
374+
Make sure to update `.github/ci/haskell.yml` so that the job also runs the test
375+
suite of the newly added era.
376+
348377
### Additional documentation
349378
350379
You can find additional documentation on the nix infrastructure used in this

cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ packages:
3838
eras/babbage/test-suite
3939
eras/conway/impl
4040
eras/conway/test-suite
41+
eras/dijkstra
4142
eras/mary/impl
4243
eras/shelley/impl
4344
eras/shelley/test-suite

eras/conway/impl/cardano-ledger-conway.cabal

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,18 @@ library testlib
126126
Test.Cardano.Ledger.Conway.Arbitrary
127127
Test.Cardano.Ledger.Conway.Binary.Annotator
128128
Test.Cardano.Ledger.Conway.Binary.Cddl
129+
Test.Cardano.Ledger.Conway.Binary.CddlSpec
129130
Test.Cardano.Ledger.Conway.Binary.Regression
130131
Test.Cardano.Ledger.Conway.Binary.RoundTrip
132+
Test.Cardano.Ledger.Conway.BinarySpec
131133
Test.Cardano.Ledger.Conway.CDDL
134+
Test.Cardano.Ledger.Conway.CommitteeRatifySpec
135+
Test.Cardano.Ledger.Conway.DRepRatifySpec
132136
Test.Cardano.Ledger.Conway.Era
133137
Test.Cardano.Ledger.Conway.Genesis
138+
Test.Cardano.Ledger.Conway.GenesisSpec
139+
Test.Cardano.Ledger.Conway.GoldenSpec
140+
Test.Cardano.Ledger.Conway.GovActionReorderSpec
134141
Test.Cardano.Ledger.Conway.Imp
135142
Test.Cardano.Ledger.Conway.Imp.BbodySpec
136143
Test.Cardano.Ledger.Conway.Imp.CertsSpec
@@ -144,9 +151,12 @@ library testlib
144151
Test.Cardano.Ledger.Conway.Imp.UtxoSpec
145152
Test.Cardano.Ledger.Conway.Imp.UtxosSpec
146153
Test.Cardano.Ledger.Conway.ImpTest
154+
Test.Cardano.Ledger.Conway.Plutus.PlutusSpec
147155
Test.Cardano.Ledger.Conway.Proposals
156+
Test.Cardano.Ledger.Conway.SPORatifySpec
148157
Test.Cardano.Ledger.Conway.Translation.TranslatableGen
149158
Test.Cardano.Ledger.Conway.TreeDiff
159+
Test.Cardano.Ledger.Conway.TxInfoSpec
150160

151161
visibility: public
152162
hs-source-dirs: testlib
@@ -163,6 +173,7 @@ library testlib
163173

164174
build-depends:
165175
FailT,
176+
aeson,
166177
base,
167178
bytestring,
168179
cardano-data:{cardano-data, testlib},
@@ -173,6 +184,7 @@ library testlib
173184
cardano-ledger-conway,
174185
cardano-ledger-core:{cardano-ledger-core, testlib},
175186
cardano-ledger-shelley:{cardano-ledger-shelley, testlib},
187+
cardano-slotting:testlib,
176188
cardano-strict-containers,
177189
containers,
178190
cuddle >=0.3.2,
@@ -236,18 +248,8 @@ test-suite tests
236248
hs-source-dirs: test
237249
other-modules:
238250
Paths_cardano_ledger_conway
239-
Test.Cardano.Ledger.Conway.Binary.CddlSpec
240-
Test.Cardano.Ledger.Conway.BinarySpec
241-
Test.Cardano.Ledger.Conway.CommitteeRatifySpec
242-
Test.Cardano.Ledger.Conway.DRepRatifySpec
243-
Test.Cardano.Ledger.Conway.GenesisSpec
244-
Test.Cardano.Ledger.Conway.GoldenSpec
245251
Test.Cardano.Ledger.Conway.GoldenTranslation
246-
Test.Cardano.Ledger.Conway.GovActionReorderSpec
247-
Test.Cardano.Ledger.Conway.Plutus.PlutusSpec
248-
Test.Cardano.Ledger.Conway.SPORatifySpec
249252
Test.Cardano.Ledger.Conway.Spec
250-
Test.Cardano.Ledger.Conway.TxInfoSpec
251253

252254
default-language: Haskell2010
253255
ghc-options:
@@ -264,22 +266,9 @@ test-suite tests
264266

265267
build-depends:
266268
HUnit,
267-
aeson,
268269
base,
269-
cardano-data,
270-
cardano-ledger-allegra,
271-
cardano-ledger-alonzo,
272270
cardano-ledger-alonzo:testlib,
273-
cardano-ledger-babbage,
274-
cardano-ledger-binary:{cardano-ledger-binary, testlib},
275271
cardano-ledger-conway,
276272
cardano-ledger-core,
277273
cardano-ledger-core:testlib,
278-
cardano-ledger-shelley,
279-
cardano-slotting:testlib,
280-
cardano-strict-containers,
281-
containers,
282-
data-default,
283-
microlens,
284-
plutus-ledger-api,
285274
testlib,

eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ toConwayGovPairs cg@(ConwayGovState _ _ _ _ _ _ _) =
398398
, "futurePParams" .= cgsFuturePParams
399399
]
400400

401-
instance EraPParams ConwayEra => EraGov ConwayEra where
401+
instance EraGov ConwayEra where
402402
type GovState ConwayEra = ConwayGovState ConwayEra
403403

404404
curPParamsGovStateL = cgsCurPParamsL

eras/conway/impl/src/Cardano/Ledger/Conway/PParams.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ module Cardano.Ledger.Conway.PParams (
8181
conwayModifiedPPGroups,
8282
pvtHardForkInitiationL,
8383
pvtMotionNoConfidenceL,
84+
conwayApplyPPUpdates,
85+
emptyConwayPParams,
86+
emptyConwayPParamsUpdate,
87+
asNaturalHKD,
88+
asBoundedIntegralHKD,
8489
) where
8590

8691
import Cardano.Ledger.Alonzo.PParams

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Bbody.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ module Cardano.Ledger.Conway.Rules.Bbody (
1919
ConwayBBODY,
2020
ConwayBbodyPredFailure (..),
2121
maxRefScriptSizePerBlock,
22+
alonzoToConwayBbodyPredFailure,
23+
shelleyToConwayBbodyPredFailure,
2224
) where
2325

2426
import Cardano.Ledger.Allegra.Rules (AllegraUtxoPredFailure)

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Ratify.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
{-# OPTIONS_GHC -Wno-orphans #-}
1414

1515
module Cardano.Ledger.Conway.Rules.Ratify (
16+
ConwayRATIFY,
1617
RatifyState (..),
1718
committeeAccepted,
1819
committeeAcceptedRatio,

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxo.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
{-# OPTIONS_GHC -Wno-orphans #-}
1616

1717
module Cardano.Ledger.Conway.Rules.Utxo (
18+
ConwayUTXO,
1819
allegraToConwayUtxoPredFailure,
1920
babbageToConwayUtxoPredFailure,
2021
alonzoToConwayUtxoPredFailure,

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxos.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ module Cardano.Ledger.Conway.Rules.Utxos (
1919
ConwayUTXOS,
2020
ConwayUtxosPredFailure (..),
2121
ConwayUtxosEvent (..),
22+
alonzoToConwayUtxosPredFailure,
23+
alonzoToConwayUtxosEvent,
2224
) where
2325

2426
import Cardano.Ledger.Alonzo.Plutus.Context (ContextError, EraPlutusContext)

0 commit comments

Comments
 (0)