/
Node.hs
1308 lines (1195 loc) · 59.3 KB
/
Node.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans
-Wno-incomplete-patterns
-Wno-incomplete-uni-patterns
-Wno-incomplete-record-updates
-Wno-overlapping-patterns #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}
module Ouroboros.Consensus.Cardano.Node (
CardanoHardForkConstraints
, MaxMajorProtVer (..)
, ProtocolParamsAllegra (..)
, ProtocolParamsMary (..)
, ProtocolTransitionParamsShelleyBased (..)
, TriggerHardFork (..)
, protocolClientInfoCardano
, protocolInfoCardano
-- * SupportedNetworkProtocolVersion
, pattern CardanoNodeToClientVersion1
, pattern CardanoNodeToClientVersion10
, pattern CardanoNodeToClientVersion11
, pattern CardanoNodeToClientVersion2
, pattern CardanoNodeToClientVersion3
, pattern CardanoNodeToClientVersion4
, pattern CardanoNodeToClientVersion5
, pattern CardanoNodeToClientVersion6
, pattern CardanoNodeToClientVersion7
, pattern CardanoNodeToClientVersion8
, pattern CardanoNodeToClientVersion9
, pattern CardanoNodeToNodeVersion1
, pattern CardanoNodeToNodeVersion2
, pattern CardanoNodeToNodeVersion3
, pattern CardanoNodeToNodeVersion4
, pattern CardanoNodeToNodeVersion5
, pattern CardanoNodeToNodeVersion6
, pattern CardanoNodeToNodeVersion7
) where
import Cardano.Binary (DecoderError (..), enforceSize)
import Cardano.Chain.Slotting (EpochSlots)
import qualified Cardano.Ledger.BaseTypes as SL
import qualified Cardano.Ledger.Era as Core
import qualified Cardano.Ledger.Shelley.API as SL
import Cardano.Prelude (cborError)
import qualified Cardano.Protocol.TPraos.OCert as Absolute (KESPeriod (..),
ocertKESPeriod)
import Cardano.Slotting.Time (SystemStart (SystemStart))
import qualified Codec.CBOR.Decoding as CBOR
import Codec.CBOR.Encoding (Encoding)
import qualified Codec.CBOR.Encoding as CBOR
import Control.Exception (assert)
import qualified Data.ByteString.Short as Short
import Data.Functor.These (These1 (..))
import qualified Data.ListMap as ListMap
import qualified Data.Map.Strict as Map
import Data.SOP.Counting (Exactly (Exactly), exactlyWeakenNonEmpty,
nonEmptyLast)
import Data.SOP.Index (Index (..))
import Data.SOP.OptNP (NonEmptyOptNP, OptNP (OptSkip))
import qualified Data.SOP.OptNP as OptNP
import Data.SOP.Strict (K (K), NP (Nil, (:*)))
import Data.Word (Word16, Word64)
import Ouroboros.Consensus.Block (BlockConfig, BlockForging,
BlockProtocol, NestedCtxt (NestedCtxt), SlotNo (SlotNo),
SomeSecond (SomeSecond))
import Ouroboros.Consensus.Byron.Ledger (ByronBlock)
import qualified Ouroboros.Consensus.Byron.Ledger as Byron
import qualified Ouroboros.Consensus.Byron.Ledger.Conversions as Byron
import Ouroboros.Consensus.Byron.Ledger.NetworkProtocolVersion
(ByronNodeToClientVersion (ByronNodeToClientVersion1),
ByronNodeToNodeVersion (ByronNodeToNodeVersion1, ByronNodeToNodeVersion2))
import Ouroboros.Consensus.Byron.Node
(ProtocolParamsByron (ProtocolParamsByron, byronGenesis, byronLeaderCredentials, byronMaxTxCapacityOverrides),
byronBlockForging, protocolClientInfoByron,
protocolInfoByron)
import Ouroboros.Consensus.Cardano.Block (AllegraEra, AlonzoEra,
BabbageEra, BlockConfig (CardanoBlockConfig), CardanoBlock,
CardanoEras, CardanoShelleyEras,
CodecConfig (CardanoCodecConfig), ConwayEra, EraCrypto,
HardForkBlock (BlockAllegra, BlockAlonzo, BlockBabbage, BlockByron, BlockConway, BlockMary, BlockShelley),
Header (HeaderAllegra, HeaderAlonzo, HeaderBabbage, HeaderByron, HeaderConway, HeaderMary, HeaderShelley),
LedgerState, MaryEra, ShelleyBasedEra, ShelleyEra,
StandardCrypto, StorageConfig (CardanoStorageConfig))
import Ouroboros.Consensus.Cardano.CanHardFork
(ByronPartialLedgerConfig (ByronPartialLedgerConfig, byronLedgerConfig, byronTriggerHardFork),
CardanoHardForkConstraints,
ShelleyPartialLedgerConfig (ShelleyPartialLedgerConfig, shelleyLedgerConfig, shelleyTriggerHardFork),
TriggerHardFork (..))
import Ouroboros.Consensus.Config (SecurityParam (SecurityParam),
TopLevelConfig (..), configCodec, configStorage)
import Ouroboros.Consensus.HardFork.Combinator
(ConsensusConfig (HardForkConsensusConfig, hardForkConsensusConfigK, hardForkConsensusConfigPerEra, hardForkConsensusConfigShape),
HardForkLedgerConfig (HardForkLedgerConfig, hardForkLedgerConfigPerEra, hardForkLedgerConfigShape),
HasPartialConsensusConfig (PartialConsensusConfig),
HasPartialLedgerConfig (PartialLedgerConfig),
LedgerState (..), NestedCtxt_ (NCS, NCZ),
PerEraConsensusConfig (PerEraConsensusConfig),
PerEraLedgerConfig (PerEraLedgerConfig),
WrapPartialConsensusConfig (WrapPartialConsensusConfig),
WrapPartialLedgerConfig (WrapPartialLedgerConfig),
hardForkBlockForging)
import Ouroboros.Consensus.HardFork.Combinator.Embed.Nary
(injectInitialExtLedgerState)
import Ouroboros.Consensus.HardFork.Combinator.Serialisation
(EraNodeToClientVersion (EraNodeToClientDisabled, EraNodeToClientEnabled),
EraNodeToNodeVersion (EraNodeToNodeDisabled, EraNodeToNodeEnabled),
HardForkNodeToClientVersion (HardForkNodeToClientDisabled, HardForkNodeToClientEnabled),
HardForkNodeToNodeVersion (HardForkNodeToNodeDisabled, HardForkNodeToNodeEnabled),
HardForkSpecificNodeToClientVersion (HardForkSpecificNodeToClientVersion1, HardForkSpecificNodeToClientVersion2),
HardForkSpecificNodeToNodeVersion (HardForkSpecificNodeToNodeVersion1),
SerialiseConstraintsHFC, SerialiseHFC (..))
import qualified Ouroboros.Consensus.HardFork.History as History
import Ouroboros.Consensus.HeaderValidation (HeaderState)
import Ouroboros.Consensus.Ledger.Extended (ExtLedgerState (..))
import qualified Ouroboros.Consensus.Mempool as Mempool
import Ouroboros.Consensus.Node.NetworkProtocolVersion
(HasNetworkProtocolVersion (BlockNodeToClientVersion, BlockNodeToNodeVersion),
NodeToClientVersion (NodeToClientV_10, NodeToClientV_11, NodeToClientV_12, NodeToClientV_13, NodeToClientV_14, NodeToClientV_15, NodeToClientV_9),
NodeToNodeVersion (NodeToNodeV_10, NodeToNodeV_11, NodeToNodeV_7, NodeToNodeV_8, NodeToNodeV_9),
SupportedNetworkProtocolVersion (..))
import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolClientInfo (..),
ProtocolInfo (..))
import Ouroboros.Consensus.Node.Run
(SerialiseNodeToNodeConstraints (estimateBlockSize))
import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
import Ouroboros.Consensus.Protocol.Praos (Praos, PraosParams (..))
import Ouroboros.Consensus.Protocol.Praos.Common
(praosCanBeLeaderOpCert)
import Ouroboros.Consensus.Protocol.TPraos (TPraos, TPraosParams (..))
import qualified Ouroboros.Consensus.Protocol.TPraos as Shelley
import Ouroboros.Consensus.Shelley.Ledger (LedgerState (..),
ShelleyBlock, ShelleyCompatible)
import qualified Ouroboros.Consensus.Shelley.Ledger as Shelley
import Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion
(ShelleyNodeToClientVersion (ShelleyNodeToClientVersion1, ShelleyNodeToClientVersion2, ShelleyNodeToClientVersion3, ShelleyNodeToClientVersion4, ShelleyNodeToClientVersion5, ShelleyNodeToClientVersion6),
ShelleyNodeToNodeVersion (ShelleyNodeToNodeVersion1))
import Ouroboros.Consensus.Shelley.Node (MaxMajorProtVer (..),
ProtVer (pvMajor), ProtocolParamsAllegra (..),
ProtocolParamsAlonzo (..), ProtocolParamsMary (..),
ProtocolParamsShelley (..),
ProtocolParamsShelleyBased (..), ShelleyGenesis (..),
ShelleyGenesisStaking (..), ShelleyLeaderCredentials (..),
protocolClientInfoShelley, registerGenesisStaking,
registerInitialFunds, validateGenesis)
import Ouroboros.Consensus.Shelley.Node.Common (ShelleyEraWithCrypto,
shelleyBlockIssuerVKey, translateShelleyLeaderCredentials)
import Ouroboros.Consensus.Shelley.HFEras()
import Cardano.Ledger.Address (BootstrapAddress (..), RewardAcnt (..))
import qualified Cardano.Ledger.BaseTypes as SL
import Cardano.Ledger.CompactAddress (Addr (..))
import Cardano.Ledger.Core (PParams (..))
import Cardano.Ledger.Credential (StakeReference (..))
import Cardano.Ledger.Crypto (Crypto (..))
import Cardano.Ledger.Keys (GenDelegPair (..))
import Cardano.Ledger.PoolParams (PoolParams (..))
import Cardano.Ledger.Shelley.API (Credential (..))
import Cardano.Slotting.Time (SystemStart (SystemStart))
import Data.Coerce (coerce)
import qualified Data.Set as Set
import Ouroboros.Consensus.Cardano.Block
import Ouroboros.Consensus.Cardano.Block ()
import Ouroboros.Consensus.Cardano.CanHardFork
import Ouroboros.Consensus.Cardano.CanHardFork ()
import Ouroboros.Consensus.Protocol.BatchCompatibleCrypto
(BatchCompatibleCrypto)
import Ouroboros.Consensus.Protocol.Ledger.HotKey (HotKey (..))
import Ouroboros.Consensus.Protocol.Praos (Praos, PraosCrypto,
PraosParams (..))
import Ouroboros.Consensus.Protocol.Praos.Common
(praosCanBeLeaderOpCert, translateCanBeLeader)
import Ouroboros.Consensus.Protocol.Praos.Crypto
(CanConvertVRF (convertVKey))
import Ouroboros.Consensus.Shelley.Node.Praos
(ProtocolParamsBabbage (..), ProtocolParamsConway (..))
import qualified Ouroboros.Consensus.Shelley.Node.Praos as Praos
import qualified Ouroboros.Consensus.Shelley.Node.TPraos as TPraos
import Ouroboros.Consensus.Storage.Serialisation
(BinaryBlockInfo (headerOffset), DecodeDisk (decodeDisk),
EncodeDisk (encodeDisk),
HasBinaryBlockInfo (getBinaryBlockInfo),
PrefixLen (PrefixLen))
import Ouroboros.Consensus.Util.Assert (assertWithMsg)
import Ouroboros.Consensus.Util.IOLike (IOLike)
import Ouroboros.Network.Magic (NetworkMagic (..))
{-------------------------------------------------------------------------------
SerialiseHFC
-------------------------------------------------------------------------------}
instance SerialiseConstraintsHFC ByronBlock
-- | Important: we need to maintain binary compatibility with Byron blocks, as
-- they are already stored on disk.
--
-- We also want to be able to efficiently detect (without having to peek far
-- ahead) whether we're dealing with a Byron or Shelley block, so that we can
-- invoke the right decoder. We plan to have a few more hard forks after
-- Shelley (Goguen, Basho, Voltaire), so we want a future-proof envelope for
-- distinguishing the different block types, i.e., a byte indicating the era.
--
-- Byron does not provide such an envelope. However, a Byron block is a CBOR
-- 2-tuple with the first element being a tag ('Word': 0 = EBB; 1 = regular
-- block) and the second being the payload. We can easily extend this encoding
-- format with support for Shelley, Goguen, etc.
--
-- We encode a 'CardanoBlock' as the same CBOR 2-tuple as a Byron block, but
-- we use the tags after 1 for the hard forks after Byron:
--
-- 0. Byron EBB
-- 1. Byron regular block
-- 2. Shelley block
-- 3. Allegra block
-- 4. Mary block
-- 5. Goguen block
-- 6. etc.
--
-- For more details, see:
-- <https://github.com/input-output-hk/ouroboros-network/pull/1175#issuecomment-558147194>
instance CardanoHardForkConstraints c1 c2 => SerialiseHFC (CardanoEras c1 c2) where
encodeDiskHfcBlock (CardanoCodecConfig ccfgByron ccfgShelley ccfgAllegra ccfgMary ccfgAlonzo ccfgBabbage ccfgConway) = \case
-- We are backwards compatible with Byron and thus use the exact same
-- encoding.
BlockByron blockByron -> encodeDisk ccfgByron blockByron
-- For Shelley and later eras, we need to prepend the hard fork envelope.
BlockShelley blockShelley -> prependTag 2 $ encodeDisk ccfgShelley blockShelley
BlockAllegra blockAllegra -> prependTag 3 $ encodeDisk ccfgAllegra blockAllegra
BlockMary blockMary -> prependTag 4 $ encodeDisk ccfgMary blockMary
BlockAlonzo blockAlonzo -> prependTag 5 $ encodeDisk ccfgAlonzo blockAlonzo
BlockBabbage blockBabbage -> prependTag 6 $ encodeDisk ccfgBabbage blockBabbage
BlockConway blockConway -> prependTag 7 $ encodeDisk ccfgConway blockConway
decodeDiskHfcBlock (CardanoCodecConfig ccfgByron ccfgShelley ccfgAllegra ccfgMary ccfgAlonzo ccfgBabbage ccfgConway) = do
enforceSize "CardanoBlock" 2
CBOR.decodeWord >>= \case
0 -> fmap BlockByron <$> Byron.decodeByronBoundaryBlock epochSlots
1 -> fmap BlockByron <$> Byron.decodeByronRegularBlock epochSlots
-- We don't have to drop the first two bytes from the 'ByteString'
-- passed to the decoder as slicing already takes care of this.
2 -> fmap BlockShelley <$> decodeDisk ccfgShelley
3 -> fmap BlockAllegra <$> decodeDisk ccfgAllegra
4 -> fmap BlockMary <$> decodeDisk ccfgMary
5 -> fmap BlockAlonzo <$> decodeDisk ccfgAlonzo
6 -> fmap BlockBabbage <$> decodeDisk ccfgBabbage
7 -> fmap BlockConway <$> decodeDisk ccfgConway
t -> cborError $ DecoderErrorUnknownTag "CardanoBlock" (fromIntegral t)
where
epochSlots = Byron.getByronEpochSlots ccfgByron
reconstructHfcPrefixLen _ = PrefixLen 2
reconstructHfcNestedCtxt _ prefix blockSize =
case Short.index prefix 1 of
0 -> SomeSecond $ NestedCtxt (NCZ (Byron.CtxtByronBoundary blockSize))
1 -> SomeSecond $ NestedCtxt (NCZ (Byron.CtxtByronRegular blockSize))
2 -> SomeSecond $ NestedCtxt (NCS (NCZ Shelley.CtxtShelley))
3 -> SomeSecond $ NestedCtxt (NCS (NCS (NCZ Shelley.CtxtShelley)))
4 -> SomeSecond $ NestedCtxt (NCS (NCS (NCS (NCZ Shelley.CtxtShelley))))
5 -> SomeSecond $ NestedCtxt (NCS (NCS (NCS (NCS (NCZ Shelley.CtxtShelley)))))
6 -> SomeSecond $ NestedCtxt (NCS (NCS (NCS (NCS (NCS (NCZ Shelley.CtxtShelley))))))
7 -> SomeSecond $ NestedCtxt (NCS (NCS (NCS (NCS (NCS (NCS (NCZ Shelley.CtxtShelley)))))))
_ -> error $ "CardanoBlock: invalid prefix " <> show prefix
getHfcBinaryBlockInfo = \case
BlockByron blockByron ->
getBinaryBlockInfo blockByron
-- For Shelley and the later eras, we need to account for the two extra
-- bytes of the envelope.
BlockShelley blockShelley ->
shiftHeaderOffset 2 $ getBinaryBlockInfo blockShelley
BlockAllegra blockAllegra ->
shiftHeaderOffset 2 $ getBinaryBlockInfo blockAllegra
BlockMary blockMary ->
shiftHeaderOffset 2 $ getBinaryBlockInfo blockMary
BlockAlonzo blockAlonzo ->
shiftHeaderOffset 2 $ getBinaryBlockInfo blockAlonzo
BlockBabbage blockBabbage ->
shiftHeaderOffset 2 $ getBinaryBlockInfo blockBabbage
BlockConway blockConway ->
shiftHeaderOffset 2 $ getBinaryBlockInfo blockConway
where
shiftHeaderOffset :: Word16 -> BinaryBlockInfo -> BinaryBlockInfo
shiftHeaderOffset shift binfo = binfo {
headerOffset = headerOffset binfo + shift
}
estimateHfcBlockSize = \case
HeaderByron headerByron -> estimateBlockSize headerByron
-- For Shelley and later eras, we add two extra bytes, see the
-- 'SerialiseHFC' instance.
HeaderShelley headerShelley -> estimateBlockSize headerShelley + 2
HeaderAllegra headerAllegra -> estimateBlockSize headerAllegra + 2
HeaderMary headerMary -> estimateBlockSize headerMary + 2
HeaderAlonzo headerAlonzo -> estimateBlockSize headerAlonzo + 2
HeaderBabbage headerBabbage -> estimateBlockSize headerBabbage + 2
HeaderConway headerConway -> estimateBlockSize headerConway + 2
-- | Prepend the given tag by creating a CBOR 2-tuple with the tag as the
-- first element and the given 'Encoding' as the second.
prependTag :: Word -> Encoding -> Encoding
prependTag tag payload = mconcat [
CBOR.encodeListLen 2
, CBOR.encodeWord tag
, payload
]
{-------------------------------------------------------------------------------
SupportedNetworkProtocolVersion instance
-------------------------------------------------------------------------------}
-- Note: we don't support all combinations, so we don't declare them as
-- COMPLETE
-- | We support only Byron V1 with the hard fork disabled, as no other
-- versions have been released before the hard fork
pattern CardanoNodeToNodeVersion1 :: BlockNodeToNodeVersion (CardanoBlock c1 c2)
pattern CardanoNodeToNodeVersion1 =
HardForkNodeToNodeDisabled ByronNodeToNodeVersion1
-- | The hard fork enabled with the latest Byron version and the Shelley era
-- enabled.
pattern CardanoNodeToNodeVersion2 :: BlockNodeToNodeVersion (CardanoBlock c1 c2)
pattern CardanoNodeToNodeVersion2 =
HardForkNodeToNodeEnabled
HardForkSpecificNodeToNodeVersion1
( EraNodeToNodeEnabled ByronNodeToNodeVersion2
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeDisabled
:* EraNodeToNodeDisabled
:* EraNodeToNodeDisabled
:* EraNodeToNodeDisabled
:* EraNodeToNodeDisabled
:* Nil
)
-- | The hard fork enabled with the latest Byron version, the Shelley and
-- Allegra eras enabled.
pattern CardanoNodeToNodeVersion3 :: BlockNodeToNodeVersion (CardanoBlock c1 c2)
pattern CardanoNodeToNodeVersion3 =
HardForkNodeToNodeEnabled
HardForkSpecificNodeToNodeVersion1
( EraNodeToNodeEnabled ByronNodeToNodeVersion2
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeDisabled
:* EraNodeToNodeDisabled
:* EraNodeToNodeDisabled
:* EraNodeToNodeDisabled
:* Nil
)
-- | The hard fork enabled with the latest Byron version, the Shelley, Allegra,
-- and Mary eras enabled.
pattern CardanoNodeToNodeVersion4 :: BlockNodeToNodeVersion (CardanoBlock c1 c2)
pattern CardanoNodeToNodeVersion4 =
HardForkNodeToNodeEnabled
HardForkSpecificNodeToNodeVersion1
( EraNodeToNodeEnabled ByronNodeToNodeVersion2
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeDisabled
:* EraNodeToNodeDisabled
:* EraNodeToNodeDisabled
:* Nil
)
-- | The hard fork enabled with the latest Byron version, the Shelley, Allegra,
-- Mary and Alonzo eras enabled.
pattern CardanoNodeToNodeVersion5 :: BlockNodeToNodeVersion (CardanoBlock c1 c2)
pattern CardanoNodeToNodeVersion5 =
HardForkNodeToNodeEnabled
HardForkSpecificNodeToNodeVersion1
( EraNodeToNodeEnabled ByronNodeToNodeVersion2
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeDisabled
:* EraNodeToNodeDisabled
:* Nil
)
-- | The hard fork enabled with the latest Byron version, the Shelley, Allegra,
-- Mary, Alonzo and Babbage eras enabled.
pattern CardanoNodeToNodeVersion6 :: BlockNodeToNodeVersion (CardanoBlock c1 c2)
pattern CardanoNodeToNodeVersion6 =
HardForkNodeToNodeEnabled
HardForkSpecificNodeToNodeVersion1
( EraNodeToNodeEnabled ByronNodeToNodeVersion2
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeDisabled
:* Nil
)
-- | The hard fork enabled with the latest Byron version, the Shelley, Allegra,
-- Mary, Alonzo, Babbage and Conway eras enabled.
pattern CardanoNodeToNodeVersion7 :: BlockNodeToNodeVersion (CardanoBlock c1 c2)
pattern CardanoNodeToNodeVersion7 =
HardForkNodeToNodeEnabled
HardForkSpecificNodeToNodeVersion1
( EraNodeToNodeEnabled ByronNodeToNodeVersion2
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* EraNodeToNodeEnabled ShelleyNodeToNodeVersion1
:* Nil
)
-- | We support the sole Byron version with the hard fork disabled.
pattern CardanoNodeToClientVersion1 :: BlockNodeToClientVersion (CardanoBlock c1 c2)
pattern CardanoNodeToClientVersion1 =
HardForkNodeToClientDisabled ByronNodeToClientVersion1
-- | The hard fork enabled and the Shelley era enabled.
pattern CardanoNodeToClientVersion2 :: BlockNodeToClientVersion (CardanoBlock c1 c2)
pattern CardanoNodeToClientVersion2 =
HardForkNodeToClientEnabled
HardForkSpecificNodeToClientVersion1
( EraNodeToClientEnabled ByronNodeToClientVersion1
:* EraNodeToClientEnabled ShelleyNodeToClientVersion1
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* Nil
)
-- | The hard fork enabled and the Shelley era enabled, but using
-- 'ShelleyNodeToClientVersion2' and 'HardForkSpecificNodeToClientVersion2'.
pattern CardanoNodeToClientVersion3 :: BlockNodeToClientVersion (CardanoBlock c1 c2)
pattern CardanoNodeToClientVersion3 =
HardForkNodeToClientEnabled
HardForkSpecificNodeToClientVersion2
( EraNodeToClientEnabled ByronNodeToClientVersion1
:* EraNodeToClientEnabled ShelleyNodeToClientVersion2
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* Nil
)
-- | The hard fork enabled, and the Shelley and Allegra eras enabled.
--
-- We don't bother with 'ShelleyNodeToClientVersion1' and
-- 'HardForkSpecificNodeToClientVersion1'.
pattern CardanoNodeToClientVersion4 :: BlockNodeToClientVersion (CardanoBlock c1 c2)
pattern CardanoNodeToClientVersion4 =
HardForkNodeToClientEnabled
HardForkSpecificNodeToClientVersion2
( EraNodeToClientEnabled ByronNodeToClientVersion1
:* EraNodeToClientEnabled ShelleyNodeToClientVersion2
:* EraNodeToClientEnabled ShelleyNodeToClientVersion2
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* Nil
)
-- | The hard fork enabled, and the Shelley, Allegra, and Mary eras enabled.
--
-- We don't bother with 'ShelleyNodeToClientVersion1'.
pattern CardanoNodeToClientVersion5 :: BlockNodeToClientVersion (CardanoBlock c1 c2)
pattern CardanoNodeToClientVersion5 =
HardForkNodeToClientEnabled
HardForkSpecificNodeToClientVersion2
( EraNodeToClientEnabled ByronNodeToClientVersion1
:* EraNodeToClientEnabled ShelleyNodeToClientVersion2
:* EraNodeToClientEnabled ShelleyNodeToClientVersion2
:* EraNodeToClientEnabled ShelleyNodeToClientVersion2
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* Nil
)
-- | The hard fork enabled, and the Shelley, Allegra, and Mary eras enabled, but
-- using 'ShelleyNodeToClientVersion3' for the Shelley-based eras , which
-- enables new queries.
pattern CardanoNodeToClientVersion6 :: BlockNodeToClientVersion (CardanoBlock c1 c2)
pattern CardanoNodeToClientVersion6 =
HardForkNodeToClientEnabled
HardForkSpecificNodeToClientVersion2
( EraNodeToClientEnabled ByronNodeToClientVersion1
:* EraNodeToClientEnabled ShelleyNodeToClientVersion3
:* EraNodeToClientEnabled ShelleyNodeToClientVersion3
:* EraNodeToClientEnabled ShelleyNodeToClientVersion3
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* Nil
)
-- | The hard fork enabled, and the Shelley, Allegra, Mary and Alonzo eras enabled
pattern CardanoNodeToClientVersion7 :: BlockNodeToClientVersion (CardanoBlock c1 c2)
pattern CardanoNodeToClientVersion7 =
HardForkNodeToClientEnabled
HardForkSpecificNodeToClientVersion2
( EraNodeToClientEnabled ByronNodeToClientVersion1
:* EraNodeToClientEnabled ShelleyNodeToClientVersion4
:* EraNodeToClientEnabled ShelleyNodeToClientVersion4
:* EraNodeToClientEnabled ShelleyNodeToClientVersion4
:* EraNodeToClientEnabled ShelleyNodeToClientVersion4
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* Nil
)
-- | The hard fork enabled, and the Shelley, Allegra, Mary and Alonzo eras enabled
-- Using 'ShelleyNodeToClientVersion5' for the Shelley-based eras , which
-- enables new queries.
pattern CardanoNodeToClientVersion8 :: BlockNodeToClientVersion (CardanoBlock c1 c2)
pattern CardanoNodeToClientVersion8 =
HardForkNodeToClientEnabled
HardForkSpecificNodeToClientVersion2
( EraNodeToClientEnabled ByronNodeToClientVersion1
:* EraNodeToClientEnabled ShelleyNodeToClientVersion5
:* EraNodeToClientEnabled ShelleyNodeToClientVersion5
:* EraNodeToClientEnabled ShelleyNodeToClientVersion5
:* EraNodeToClientEnabled ShelleyNodeToClientVersion5
:* EraNodeToClientDisabled
:* EraNodeToClientDisabled
:* Nil
)
-- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo and Babbage
-- eras enabled Using 'ShelleyNodeToClientVersion5' for the Shelley-based eras,
-- which enables new queries.
pattern CardanoNodeToClientVersion9 :: BlockNodeToClientVersion (CardanoBlock c1 c2)
pattern CardanoNodeToClientVersion9 =
HardForkNodeToClientEnabled
HardForkSpecificNodeToClientVersion2
( EraNodeToClientEnabled ByronNodeToClientVersion1
:* EraNodeToClientEnabled ShelleyNodeToClientVersion5
:* EraNodeToClientEnabled ShelleyNodeToClientVersion5
:* EraNodeToClientEnabled ShelleyNodeToClientVersion5
:* EraNodeToClientEnabled ShelleyNodeToClientVersion5
:* EraNodeToClientEnabled ShelleyNodeToClientVersion5
:* EraNodeToClientDisabled
:* Nil
)
-- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo and Babbage
-- eras enabled Using 'ShelleyNodeToClientVersion6' for the Shelley-based eras,
-- which enables new queries.
pattern CardanoNodeToClientVersion10 :: BlockNodeToClientVersion (CardanoBlock c1 c2)
pattern CardanoNodeToClientVersion10 =
HardForkNodeToClientEnabled
HardForkSpecificNodeToClientVersion2
( EraNodeToClientEnabled ByronNodeToClientVersion1
:* EraNodeToClientEnabled ShelleyNodeToClientVersion6
:* EraNodeToClientEnabled ShelleyNodeToClientVersion6
:* EraNodeToClientEnabled ShelleyNodeToClientVersion6
:* EraNodeToClientEnabled ShelleyNodeToClientVersion6
:* EraNodeToClientEnabled ShelleyNodeToClientVersion6
:* EraNodeToClientDisabled
:* Nil
)
-- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo, Babbage and
-- Conway eras enabled Using 'ShelleyNodeToClientVersion6' for the
-- Shelley-based eras, which enables new queries.
pattern CardanoNodeToClientVersion11 :: BlockNodeToClientVersion (CardanoBlock c1 c2)
pattern CardanoNodeToClientVersion11 =
HardForkNodeToClientEnabled
HardForkSpecificNodeToClientVersion2
( EraNodeToClientEnabled ByronNodeToClientVersion1
:* EraNodeToClientEnabled ShelleyNodeToClientVersion6
:* EraNodeToClientEnabled ShelleyNodeToClientVersion6
:* EraNodeToClientEnabled ShelleyNodeToClientVersion6
:* EraNodeToClientEnabled ShelleyNodeToClientVersion6
:* EraNodeToClientEnabled ShelleyNodeToClientVersion6
:* EraNodeToClientEnabled ShelleyNodeToClientVersion6
:* Nil
)
instance CardanoHardForkConstraints c1 c2
=> SupportedNetworkProtocolVersion (CardanoBlock c1 c2) where
supportedNodeToNodeVersions _ = Map.fromList
[ (NodeToNodeV_7, CardanoNodeToNodeVersion5)
, (NodeToNodeV_8, CardanoNodeToNodeVersion5)
, (NodeToNodeV_9, CardanoNodeToNodeVersion6)
, (NodeToNodeV_10, CardanoNodeToNodeVersion6)
, (NodeToNodeV_11, CardanoNodeToNodeVersion7)
]
supportedNodeToClientVersions _ = Map.fromList
[ (NodeToClientV_9 , CardanoNodeToClientVersion7)
, (NodeToClientV_10, CardanoNodeToClientVersion7)
, (NodeToClientV_11, CardanoNodeToClientVersion8)
, (NodeToClientV_12, CardanoNodeToClientVersion8)
, (NodeToClientV_13, CardanoNodeToClientVersion9)
, (NodeToClientV_14, CardanoNodeToClientVersion10)
, (NodeToClientV_15, CardanoNodeToClientVersion11)
]
latestReleasedNodeVersion _prx = (Just NodeToNodeV_10, Just NodeToClientV_14)
{-------------------------------------------------------------------------------
ProtocolInfo
-------------------------------------------------------------------------------}
-- | Parameters needed to transition to a Shelley era.
data ProtocolTransitionParamsShelleyBased era = ProtocolTransitionParamsShelleyBased {
transitionTranslationContext :: Core.TranslationContext era
, transitionTrigger :: TriggerHardFork
}
-- | Create a 'ProtocolInfo' for 'CardanoBlock'
--
-- NOTE: the initial staking and funds in the 'ShelleyGenesis' are ignored,
-- /unless/ configured to skip the Byron era and hard fork to Shelley or a later
-- era from the start using @TriggerHardForkAtEpoch 0@ for testing purposes.
--
-- PRECONDITION: only a single set of Shelley credentials is allowed when used
-- for mainnet (check against @'SL.gNetworkId' 'shelleyBasedGenesis'@).
protocolInfoCardano ::
forall c1 c2 m. (IOLike m, KES c1 ~ KES c2, CardanoHardForkConstraints c1 c2)
=> ProtocolParamsByron
-> ProtocolParamsShelleyBased (ShelleyEra c1)
-> ProtocolParamsShelley c1
-> ProtocolParamsAllegra c1
-> ProtocolParamsMary c1
-> ProtocolParamsAlonzo c1
-> ProtocolParamsBabbage c1
-> ProtocolParamsConway c2
-> ProtocolTransitionParamsShelleyBased (ShelleyEra c1)
-> ProtocolTransitionParamsShelleyBased (AllegraEra c1)
-> ProtocolTransitionParamsShelleyBased (MaryEra c1)
-> ProtocolTransitionParamsShelleyBased (AlonzoEra c1)
-> ProtocolTransitionParamsShelleyBased (BabbageEra c1)
-> ProtocolTransitionParamsShelleyBased (ConwayEra c2)
-> ProtocolInfo m (CardanoBlock c1 c2)
protocolInfoCardano protocolParamsByron@ProtocolParamsByron {
byronGenesis = genesisByron
, byronLeaderCredentials = mCredsByron
, byronMaxTxCapacityOverrides = maxTxCapacityOverridesByron
}
ProtocolParamsShelleyBased {
shelleyBasedGenesis = genesisShelley
, shelleyBasedInitialNonce = initialNonceShelley
, shelleyBasedLeaderCredentials = credssShelleyBased
}
ProtocolParamsShelley {
shelleyProtVer = protVerShelley
, shelleyMaxTxCapacityOverrides = maxTxCapacityOverridesShelley
}
ProtocolParamsAllegra {
allegraProtVer = protVerAllegra
, allegraMaxTxCapacityOverrides = maxTxCapacityOverridesAllegra
}
ProtocolParamsMary {
maryProtVer = protVerMary
, maryMaxTxCapacityOverrides = maxTxCapacityOverridesMary
}
ProtocolParamsAlonzo {
alonzoProtVer = protVerAlonzo
, alonzoMaxTxCapacityOverrides = maxTxCapacityOverridesAlonzo
}
ProtocolParamsBabbage {
babbageProtVer = protVerBabbage
, babbageMaxTxCapacityOverrides = maxTxCapacityOverridesBabbage
}
ProtocolParamsConway {
conwayProtVer = protVerConway
, conwayMaxTxCapacityOverrides = maxTxCapacityOverridesConway
}
ProtocolTransitionParamsShelleyBased {
transitionTranslationContext = transCtxtShelley
, transitionTrigger = triggerHardForkShelley
}
ProtocolTransitionParamsShelleyBased {
transitionTranslationContext = ()
, transitionTrigger = triggerHardForkAllegra
}
ProtocolTransitionParamsShelleyBased {
transitionTranslationContext = ()
, transitionTrigger = triggerHardForkMary
}
ProtocolTransitionParamsShelleyBased {
transitionTranslationContext = transCtxtAlonzo
, transitionTrigger = triggerHardForkAlonzo
}
ProtocolTransitionParamsShelleyBased {
transitionTranslationContext = transCtxtBabbage
, transitionTrigger = triggerHardForkBabbage
}
ProtocolTransitionParamsShelleyBased {
transitionTranslationContext = transCtxtConway
, transitionTrigger = triggerHardForkConway
}
| SL.Mainnet <- SL.sgNetworkId genesisShelley
, length credssShelleyBased > 1
= error "Multiple Shelley-based credentials not allowed for mainnet"
| otherwise
= assertWithMsg (validateGenesis genesisShelley) $
ProtocolInfo {
pInfoConfig = cfg
, pInfoInitLedger = initExtLedgerStateCardano
, pInfoBlockForging = blockForging
}
where
-- The major protocol version of the last era is the maximum major protocol
-- version we support.
maxMajorProtVer :: MaxMajorProtVer
maxMajorProtVer =
MaxMajorProtVer
$ pvMajor
$ nonEmptyLast
$ exactlyWeakenNonEmpty protVers
where
protVers :: Exactly (CardanoShelleyEras StandardCrypto BatchCompatibleCrypto) ProtVer
protVers = Exactly $
-- ensure that these have the same order as 'CardanoShelleyEras'!
K protVerShelley :*
K protVerAllegra :*
K protVerMary :*
K protVerAlonzo :*
K protVerBabbage :*
K protVerConway :*
Nil
-- Byron
ProtocolInfo {
pInfoConfig = topLevelConfigByron@TopLevelConfig {
topLevelConfigProtocol = consensusConfigByron
, topLevelConfigLedger = ledgerConfigByron
, topLevelConfigBlock = blockConfigByron
}
, pInfoInitLedger = initExtLedgerStateByron
} = protocolInfoByron @m protocolParamsByron
partialConsensusConfigByron :: PartialConsensusConfig (BlockProtocol ByronBlock)
partialConsensusConfigByron = consensusConfigByron
partialLedgerConfigByron :: PartialLedgerConfig ByronBlock
partialLedgerConfigByron = ByronPartialLedgerConfig {
byronLedgerConfig = ledgerConfigByron
, byronTriggerHardFork = triggerHardForkShelley
}
kByron :: SecurityParam
kByron = Byron.genesisSecurityParam genesisByron
-- Shelley
tpraosParams :: TPraosParams
tpraosParams =
Shelley.mkTPraosParams
maxMajorProtVer
initialNonceShelley
genesisShelley
TPraosParams { tpraosSlotsPerKESPeriod, tpraosMaxKESEvo } = tpraosParams
systemStart = SystemStart $ SL.sgSystemStart genesisShelley
networkMagic = NetworkMagic $ SL.sgNetworkMagic genesisShelley
praosParams :: PraosParams
praosParams = PraosParams
{ praosSlotsPerKESPeriod = SL.sgSlotsPerKESPeriod genesisShelley,
praosLeaderF = SL.mkActiveSlotCoeff $ SL.sgActiveSlotsCoeff genesisShelley,
praosSecurityParam = SecurityParam $ SL.sgSecurityParam genesisShelley,
praosMaxKESEvo = SL.sgMaxKESEvolutions genesisShelley,
praosQuorum = SL.sgUpdateQuorum genesisShelley,
praosMaxMajorPV = maxMajorProtVer,
praosMaxLovelaceSupply = SL.sgMaxLovelaceSupply genesisShelley,
praosNetworkId = SL.sgNetworkId genesisShelley,
praosSystemStart = systemStart
}
PraosParams { praosSlotsPerKESPeriod, praosMaxKESEvo } = praosParams
blockConfigShelley :: BlockConfig (ShelleyBlock (TPraos c1) (ShelleyEra c1))
blockConfigShelley =
Shelley.mkShelleyBlockConfig
protVerShelley
systemStart
networkMagic
(shelleyBlockIssuerVKey <$> credssShelleyBased)
partialConsensusConfigShelley ::
PartialConsensusConfig (BlockProtocol (ShelleyBlock (TPraos c1) (ShelleyEra c1)))
partialConsensusConfigShelley = tpraosParams
partialLedgerConfigShelley :: PartialLedgerConfig (ShelleyBlock (TPraos c1) (ShelleyEra c1))
partialLedgerConfigShelley =
mkPartialLedgerConfigShelley
genesisShelley
transCtxtShelley
maxMajorProtVer
triggerHardForkAllegra
kShelley :: SecurityParam
kShelley = SecurityParam $ sgSecurityParam genesisShelley
-- Allegra
blockConfigAllegra :: BlockConfig (ShelleyBlock (TPraos c1) (AllegraEra c1))
blockConfigAllegra =
Shelley.mkShelleyBlockConfig
protVerAllegra
systemStart
networkMagic
(shelleyBlockIssuerVKey <$> credssShelleyBased)
partialConsensusConfigAllegra ::
PartialConsensusConfig (BlockProtocol (ShelleyBlock (TPraos c1) (AllegraEra c1)))
partialConsensusConfigAllegra = tpraosParams
partialLedgerConfigAllegra :: PartialLedgerConfig (ShelleyBlock (TPraos c1) (AllegraEra c1))
partialLedgerConfigAllegra =
mkPartialLedgerConfigShelley
genesisShelley
() -- trivial translation context
maxMajorProtVer
triggerHardForkMary
-- Mary
blockConfigMary :: BlockConfig (ShelleyBlock (TPraos c1) (MaryEra c1))
blockConfigMary =
Shelley.mkShelleyBlockConfig
protVerMary
systemStart
networkMagic
(shelleyBlockIssuerVKey <$> credssShelleyBased)
partialConsensusConfigMary ::
PartialConsensusConfig (BlockProtocol (ShelleyBlock (TPraos c1) (MaryEra c1)))
partialConsensusConfigMary = tpraosParams
partialLedgerConfigMary :: PartialLedgerConfig (ShelleyBlock (TPraos c1) (MaryEra c1))
partialLedgerConfigMary =
mkPartialLedgerConfigShelley
genesisShelley
() -- trivial translation context
maxMajorProtVer
triggerHardForkAlonzo
-- Alonzo
blockConfigAlonzo :: BlockConfig (ShelleyBlock (TPraos c1) (AlonzoEra c1))
blockConfigAlonzo =
Shelley.mkShelleyBlockConfig
protVerAlonzo
systemStart
networkMagic
(shelleyBlockIssuerVKey <$> credssShelleyBased)
partialConsensusConfigAlonzo ::
PartialConsensusConfig (BlockProtocol (ShelleyBlock (TPraos c1) (AlonzoEra c1)))
partialConsensusConfigAlonzo = tpraosParams
partialLedgerConfigAlonzo :: PartialLedgerConfig (ShelleyBlock (TPraos c1) (AlonzoEra c1))
partialLedgerConfigAlonzo =
mkPartialLedgerConfigShelley
genesisShelley
transCtxtAlonzo
maxMajorProtVer
triggerHardForkBabbage
-- Babbage
blockConfigBabbage :: BlockConfig (ShelleyBlock (Praos c1) (BabbageEra c1))
blockConfigBabbage =
Shelley.mkShelleyBlockConfig
protVerBabbage
systemStart
networkMagic
(shelleyBlockIssuerVKey <$> credssShelleyBased)
partialConsensusConfigBabbage ::
PartialConsensusConfig (BlockProtocol (ShelleyBlock (Praos c1) (BabbageEra c1)))
partialConsensusConfigBabbage = praosParams
partialLedgerConfigBabbage :: PartialLedgerConfig (ShelleyBlock (Praos c1) (BabbageEra c1))
partialLedgerConfigBabbage =
mkPartialLedgerConfigShelley
genesisShelley
transCtxtBabbage
maxMajorProtVer
triggerHardForkConway
-- Conway
genesisShelleyConway :: ShelleyGenesis c2
genesisShelleyConway = translateShelleyGenesis genesisShelley
blockConfigConway :: BlockConfig (ShelleyBlock (Praos c2) (ConwayEra c2))
blockConfigConway =
Shelley.mkShelleyBlockConfig
protVerConway
systemStart
networkMagic
(shelleyBlockIssuerVKey . translateShelleyLeaderCredentials <$> credssShelleyBased)
partialConsensusConfigConway ::
PartialConsensusConfig (BlockProtocol (ShelleyBlock (Praos c2) (ConwayEra c2)))
partialConsensusConfigConway = praosParams
partialLedgerConfigConway :: PartialLedgerConfig (ShelleyBlock (Praos c2) (ConwayEra c2))
partialLedgerConfigConway =
mkPartialLedgerConfigShelley
genesisShelleyConway
transCtxtConway
maxMajorProtVer
TriggerHardForkNever
-- Cardano
k :: SecurityParam
k = assert (kByron == kShelley) kByron
shape :: History.Shape (CardanoEras c1 c2)
shape = History.Shape $ Exactly $
K (Byron.byronEraParams genesisByron)
:* K (Shelley.shelleyEraParams genesisShelley)
:* K (Shelley.shelleyEraParams genesisShelley)
:* K (Shelley.shelleyEraParams genesisShelley)
:* K (Shelley.shelleyEraParams genesisShelley)
:* K (Shelley.shelleyEraParams genesisShelley)
:* K (Shelley.shelleyEraParams genesisShelley)
:* Nil
cfg :: TopLevelConfig (CardanoBlock c1 c2)
cfg = TopLevelConfig {
topLevelConfigProtocol = HardForkConsensusConfig {
hardForkConsensusConfigK = k
, hardForkConsensusConfigShape = shape
, hardForkConsensusConfigPerEra = PerEraConsensusConfig
( WrapPartialConsensusConfig partialConsensusConfigByron
:* WrapPartialConsensusConfig partialConsensusConfigShelley
:* WrapPartialConsensusConfig partialConsensusConfigAllegra
:* WrapPartialConsensusConfig partialConsensusConfigMary
:* WrapPartialConsensusConfig partialConsensusConfigAlonzo
:* WrapPartialConsensusConfig partialConsensusConfigBabbage
:* WrapPartialConsensusConfig partialConsensusConfigConway
:* Nil
)
}
, topLevelConfigLedger = HardForkLedgerConfig {
hardForkLedgerConfigShape = shape
, hardForkLedgerConfigPerEra = PerEraLedgerConfig
( WrapPartialLedgerConfig partialLedgerConfigByron
:* WrapPartialLedgerConfig partialLedgerConfigShelley
:* WrapPartialLedgerConfig partialLedgerConfigAllegra
:* WrapPartialLedgerConfig partialLedgerConfigMary
:* WrapPartialLedgerConfig partialLedgerConfigAlonzo
:* WrapPartialLedgerConfig partialLedgerConfigBabbage
:* WrapPartialLedgerConfig partialLedgerConfigConway
:* Nil
)
}
, topLevelConfigBlock =
CardanoBlockConfig
blockConfigByron
blockConfigShelley
blockConfigAllegra
blockConfigMary
blockConfigAlonzo
blockConfigBabbage
blockConfigConway
, topLevelConfigCodec =
CardanoCodecConfig
(configCodec topLevelConfigByron)
Shelley.ShelleyCodecConfig
Shelley.ShelleyCodecConfig
Shelley.ShelleyCodecConfig
Shelley.ShelleyCodecConfig
Shelley.ShelleyCodecConfig
Shelley.ShelleyCodecConfig
, topLevelConfigStorage =
CardanoStorageConfig
(configStorage topLevelConfigByron)
(Shelley.ShelleyStorageConfig tpraosSlotsPerKESPeriod k)
(Shelley.ShelleyStorageConfig tpraosSlotsPerKESPeriod k)