Skip to content

Commit 337f767

Browse files
Soupstrawlehins
andcommitted
Added Dijkstra era
Removed era parameter from GovActionId Made some Conway tests era-generic Co-authored-by: Alexey Kuleshevich <[email protected]>
1 parent 180aa86 commit 337f767

File tree

94 files changed

+3768
-354
lines changed

Some content is hidden

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

94 files changed

+3768
-354
lines changed

.github/workflows/haskell.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ jobs:
208208
- cardano-ledger-conway
209209
- cardano-ledger-conway-test
210210
- cardano-ledger-core
211+
- cardano-ledger-dijkstra
211212
- cardano-ledger-mary
212213
- cardano-ledger-shelley
213214
- cardano-ledger-shelley-ma-test

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

docs/NewEra.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
### Adding a new era to `cardano-ledger`
2+
3+
First you need to crate a new sub-package in the `eras` directory.
4+
It's easiest to just copy the `.cabal` file from the previous era and then make
5+
some changes to that. Change the name of the project to `cardano-ledger-<era>`
6+
and update the description/synopsis.
7+
8+
Next you'll want to add a datatype to represent the new era (e.g. `ConwayEra`).
9+
Then copy over the entire test suite from the previous era and substitute the
10+
era types for the newly added era type. Once the tests are in place, the type
11+
checker will guide you to add all the necessary type family and type class
12+
instances. You might need to make some of the tests era-generic. See which tests
13+
don't yet take an era type annotation and modify those test if possible. The tests
14+
that can be made era-generic should be moved to the `testlib` of the era where
15+
they were first introduced, and any era-specific tests should reside in the test
16+
suite package of that era.
17+
18+
Add the `Cardano.Ledger.<era>.Core` module and re-export the `Core` module from
19+
the previous era. Use the `Core` module from the current era whenever you need
20+
to import anything from the core module. Do the same for
21+
`Cardano.Ledger.<era>.State`.
22+
23+
It's a good idea to re-use the data types defined in the previous era at first.
24+
You might need to use `coerce` in a couple of places to change the era parameter
25+
when translating these types. Also, there might be some constraints that expect
26+
the era to be exactly the previous era, you will probably be able to generalize
27+
these functions and type class instances to make them compatible with the new era.
28+
29+
For `EraRule` instances use the same rules as in the previous era.
30+
31+
Make sure to update `.github/ci/haskell.yml` so that the job also runs the test
32+
suite of the newly added era.

eras/conway/impl/CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,26 @@
22

33
## 1.20.0.0
44

5+
* Add:
6+
* `alonzoToConwayUtxosPredFailure`
7+
* `alonzoToConwayUtxosEvent`
8+
* `getConwayScriptsNeeded`
9+
* `getConwayMinFeeTxUtxo`
10+
* `getConwayMinFeeTx`
11+
* `conwayRedeemerPointer`
12+
* `conwayRedeemerPointerInverse`
13+
* `transMintValue`
14+
* `transTxBodyId`
15+
* `transVotingProcedures`
16+
* `transProposal`
17+
* `transTxCertV1V2`
18+
* `transPlutusPurposeV1V2`
19+
* `guardConwayFeaturesForPlutusV1V2`
20+
* `transTxInInfoV3`
21+
* Remove era parametrization from `GovPurposeId`, `GovRelation`
522
* Move to `testlib` the `DecCBOR` instance for `TxBody ConwayEra`
623
* Add `ReferenceInputsNotDisjointFromInputs`
7-
- Remove `ConwayNewEpochPredFailure` and replace it with `Void`. #5007
24+
* Remove `ConwayNewEpochPredFailure` and replace it with `Void`. #5007
825
* Added to `PParams`: `ppCommitteeMaxTermLength`,`ppCommitteeMinSize`,`ppDRepActivity`,`ppDRepDeposit`,`ppDRepVotingThresholds`,`ppGovActionDeposit`,`ppGovActionLifetime`,`ppGovProtocolVersion`,`ppMinFeeRefScriptCostPerByte`,`ppPoolVotingThresholds`
926
* Moved `ConwayEraPlutusTxInfo` class from `Context` module to `TxInfo`
1027
* Removed `Cardano.Ledger.Conway.Plutus.Context` module

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

Lines changed: 14 additions & 26 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,13 @@ 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
157+
Test.Cardano.Ledger.Conway.Spec
148158
Test.Cardano.Ledger.Conway.Translation.TranslatableGen
149159
Test.Cardano.Ledger.Conway.TreeDiff
160+
Test.Cardano.Ledger.Conway.TxInfoSpec
150161

151162
visibility: public
152163
hs-source-dirs: testlib
@@ -163,6 +174,7 @@ library testlib
163174

