@@ -25,7 +25,9 @@ module Ouroboros.Consensus.Cardano.CanHardFork (
25
25
-- * Re-exports of Shelley code
26
26
, ShelleyPartialLedgerConfig (.. )
27
27
, crossEraForecastAcrossShelley
28
- , translateChainDepStateAcrossShelley
28
+ , forecastAcrossShelley
29
+ , tickChainDepStateAcrossShelley
30
+ , tickLedgerStateAcrossShelley
29
31
, translateLedgerStateByronToShelley
30
32
) where
31
33
@@ -53,7 +55,8 @@ import qualified Data.Map.Strict as Map
53
55
import Data.Maybe (listToMaybe , mapMaybe )
54
56
import Data.Proxy
55
57
import Data.SOP.BasicFunctors
56
- import Data.SOP.InPairs (RequiringBoth (.. ), ignoringBoth )
58
+ import Data.SOP.InPairs (RequiringBoth , RequiringBoth' (.. ),
59
+ ignoringBoth )
57
60
import qualified Data.SOP.Strict as SOP
58
61
import Data.SOP.Tails (Tails (.. ))
59
62
import qualified Data.SOP.Tails as Tails
@@ -68,8 +71,7 @@ import Ouroboros.Consensus.Cardano.Block
68
71
import Ouroboros.Consensus.Forecast
69
72
import Ouroboros.Consensus.HardFork.Combinator
70
73
import Ouroboros.Consensus.HardFork.Combinator.State.Types
71
- import Ouroboros.Consensus.HardFork.History (Bound (boundSlot ),
72
- addSlots )
74
+ import Ouroboros.Consensus.HardFork.History (Bound (.. ), addSlots )
73
75
import Ouroboros.Consensus.HardFork.Simple
74
76
import Ouroboros.Consensus.Ledger.Abstract
75
77
import Ouroboros.Consensus.Ledger.SupportsMempool (ByteSize32 ,
@@ -282,23 +284,23 @@ instance CardanoHardForkConstraints c => CanHardFork (CardanoEras c) where
282
284
type HardForkTxMeasure (CardanoEras c ) = ConwayMeasure
283
285
284
286
hardForkEraTranslation = EraTranslation {
285
- translateLedgerState =
286
- PCons translateLedgerStateByronToShelleyWrapper
287
- $ PCons translateLedgerStateShelleyToAllegraWrapper
288
- $ PCons translateLedgerStateAllegraToMaryWrapper
289
- $ PCons translateLedgerStateMaryToAlonzoWrapper
290
- $ PCons translateLedgerStateAlonzoToBabbageWrapper
291
- $ PCons translateLedgerStateBabbageToConwayWrapper
287
+ crossEraTickLedgerState =
288
+ PCons tickLedgerStateByronToShelley
289
+ $ PCons tickLedgerStateAcrossShelley
290
+ $ PCons tickLedgerStateAcrossShelley
291
+ $ PCons tickLedgerStateAcrossShelley
292
+ $ PCons tickLedgerStateAcrossShelley
293
+ $ PCons tickLedgerStateAcrossShelley
292
294
$ PNil
293
- , translateChainDepState =
294
- PCons translateChainDepStateByronToShelleyWrapper
295
- $ PCons translateChainDepStateAcrossShelley
296
- $ PCons translateChainDepStateAcrossShelley
297
- $ PCons translateChainDepStateAcrossShelley
298
- $ PCons translateChainDepStateAcrossShelley
299
- $ PCons translateChainDepStateAcrossShelley
295
+ , crossEraTickChainDepState =
296
+ PCons tickChainDepStateByronToShelley
297
+ $ PCons tickChainDepStateAcrossShelley
298
+ $ PCons tickChainDepStateAcrossShelley
299
+ $ PCons tickChainDepStateAcrossShelley
300
+ $ PCons tickChainDepStateAcrossShelley
301
+ $ PCons tickChainDepStateAcrossShelley
300
302
$ PNil
301
- , crossEraForecast =
303
+ , crossEraForecast =
302
304
PCons crossEraForecastByronToShelleyWrapper
303
305
$ PCons crossEraForecastAcrossShelley
304
306
$ PCons crossEraForecastAcrossShelley
@@ -324,8 +326,8 @@ instance CardanoHardForkConstraints c => CanHardFork (CardanoEras c) where
324
326
translateTxAllegraToMaryWrapper
325
327
translateValidatedTxAllegraToMaryWrapper
326
328
)
327
- $ PCons (RequireBoth $ \ _cfgMary cfgAlonzo ->
328
- let ctxt = getAlonzoTranslationContext cfgAlonzo
329
+ $ PCons (RequireBoth $ \ _cfgMary ( WrapLedgerConfig cfgAlonzo) ->
330
+ let ctxt = shelleyLedgerTranslationContext cfgAlonzo
329
331
in
330
332
Pair2
331
333
(translateTxMaryToAlonzoWrapper ctxt)
@@ -338,8 +340,8 @@ instance CardanoHardForkConstraints c => CanHardFork (CardanoEras c) where
338
340
(translateTxAlonzoToBabbageWrapper ctxt)
339
341
(translateValidatedTxAlonzoToBabbageWrapper ctxt)
340
342
)
341
- $ PCons (RequireBoth $ \ _cfgBabbage cfgConway ->
342
- let ctxt = getConwayTranslationContext cfgConway
343
+ $ PCons (RequireBoth $ \ _cfgBabbage ( WrapLedgerConfig cfgConway) ->
344
+ let ctxt = shelleyLedgerTranslationContext cfgConway
343
345
in
344
346
Pair2
345
347
(translateTxBabbageToConwayWrapper ctxt)
@@ -415,31 +417,34 @@ translatePointByronToShelley point bNo =
415
417
_otherwise ->
416
418
error " translatePointByronToShelley: invalid Byron state"
417
419
418
- translateLedgerStateByronToShelleyWrapper ::
420
+ tickLedgerStateByronToShelley ::
419
421
( ShelleyCompatible (TPraos c ) (ShelleyEra c )
420
422
, HASH c ~ Blake2b_256
421
423
, ADDRHASH c ~ Blake2b_224
422
424
)
423
425
=> RequiringBoth
424
426
WrapLedgerConfig
425
- ( Translate LedgerState )
427
+ CrossEraTickLedgerState
426
428
ByronBlock
427
429
(ShelleyBlock (TPraos c ) (ShelleyEra c ))
428
- translateLedgerStateByronToShelleyWrapper =
429
- RequireBoth $ \ _ (WrapLedgerConfig cfgShelley) -> Translate $
430
- translateLedgerStateByronToShelley
431
- (toFromByronTranslationContext (shelleyLedgerGenesis cfgShelley))
430
+ tickLedgerStateByronToShelley =
431
+ RequireBoth $ \ _ (WrapLedgerConfig cfgShelley) ->
432
+ CrossEraTickLedgerState $ \ bound slot ->
433
+ applyChainTickLedgerResult cfgShelley slot
434
+ . translateLedgerStateByronToShelley
435
+ (shelleyLedgerTranslationContext cfgShelley)
436
+ bound
432
437
433
438
translateLedgerStateByronToShelley ::
434
439
( ShelleyCompatible (TPraos c ) (ShelleyEra c )
435
440
, HASH c ~ Blake2b_256
436
441
, ADDRHASH c ~ Blake2b_224
437
442
)
438
443
=> SL. FromByronTranslationContext c
439
- -> EpochNo -- ^ Start of the new era
444
+ -> Bound -- ^ Start of the new era
440
445
-> LedgerState ByronBlock
441
446
-> LedgerState (ShelleyBlock (TPraos c ) (ShelleyEra c ))
442
- translateLedgerStateByronToShelley ctx epochNo ledgerByron =
447
+ translateLedgerStateByronToShelley ctx bound ledgerByron =
443
448
ShelleyLedgerState {
444
449
shelleyLedgerTip =
445
450
translatePointByronToShelley
@@ -448,23 +453,24 @@ translateLedgerStateByronToShelley ctx epochNo ledgerByron =
448
453
, shelleyLedgerState =
449
454
SL. translateToShelleyLedgerState
450
455
ctx
451
- epochNo
456
+ (boundEpoch bound)
452
457
(byronLedgerState ledgerByron)
453
458
, shelleyLedgerTransition =
454
459
ShelleyTransitionInfo {shelleyAfterVoting = 0 }
455
460
}
456
461
457
- translateChainDepStateByronToShelleyWrapper ::
458
- RequiringBoth
462
+ tickChainDepStateByronToShelley ::
463
+ ConsensusProtocol (TPraos c )
464
+ => RequiringBoth
459
465
WrapConsensusConfig
460
- ( Translate WrapChainDepState )
466
+ CrossEraTickChainDepState
461
467
ByronBlock
462
468
(ShelleyBlock (TPraos c ) (ShelleyEra c ))
463
- translateChainDepStateByronToShelleyWrapper =
469
+ tickChainDepStateByronToShelley =
464
470
RequireBoth $ \ _ (WrapConsensusConfig cfgShelley) ->
465
- Translate $ \ _ ( WrapChainDepState pbftState) ->
466
- WrapChainDepState $
467
- translateChainDepStateByronToShelley cfgShelley pbftState
471
+ CrossEraTickChainDepState $ \ _bound view slot ->
472
+ tickChainDepState cfgShelley view slot
473
+ . translateChainDepStateByronToShelley cfgShelley
468
474
469
475
translateChainDepStateByronToShelley ::
470
476
forall bc c .
@@ -555,18 +561,6 @@ crossEraForecastByronToShelleyWrapper =
555
561
Translation from Shelley to Allegra
556
562
-------------------------------------------------------------------------------}
557
563
558
- translateLedgerStateShelleyToAllegraWrapper ::
559
- (PraosCrypto c , DSignable c (Hash c EraIndependentTxBody ))
560
- => RequiringBoth
561
- WrapLedgerConfig
562
- (Translate LedgerState )
563
- (ShelleyBlock (TPraos c ) (ShelleyEra c ))
564
- (ShelleyBlock (TPraos c ) (AllegraEra c ))
565
- translateLedgerStateShelleyToAllegraWrapper =
566
- ignoringBoth $
567
- Translate $ \ _epochNo ->
568
- unComp . SL. translateEra' SL. NoGenesis . Comp
569
-
570
564
translateTxShelleyToAllegraWrapper ::
571
565
(PraosCrypto c , DSignable c (Hash c EraIndependentTxBody ))
572
566
=> InjectTx
@@ -587,18 +581,6 @@ translateValidatedTxShelleyToAllegraWrapper = InjectValidatedTx $
587
581
Translation from Allegra to Mary
588
582
-------------------------------------------------------------------------------}
589
583
590
- translateLedgerStateAllegraToMaryWrapper ::
591
- (PraosCrypto c , DSignable c (Hash c EraIndependentTxBody ))
592
- => RequiringBoth
593
- WrapLedgerConfig
594
- (Translate LedgerState )
595
- (ShelleyBlock (TPraos c ) (AllegraEra c ))
596
- (ShelleyBlock (TPraos c ) (MaryEra c ))
597
- translateLedgerStateAllegraToMaryWrapper =
598
- ignoringBoth $
599
- Translate $ \ _epochNo ->
600
- unComp . SL. translateEra' SL. NoGenesis . Comp
601
-
602
584
translateTxAllegraToMaryWrapper ::
603
585
(PraosCrypto c , DSignable c (Hash c EraIndependentTxBody ))
604
586
=> InjectTx
@@ -619,24 +601,6 @@ translateValidatedTxAllegraToMaryWrapper = InjectValidatedTx $
619
601
Translation from Mary to Alonzo
620
602
-------------------------------------------------------------------------------}
621
603
622
- translateLedgerStateMaryToAlonzoWrapper ::
623
- (PraosCrypto c , DSignable c (Hash c EraIndependentTxBody ))
624
- => RequiringBoth
625
- WrapLedgerConfig
626
- (Translate LedgerState )
627
- (ShelleyBlock (TPraos c ) (MaryEra c ))
628
- (ShelleyBlock (TPraos c ) (AlonzoEra c ))
629
- translateLedgerStateMaryToAlonzoWrapper =
630
- RequireBoth $ \ _cfgMary cfgAlonzo ->
631
- Translate $ \ _epochNo ->
632
- unComp . SL. translateEra' (getAlonzoTranslationContext cfgAlonzo) . Comp
633
-
634
- getAlonzoTranslationContext ::
635
- WrapLedgerConfig (ShelleyBlock (TPraos c ) (AlonzoEra c ))
636
- -> SL. TranslationContext (AlonzoEra c )
637
- getAlonzoTranslationContext =
638
- shelleyLedgerTranslationContext . unwrapLedgerConfig
639
-
640
604
translateTxMaryToAlonzoWrapper ::
641
605
(PraosCrypto c , DSignable c (Hash c EraIndependentTxBody ))
642
606
=> SL. TranslationContext (AlonzoEra c )
@@ -660,28 +624,6 @@ translateValidatedTxMaryToAlonzoWrapper ctxt = InjectValidatedTx $
660
624
Translation from Alonzo to Babbage
661
625
-------------------------------------------------------------------------------}
662
626
663
- translateLedgerStateAlonzoToBabbageWrapper ::
664
- (Praos. PraosCrypto c , TPraos. PraosCrypto c )
665
- => RequiringBoth
666
- WrapLedgerConfig
667
- (Translate LedgerState )
668
- (ShelleyBlock (TPraos c ) (AlonzoEra c ))
669
- (ShelleyBlock (Praos c ) (BabbageEra c ))
670
- translateLedgerStateAlonzoToBabbageWrapper =
671
- RequireBoth $ \ _cfgAlonzo _cfgBabbage ->
672
- Translate $ \ _epochNo ->
673
- unComp . SL. translateEra' SL. NoGenesis . Comp . transPraosLS
674
- where
675
- transPraosLS ::
676
- LedgerState (ShelleyBlock (TPraos c ) (AlonzoEra c )) ->
677
- LedgerState (ShelleyBlock (Praos c ) (AlonzoEra c ))
678
- transPraosLS (ShelleyLedgerState wo nes st) =
679
- ShelleyLedgerState
680
- { shelleyLedgerTip = fmap castShelleyTip wo
681
- , shelleyLedgerState = nes
682
- , shelleyLedgerTransition = st
683
- }
684
-
685
627
translateTxAlonzoToBabbageWrapper ::
686
628
(Praos. PraosCrypto c )
687
629
=> SL. TranslationContext (BabbageEra c )
@@ -722,24 +664,6 @@ translateValidatedTxAlonzoToBabbageWrapper ctxt = InjectValidatedTx $
722
664
Translation from Babbage to Conway
723
665
-------------------------------------------------------------------------------}
724
666
725
- translateLedgerStateBabbageToConwayWrapper ::
726
- (Praos. PraosCrypto c )
727
- => RequiringBoth
728
- WrapLedgerConfig
729
- (Translate LedgerState )
730
- (ShelleyBlock (Praos c ) (BabbageEra c ))
731
- (ShelleyBlock (Praos c ) (ConwayEra c ))
732
- translateLedgerStateBabbageToConwayWrapper =
733
- RequireBoth $ \ _cfgBabbage cfgConway ->
734
- Translate $ \ _epochNo ->
735
- unComp . SL. translateEra' (getConwayTranslationContext cfgConway) . Comp
736
-
737
- getConwayTranslationContext ::
738
- WrapLedgerConfig (ShelleyBlock (Praos c ) (ConwayEra c ))
739
- -> SL. TranslationContext (ConwayEra c )
740
- getConwayTranslationContext =
741
- shelleyLedgerTranslationContext . unwrapLedgerConfig
742
-
743
667
translateTxBabbageToConwayWrapper ::
744
668
(Praos. PraosCrypto c )
745
669
=> SL. TranslationContext (ConwayEra c )
0 commit comments