Skip to content

Commit 201b2a3

Browse files
committed
Consensus related Dijkstra changes
1 parent 394927d commit 201b2a3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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"

0 commit comments

Comments
 (0)