164175
build-depends:
165176
FailT,
177+
aeson,
166178
base,
167179
bytestring,
168180
cardano-data:{cardano-data, testlib},
@@ -173,6 +185,7 @@ library testlib
173185
cardano-ledger-conway,
174186
cardano-ledger-core:{cardano-ledger-core, testlib},
175187
cardano-ledger-shelley:{cardano-ledger-shelley, testlib},
188+
cardano-slotting:testlib,
176189
cardano-strict-containers,
177190
containers,
178191
cuddle >=0.4,
@@ -236,18 +249,7 @@ test-suite tests
236249
hs-source-dirs: test
237250
other-modules:
238251
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
245252
Test.Cardano.Ledger.Conway.GoldenTranslation
246-
Test.Cardano.Ledger.Conway.GovActionReorderSpec
247-
Test.Cardano.Ledger.Conway.Plutus.PlutusSpec
248-
Test.Cardano.Ledger.Conway.SPORatifySpec
249-
Test.Cardano.Ledger.Conway.Spec
250-
Test.Cardano.Ledger.Conway.TxInfoSpec
251253

252254
default-language: Haskell2010
253255
ghc-options:
@@ -264,22 +266,8 @@ 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,
276-
cardano-ledger-core,
277-
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,
272+
cardano-ledger-core:{cardano-ledger-core, testlib},
285273
testlib,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ module Cardano.Ledger.Conway.Governance (
164164
reCommitteeStateL,
165165
DefaultVote (..),
166166
defaultStakePoolVote,
167+
translateProposals,
167168

168169
-- * Exported for testing
169170
pparamsUpdateThreshold,
@@ -287,7 +288,7 @@ cgsFuturePParamsL :: Lens' (ConwayGovState era) (FuturePParams era)
287288
cgsFuturePParamsL =
288289
lens cgsFuturePParams (\cgs futurePParams -> cgs {cgsFuturePParams = futurePParams})
289290

290-
govStatePrevGovActionIds :: ConwayEraGov era => GovState era -> GovRelation StrictMaybe era
291+
govStatePrevGovActionIds :: ConwayEraGov era => GovState era -> GovRelation StrictMaybe
291292
govStatePrevGovActionIds = view $ proposalsGovStateL . pRootsL . to toPrevGovActionIds
292293

293294
conwayGovStateDRepDistrG ::
@@ -398,7 +399,7 @@ toConwayGovPairs cg@(ConwayGovState _ _ _ _ _ _ _) =
398399
, "futurePParams" .= cgsFuturePParams
399400
]
400401

401-
instance EraPParams ConwayEra => EraGov ConwayEra where
402+
instance EraGov ConwayEra where
402403
type GovState ConwayEra = ConwayGovState ConwayEra
403404

404405
curPParamsGovStateL = cgsCurPParamsL

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ data EnactState era = EnactState
141141
, ensPrevPParams :: !(PParams era)
142142
, ensTreasury :: !Coin
143143
, ensWithdrawals :: !(Map (Credential 'Staking) Coin)
144-
, ensPrevGovActionIds :: !(GovRelation StrictMaybe era)
144+
, ensPrevGovActionIds :: !(GovRelation StrictMaybe)
145145
-- ^ Last enacted GovAction Ids
146146
}
147147
deriving (Generic)
@@ -167,23 +167,23 @@ ensTreasuryL = lens ensTreasury $ \es x -> es {ensTreasury = x}
167167
ensWithdrawalsL :: Lens' (EnactState era) (Map (Credential 'Staking) Coin)
168168
ensWithdrawalsL = lens ensWithdrawals $ \es x -> es {ensWithdrawals = x}
169169

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

173173
ensPrevPParamUpdateL ::
174-
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'PParamUpdatePurpose era))
174+
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'PParamUpdatePurpose))
175175
ensPrevPParamUpdateL = ensPrevGovActionIdsL . grPParamUpdateL
176176

177177
ensPrevHardForkL ::
178-
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'HardForkPurpose era))
178+
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'HardForkPurpose))
179179
ensPrevHardForkL = ensPrevGovActionIdsL . grHardForkL
180180

181181
ensPrevCommitteeL ::
182-
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'CommitteePurpose era))
182+
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'CommitteePurpose))
183183
ensPrevCommitteeL = ensPrevGovActionIdsL . grCommitteeL
184184

185185
ensPrevConstitutionL ::
186-
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'ConstitutionPurpose era))
186+
Lens' (EnactState era) (StrictMaybe (GovPurposeId 'ConstitutionPurpose))
187187
ensPrevConstitutionL = ensPrevGovActionIdsL . grConstitutionL
188188

189189
instance EraPParams era => ToJSON (EnactState era) where

0 commit comments

Comments
 (0)