Skip to content

Commit 8b8f9db

Browse files
committed
WIP ThreadNet: abstract protocolInfoShelleyBasedHardFork
1 parent 94cb00e commit 8b8f9db

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

ouroboros-consensus-cardano/src/unstable-cardano-testlib/Test/ThreadNet/Infra/ShelleyBasedHardFork.hs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ type ShelleyBasedHardForkConstraints proto1 era1 proto2 era2 =
193193
, -- At the moment, fix the protocols together
194194
ProtoCrypto proto1 ~ ProtoCrypto proto2
195195
, PraosCrypto (ProtoCrypto proto1)
196-
, proto1 ~ TPraos (ProtoCrypto proto1)
197196
, proto1 ~ proto2
198197
, MemPack (TxOut (LedgerState (ShelleyBlock proto1 era1)))
199198
, MemPack (TxOut (LedgerState (ShelleyBlock proto2 era2)))
@@ -390,7 +389,23 @@ protocolInfoShelleyBasedHardFork ::
390389
( KESAgentContext (ProtoCrypto proto2) m
391390
, ShelleyBasedHardForkConstraints proto1 era1 proto2 era2
392391
) =>
392+
( ProtocolParamsShelleyBased (ProtoCrypto proto1) ->
393+
L.TransitionConfig era1 ->
394+
SL.ProtVer ->
395+
( ProtocolInfo (ShelleyBlock proto1 era1)
396+
, Tracer.Tracer m KESAgentClientTrace -> m [MkBlockForging m (ShelleyBlock proto1 era1)]
397+
)
398+
) ->
399+
( ProtocolParamsShelleyBased (ProtoCrypto proto2) ->
400+
L.TransitionConfig era2 ->
401+
SL.ProtVer ->
402+
( ProtocolInfo (ShelleyBlock proto2 era2)
403+
, Tracer.Tracer m KESAgentClientTrace -> m [MkBlockForging m (ShelleyBlock proto2 era2)]
404+
)
405+
) ->
393406
ProtocolParamsShelleyBased (ProtoCrypto proto1) ->
407+
(ConsensusConfig proto1 -> PartialConsensusConfig proto1) ->
408+
(ConsensusConfig proto2 -> PartialConsensusConfig proto2) ->
394409
SL.ProtVer ->
395410
SL.ProtVer ->
396411
L.TransitionConfig era2 ->
@@ -400,7 +415,11 @@ protocolInfoShelleyBasedHardFork ::
400415
m [MkBlockForging m (ShelleyBasedHardForkBlock proto1 era1 proto2 era2)]
401416
)
402417
protocolInfoShelleyBasedHardFork
418+
protocolInfoProtoShelleyBased1 -- TODO(geo2a): come up with a better name for this argument
419+
protocolInfoProtoShelleyBased2
403420
protocolParamsShelleyBased
421+
toPartialConsensusConfig1
422+
toPartialConsensusConfig2
404423
protVer1
405424
protVer2
406425
transCfg2
@@ -410,20 +429,15 @@ protocolInfoShelleyBasedHardFork
410429
protocolInfo1
411430
blockForging1
412431
eraParams1
413-
tpraosParams
432+
toPartialConsensusConfig1
414433
toPartialLedgerConfig1
415434
-- Era 2
416435
protocolInfo2
417436
blockForging2
418437
eraParams2
419-
tpraosParams
438+
toPartialConsensusConfig2
420439
toPartialLedgerConfig2
421440
where
422-
ProtocolParamsShelleyBased
423-
{ shelleyBasedInitialNonce
424-
, shelleyBasedLeaderCredentials
425-
} = protocolParamsShelleyBased
426-
427441
-- Era 1
428442

429443
genesis :: SL.ShelleyGenesis
@@ -433,7 +447,7 @@ protocolInfoShelleyBasedHardFork
433447
blockForging1 ::
434448
Tracer.Tracer m KESAgentClientTrace -> m [MkBlockForging m (ShelleyBlock proto1 era1)]
435449
(protocolInfo1, blockForging1) =
436-
protocolInfoTPraosShelleyBased
450+
protocolInfoProtoShelleyBased1
437451
protocolParamsShelleyBased
438452
(transCfg2 ^. L.tcPreviousEraConfigL)
439453
protVer1
@@ -456,11 +470,8 @@ protocolInfoShelleyBasedHardFork
456470
blockForging2 ::
457471
Tracer.Tracer m KESAgentClientTrace -> m [MkBlockForging m (ShelleyBlock proto2 era2)]
458472
(protocolInfo2, blockForging2) =
459-
protocolInfoTPraosShelleyBased
460-
ProtocolParamsShelleyBased
461-
{ shelleyBasedInitialNonce
462-
, shelleyBasedLeaderCredentials
463-
}
473+
protocolInfoProtoShelleyBased2
474+
protocolParamsShelleyBased
464475
transCfg2
465476
protVer2
466477

