Skip to content

Commit f91eb81

Browse files
committed
WIP
1 parent 9e37fec commit f91eb81

File tree

24 files changed

+386
-82
lines changed

24 files changed

+386
-82
lines changed

cardano-api/src/Cardano/Api/Certificate/Internal.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ certificateToTxCert c =
234234
ConwayCertificate eon cert ->
235235
case eon of
236236
ConwayEraOnwardsConway -> cert
237+
ConwayEraOnwardsDijkstra -> cert
237238

238239
-- ----------------------------------------------------------------------------
239240
-- Stake pool parameters
@@ -576,6 +577,7 @@ filterUnRegCreds =
576577
Ledger.RetirePoolTxCert _ _ -> Nothing
577578
Ledger.MirTxCert _ -> Nothing
578579
Ledger.GenesisDelegTxCert{} -> Nothing
580+
_ -> error "dijkstra"
579581
ConwayCertificate cEra conwayCert -> conwayEraOnwardsConstraints cEra $
580582
case conwayCert of
581583
Ledger.RegPoolTxCert _ -> Nothing
@@ -593,6 +595,7 @@ filterUnRegCreds =
593595
Ledger.RegTxCert _ -> Nothing
594596
-- stake cred deregistration w/o deposit
595597
Ledger.UnRegTxCert cred -> Just cred
598+
_ -> error "dijkstra"
596599

597600
filterUnRegDRepCreds
598601
:: Certificate era -> Maybe (Ledger.Credential Ledger.DRepRole)
@@ -615,6 +618,7 @@ filterUnRegDRepCreds = \case
615618
Ledger.RegTxCert _ -> Nothing
616619
-- stake cred deregistration w/o deposit
617620
Ledger.UnRegTxCert _ -> Nothing
621+
_ -> error "dijkstra"
618622

619623
-- ----------------------------------------------------------------------------
620624
-- Internal conversion functions
@@ -803,6 +807,7 @@ getAnchorDataFromCertificate c =
803807
Ledger.RetirePoolTxCert _ _ -> return Nothing
804808
Ledger.GenesisDelegTxCert{} -> return Nothing
805809
Ledger.MirTxCert _ -> return Nothing
810+
_ -> error "dijkstra"
806811
ConwayCertificate ceo ccert ->
807812
conwayEraOnwardsConstraints ceo $
808813
case ccert of
@@ -819,6 +824,7 @@ getAnchorDataFromCertificate c =
819824
Ledger.UpdateDRepTxCert _ mAnchor -> return $ Ledger.strictMaybeToMaybe mAnchor
820825
Ledger.AuthCommitteeHotKeyTxCert _ _ -> return Nothing
821826
Ledger.ResignCommitteeColdTxCert _ mAnchor -> return $ Ledger.strictMaybeToMaybe mAnchor
827+
_ -> error "dijkstra"
822828
where
823829
anchorDataFromPoolMetadata
824830
:: MonadError AnchorDataFromCertificateError m

cardano-api/src/Cardano/Api/Consensus/Internal/InMode.hs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ fromConsensusGenTx = \case
100100
Consensus.HardForkGenTx (Consensus.OneEraGenTx (S (S (S (S (S (S (Z tx')))))))) ->
101101
let Consensus.ShelleyTx _txid shelleyEraTx = tx'
102102
in TxInMode ShelleyBasedEraConway (ShelleyTx ShelleyBasedEraConway shelleyEraTx)
103+
Consensus.HardForkGenTx (Consensus.OneEraGenTx (S (S (S (S (S (S (S (Z tx'))))))))) ->
104+
let Consensus.ShelleyTx _txid shelleyEraTx = tx'
105+
in TxInMode ShelleyBasedEraDijkstra (ShelleyTx ShelleyBasedEraDijkstra shelleyEraTx)
103106

104107
toConsensusGenTx
105108
:: ()
@@ -132,6 +135,10 @@ toConsensusGenTx (TxInMode ShelleyBasedEraConway (ShelleyTx _ tx)) =
132135
Consensus.HardForkGenTx (Consensus.OneEraGenTx (S (S (S (S (S (S (Z tx'))))))))
133136
where
134137
tx' = Consensus.mkShelleyTx tx
138+
toConsensusGenTx (TxInMode ShelleyBasedEraDijkstra (ShelleyTx _ tx)) =
139+
Consensus.HardForkGenTx (Consensus.OneEraGenTx (S (S (S (S (S (S (S (Z tx')))))))))
140+
where
141+
tx' = Consensus.mkShelleyTx tx
135142

136143
-- ----------------------------------------------------------------------------
137144
-- Transaction ids in the context of a consensus mode
@@ -193,6 +200,12 @@ toConsensusTxId (TxIdInMode ConwayEra txid) =
193200
where
194201
txid' :: Consensus.TxId (Consensus.GenTx Consensus.StandardConwayBlock)
195202
txid' = Consensus.ShelleyTxId $ toShelleyTxId txid
203+
toConsensusTxId (TxIdInMode DijkstraEra txid) =
204+
Consensus.HardForkGenTxId
205+
(Consensus.OneEraGenTxId (S (S (S (S (S (S (S (Z (Consensus.WrapGenTxId txid'))))))))))
206+
where
207+
txid' :: Consensus.TxId (Consensus.GenTx Consensus.StandardDijkstraBlock)
208+
txid' = Consensus.ShelleyTxId $ toShelleyTxId txid
196209

197210
-- ----------------------------------------------------------------------------
198211
-- Transaction validation errors in the context of eras and consensus modes
@@ -300,5 +313,7 @@ fromConsensusApplyTxErr = \case
300313
TxValidationErrorInCardanoMode $ ShelleyTxValidationError ShelleyBasedEraBabbage err
301314
Consensus.ApplyTxErrConway err ->
302315
TxValidationErrorInCardanoMode $ ShelleyTxValidationError ShelleyBasedEraConway err
316+
Consensus.ApplyTxErrDijkstra err ->
317+
TxValidationErrorInCardanoMode $ ShelleyTxValidationError ShelleyBasedEraDijkstra err
303318
Consensus.ApplyTxErrWrongEra err ->
304319
TxValidationEraMismatch err

cardano-api/src/Cardano/Api/Consensus/Internal/Mode.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type family ConsensusBlockForEra era where
8383
ConsensusBlockForEra AlonzoEra = Consensus.StandardAlonzoBlock
8484
ConsensusBlockForEra BabbageEra = Consensus.StandardBabbageBlock
8585
ConsensusBlockForEra ConwayEra = Consensus.StandardConwayBlock
86+
ConsensusBlockForEra DijkstraEra = Consensus.StandardDijkstraBlock
8687

8788
type family ConsensusCryptoForBlock block where
8889
ConsensusCryptoForBlock Consensus.ByronBlockHFC = StandardCrypto
@@ -98,6 +99,7 @@ type family ConsensusProtocol era where
9899
ConsensusProtocol AlonzoEra = Consensus.TPraos StandardCrypto
99100
ConsensusProtocol BabbageEra = Consensus.Praos StandardCrypto
100101
ConsensusProtocol ConwayEra = Consensus.Praos StandardCrypto
102+
ConsensusProtocol DijkstraEra = Consensus.Praos StandardCrypto
101103

102104
type family ChainDepStateProtocol era where
103105
ChainDepStateProtocol ShelleyEra = Consensus.TPraosState
@@ -128,6 +130,9 @@ eraIndex5 = eraIndexSucc eraIndex4
128130
eraIndex6 :: Consensus.EraIndex (x6 : x5 : x4 : x3 : x2 : x1 : x0 : xs)
129131
eraIndex6 = eraIndexSucc eraIndex5
130132

133+
eraIndex7 :: Consensus.EraIndex (x7 : x6 : x5 : x4 : x3 : x2 : x1 : x0 : xs)
134+
eraIndex7 = eraIndexSucc eraIndex6
135+
131136
toConsensusEraIndex
132137
:: ()
133138
=> Consensus.CardanoBlock StandardCrypto ~ Consensus.HardForkBlock xs
@@ -141,6 +146,7 @@ toConsensusEraIndex = \case
141146
AlonzoEra -> eraIndex4
142147
BabbageEra -> eraIndex5
143148
ConwayEra -> eraIndex6
149+
DijkstraEra -> eraIndex7
144150

145151
fromConsensusEraIndex
146152
:: ()
@@ -161,3 +167,4 @@ fromConsensusEraIndex = \case
161167
AnyCardanoEra BabbageEra
162168
Consensus.EraIndex (S (S (S (S (S (S (Z (K ())))))))) ->
163169
AnyCardanoEra ConwayEra
170+
Consensus.EraIndex (S (S (S (S (S (S (S _))))))) -> error "dijkstra"

cardano-api/src/Cardano/Api/Experimental/Era.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ type EraCommonConstraints era =
295295
, L.AlonzoEraTx (LedgerEra era)
296296
, L.BabbageEraPParams (LedgerEra era)
297297
, L.BabbageEraTxBody (LedgerEra era)
298+
, L.ConwayEraTxBody (LedgerEra era)
298299
, L.ConwayEraTxCert (LedgerEra era)
299300
, L.TxCert (LedgerEra era) ~ L.ConwayTxCert (LedgerEra era)
300301
, L.Era (LedgerEra era)

cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/IndexedPlutusScriptWitness.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,4 @@ obtainAlonzoScriptPurposeConstraints v =
211211
AlonzoEraOnwardsAlonzo -> id
212212
AlonzoEraOnwardsBabbage -> id
213213
AlonzoEraOnwardsConway -> id
214+
AlonzoEraOnwardsDijkstra -> id

cardano-api/src/Cardano/Api/Experimental/Plutus/Internal/ScriptWitness.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ getPlutusScriptWitnessLanguage (PlutusScriptWitness l _ _ _ _) =
7474
L.SPlutusV1 -> L.plutusLanguage l
7575
L.SPlutusV2 -> L.plutusLanguage l
7676
L.SPlutusV3 -> L.plutusLanguage l
77+
L.SPlutusV4 -> L.plutusLanguage l
7778

7879
-- | Every Plutus script has a purpose that indicates
7980
-- what that script is witnessing.

cardano-api/src/Cardano/Api/Experimental/Tx.hs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ import Cardano.Crypto.Hash qualified as Hash
167167
import Cardano.Ledger.Alonzo.TxBody qualified as L
168168
import Cardano.Ledger.Api qualified as L
169169
import Cardano.Ledger.Binary qualified as Ledger
170-
import Cardano.Ledger.Conway.TxBody qualified as L
171170
import Cardano.Ledger.Core qualified as Ledger
172171
import Cardano.Ledger.Hashes qualified as L hiding (Hash)
173172

@@ -285,7 +284,7 @@ makeUnsignedTx era bc = obtainCommonConstraints era $ do
285284
& L.datsTxWitsL .~ datums
286285
& L.rdmrsTxWitsL .~ redeemers
287286

288-
eraSpecificTxBody <- eraSpecificLedgerTxBody era ledgerTxBody bc
287+
let eraSpecificTxBody = eraSpecificLedgerTxBody era ledgerTxBody bc
289288

290289
return . UnsignedTx $
291290
L.mkBasicTx eraSpecificTxBody
@@ -297,22 +296,25 @@ eraSpecificLedgerTxBody
297296
:: Era era
298297
-> Ledger.TxBody (LedgerEra era)
299298
-> TxBodyContent BuildTx era
300-
-> Either TxBodyError (Ledger.TxBody (LedgerEra era))
301-
eraSpecificLedgerTxBody ConwayEra ledgerbody bc =
302-
let propProcedures = txProposalProcedures bc
303-
voteProcedures = txVotingProcedures bc
304-
treasuryDonation = txTreasuryDonation bc
305-
currentTresuryValue = txCurrentTreasuryValue bc
306-
in return $
307-
ledgerbody
308-
& L.proposalProceduresTxBodyL
309-
.~ convProposalProcedures (maybe TxProposalProceduresNone unFeatured propProcedures)
310-
& L.votingProceduresTxBodyL
311-
.~ convVotingProcedures (maybe TxVotingProceduresNone unFeatured voteProcedures)
312-
& L.treasuryDonationTxBodyL
313-
.~ maybe (L.Coin 0) unFeatured treasuryDonation
314-
& L.currentTreasuryValueTxBodyL
315-
.~ L.maybeToStrictMaybe (unFeatured =<< currentTresuryValue)
299+
-> Ledger.TxBody (LedgerEra era)
300+
eraSpecificLedgerTxBody era ledgerbody bc =
301+
body era
302+
where
303+
body e =
304+
let propProcedures = txProposalProcedures bc
305+
voteProcedures = txVotingProcedures bc
306+
treasuryDonation = txTreasuryDonation bc
307+
currentTresuryValue = txCurrentTreasuryValue bc
308+
in obtainCommonConstraints e $
309+
ledgerbody
310+
& L.proposalProceduresTxBodyL
311+
.~ convProposalProcedures (maybe TxProposalProceduresNone unFeatured propProcedures)
312+
& L.votingProceduresTxBodyL
313+
.~ convVotingProcedures (maybe TxVotingProceduresNone unFeatured voteProcedures)
314+
& L.treasuryDonationTxBodyL
315+
.~ maybe (L.Coin 0) unFeatured treasuryDonation
316+
& L.currentTreasuryValueTxBodyL
317+
.~ L.maybeToStrictMaybe (unFeatured =<< currentTresuryValue)
316318

317319
hashTxBody
318320
:: L.HashAnnotated (Ledger.TxBody era) L.EraIndependentTxBody

cardano-api/src/Cardano/Api/Experimental/Tx/Internal/AnyWitness.hs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Cardano.Ledger.Alonzo.Scripts qualified as L
2929
import Cardano.Ledger.Babbage.Scripts qualified as L
3030
import Cardano.Ledger.Conway.Scripts qualified as L
3131
import Cardano.Ledger.Core qualified as L
32+
import Cardano.Ledger.Dijkstra.Scripts qualified as Dijkstra
3233
import Cardano.Ledger.Plutus.Data qualified as L
3334
import Cardano.Ledger.Plutus.Language qualified as L
3435

@@ -101,12 +102,14 @@ getAnyWitnessScript era ss@(AnySimpleScriptWitness{}) =
101102
ShelleyBasedEraAlonzo -> L.TimelockScript <$> getAnyWitnessSimpleScript ss
102103
ShelleyBasedEraBabbage -> L.TimelockScript <$> getAnyWitnessSimpleScript ss
103104
ShelleyBasedEraConway -> L.TimelockScript <$> getAnyWitnessSimpleScript ss
105+
ShelleyBasedEraDijkstra -> L.TimelockScript <$> getAnyWitnessSimpleScript ss
104106
getAnyWitnessScript era ps@(AnyPlutusScriptWitness{}) =
105107
forShelleyBasedEraInEon era Nothing $ \aEon ->
106108
case aEon of
107109
AlonzoEraOnwardsAlonzo -> L.PlutusScript <$> getAnyWitnessPlutusScript aEon ps
108110
AlonzoEraOnwardsBabbage -> L.PlutusScript <$> getAnyWitnessPlutusScript aEon ps
109111
AlonzoEraOnwardsConway -> L.PlutusScript <$> getAnyWitnessPlutusScript aEon ps
112+
AlonzoEraOnwardsDijkstra -> L.PlutusScript <$> getAnyWitnessPlutusScript aEon ps
110113

111114
-- It should be noted that 'PlutusRunnable' is constructed via deserialization. The deserialization
112115
-- instance lives in ledger and will fail for an invalid script language/era pairing. Therefore
@@ -127,6 +130,9 @@ fromPlutusRunnable L.SPlutusV1 eon runnable =
127130
AlonzoEraOnwardsConway ->
128131
let plutusScript = L.plutusFromRunnable runnable
129132
in Just $ L.ConwayPlutusV1 plutusScript
133+
AlonzoEraOnwardsDijkstra ->
134+
let plutusScript = L.plutusFromRunnable runnable
135+
in Just $ Dijkstra.MkDijkstraPlutusScript $ L.ConwayPlutusV1 plutusScript
130136
fromPlutusRunnable L.SPlutusV2 eon runnable =
131137
case eon of
132138
AlonzoEraOnwardsAlonzo -> Nothing
@@ -136,13 +142,29 @@ fromPlutusRunnable L.SPlutusV2 eon runnable =
136142
AlonzoEraOnwardsConway ->
137143
let plutusScript = L.plutusFromRunnable runnable
138144
in Just $ L.ConwayPlutusV2 plutusScript
145+
AlonzoEraOnwardsDijkstra ->
146+
let plutusScript = L.plutusFromRunnable runnable
147+
in Just $ Dijkstra.MkDijkstraPlutusScript $ L.ConwayPlutusV2 plutusScript
139148
fromPlutusRunnable L.SPlutusV3 eon runnable =
140149
case eon of
141150
AlonzoEraOnwardsAlonzo -> Nothing
142151
AlonzoEraOnwardsBabbage -> Nothing
143152
AlonzoEraOnwardsConway ->
144153
let plutusScript = L.plutusFromRunnable runnable
145154
in Just $ L.ConwayPlutusV3 plutusScript
155+
AlonzoEraOnwardsDijkstra ->
156+
let plutusScript = L.plutusFromRunnable runnable
157+
in Just $ Dijkstra.MkDijkstraPlutusScript $ L.ConwayPlutusV3 plutusScript
158+
fromPlutusRunnable L.SPlutusV4 eon runnable =
159+
case eon of
160+
AlonzoEraOnwardsAlonzo -> Nothing
161+
AlonzoEraOnwardsBabbage -> Nothing
162+
AlonzoEraOnwardsConway ->
163+
let plutusScript = L.plutusFromRunnable runnable
164+
in Just $ (error "ConwayPlutusV4") plutusScript
165+
AlonzoEraOnwardsDijkstra ->
166+
let plutusScript = L.plutusFromRunnable runnable
167+
in Just $ Dijkstra.MkDijkstraPlutusScript $ (error "ConwayPlutusV4") plutusScript
146168

147169
toAlonzoDatum
148170
:: AlonzoEraOnwards era
@@ -160,5 +182,6 @@ getPlutusDatum
160182
getPlutusDatum L.SPlutusV1 (SpendingScriptDatum d) = Just d
161183
getPlutusDatum L.SPlutusV2 (SpendingScriptDatum d) = Just d
162184
getPlutusDatum L.SPlutusV3 (SpendingScriptDatum d) = d
185+
getPlutusDatum L.SPlutusV4 (SpendingScriptDatum _d) = error "dijkstra"
163186
getPlutusDatum _ InlineDatum = Nothing
164187
getPlutusDatum _ NoScriptDatum = Nothing

0 commit comments

Comments
 (0)