ouroboros-consensus-cardano/test/cardano-test/Test/ThreadNet/AllegraMary.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ import Ouroboros.Consensus.Ledger.SupportsMempool (extractTxs)
3636
import Ouroboros.Consensus.Node.ProtocolInfo
3737
import Ouroboros.Consensus.NodeId
3838
import Ouroboros.Consensus.Protocol.TPraos (TPraos)
39+
import qualified Ouroboros.Consensus.Protocol.TPraos as TPraos
3940
import Ouroboros.Consensus.Shelley.Eras
4041
import Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol ()
4142
import Ouroboros.Consensus.Shelley.Node
4243
( ProtocolParamsShelleyBased (..)
4344
, ShelleyGenesis (..)
45+
, protocolInfoTPraosShelleyBased
4446
)
4547
import Test.Consensus.Shelley.MockCrypto (MockCrypto)
4648
import Test.QuickCheck
@@ -178,7 +180,11 @@ prop_simple_allegraMary_convergence
178180
TriggerHardForkAtVersion $ SL.getVersion majorVersion2
179181
(protocolInfo, blockForging) =
180182
protocolInfoShelleyBasedHardFork
183+
protocolInfoTPraosShelleyBased
184+
protocolInfoTPraosShelleyBased
181185
protocolParamsShelleyBased
186+
TPraos.tpraosParams
187+
TPraos.tpraosParams
182188
(SL.ProtVer majorVersion1 0)
183189
(SL.ProtVer majorVersion2 0)
184190
( L.mkTransitionConfig L.NoGenesis $

ouroboros-consensus-cardano/test/cardano-test/Test/ThreadNet/MaryAlonzo.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ import Ouroboros.Consensus.Ledger.SupportsMempool (extractTxs)
4141
import Ouroboros.Consensus.Node.ProtocolInfo
4242
import Ouroboros.Consensus.NodeId
4343
import Ouroboros.Consensus.Protocol.TPraos (TPraos)
44+
import qualified Ouroboros.Consensus.Protocol.TPraos as TPraos
4445
import Ouroboros.Consensus.Shelley.Eras
4546
import Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol ()
4647
import Ouroboros.Consensus.Shelley.Node
4748
( ProtocolParamsShelleyBased (..)
4849
, ShelleyGenesis (..)
50+
, protocolInfoTPraosShelleyBased
4951
)
5052
import qualified Test.Cardano.Ledger.Alonzo.Examples as SL
5153
import Test.Consensus.Shelley.MockCrypto (MockCrypto)
@@ -184,7 +186,11 @@ prop_simple_allegraAlonzo_convergence
184186
TriggerHardForkAtVersion $ SL.getVersion majorVersion2
185187
(protocolInfo, blockForging) =
186188
protocolInfoShelleyBasedHardFork
189+
protocolInfoTPraosShelleyBased
190+
protocolInfoTPraosShelleyBased
187191
protocolParamsShelleyBased
192+
TPraos.tpraosParams
193+
TPraos.tpraosParams
188194
(SL.ProtVer majorVersion1 0)
189195
(SL.ProtVer majorVersion2 0)
190196
( L.mkTransitionConfig alonzoGenesis $

ouroboros-consensus-cardano/test/cardano-test/Test/ThreadNet/ShelleyAllegra.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ import Ouroboros.Consensus.Ledger.SupportsMempool (extractTxs)
3636
import Ouroboros.Consensus.Node.ProtocolInfo
3737
import Ouroboros.Consensus.NodeId
3838
import Ouroboros.Consensus.Protocol.TPraos (TPraos)
39+
import qualified Ouroboros.Consensus.Protocol.TPraos as TPraos
3940
import Ouroboros.Consensus.Shelley.Eras
4041
import Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol ()
4142
import Ouroboros.Consensus.Shelley.Node
4243
( ProtocolParamsShelleyBased (..)
4344
, ShelleyGenesis (..)
45+
, protocolInfoTPraosShelleyBased
4446
)
4547
import Test.Consensus.Shelley.MockCrypto (MockCrypto)
4648
import Test.QuickCheck
@@ -187,7 +189,11 @@ prop_simple_shelleyAllegra_convergence
187189
TriggerHardForkAtVersion $ SL.getVersion majorVersion2
188190
(protocolInfo, blockForging) =
189191
protocolInfoShelleyBasedHardFork
192+
protocolInfoTPraosShelleyBased
193+
protocolInfoTPraosShelleyBased
190194
protocolParamsShelleyBased
195+
TPraos.tpraosParams
196+
TPraos.tpraosParams
191197
(SL.ProtVer majorVersion1 0)
192198
(SL.ProtVer majorVersion2 0)
193199
( L.mkTransitionConfig L.NoGenesis $

0 commit comments

Comments
 (0)