Skip to content

Commit 250dcc5

Browse files
committed
WIP ThreadNet: abstract protocolInfoShelleyBasedHardFork
1 parent c0aacc2 commit 250dcc5

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
@@ -194,7 +194,6 @@ type ShelleyBasedHardForkConstraints proto1 era1 proto2 era2 =
194194
, -- At the moment, fix the protocols together
195195
ProtoCrypto proto1 ~ ProtoCrypto proto2
196196
, PraosCrypto (ProtoCrypto proto1)
197-
, proto1 ~ TPraos (ProtoCrypto proto1)
198197
, proto1 ~ proto2
199198
, MemPack (TxOut (LedgerState (ShelleyBlock proto1 era1)))
200199
, MemPack (TxOut (LedgerState (ShelleyBlock proto2 era2)))
@@ -391,7 +390,23 @@ protocolInfoShelleyBasedHardFork ::
391390
( KESAgentContext (ProtoCrypto proto2) m
392391
, ShelleyBasedHardForkConstraints proto1 era1 proto2 era2
393392
) =>
393+
( ProtocolParamsShelleyBased (ProtoCrypto proto1) ->
394+
L.TransitionConfig era1 ->
395+
SL.ProtVer ->
396+
( ProtocolInfo (ShelleyBlock proto1 era1)
397+
, Tracer.Tracer m KESAgentClientTrace -> m [MkBlockForging m (ShelleyBlock proto1 era1)]
398+
)
399+
) ->
400+
( ProtocolParamsShelleyBased (ProtoCrypto proto2) ->
401+
L.TransitionConfig era2 ->
402+
SL.ProtVer ->
403+
( ProtocolInfo (ShelleyBlock proto2 era2)
404+
, Tracer.Tracer m KESAgentClientTrace -> m [MkBlockForging m (ShelleyBlock proto2 era2)]
405+
)
406+
) ->
394407
ProtocolParamsShelleyBased (ProtoCrypto proto1) ->
408+
(ConsensusConfig proto1 -> PartialConsensusConfig proto1) ->
409+
(ConsensusConfig proto2 -> PartialConsensusConfig proto2) ->
395410
SL.ProtVer ->
396411
SL.ProtVer ->
397412
L.TransitionConfig era2 ->
@@ -401,7 +416,11 @@ protocolInfoShelleyBasedHardFork ::
401416
m [MkBlockForging m (ShelleyBasedHardForkBlock proto1 era1 proto2 era2)]
402417
)
403418
protocolInfoShelleyBasedHardFork
419+
protocolInfoProtoShelleyBased1 -- TODO(geo2a): come up with a better name for this argument
420+
protocolInfoProtoShelleyBased2
404421
protocolParamsShelleyBased
422+
toPartialConsensusConfig1
423+
toPartialConsensusConfig2
405424
protVer1
406425
protVer2
407426
transCfg2
@@ -411,20 +430,15 @@ protocolInfoShelleyBasedHardFork
411430
protocolInfo1
412431
blockForging1
413432
eraParams1
414-
tpraosParams
433+
toPartialConsensusConfig1
415434
toPartialLedgerConfig1
416435
-- Era 2
417436
protocolInfo2
418437
blockForging2
419438
eraParams2
420-
tpraosParams
439+
toPartialConsensusConfig2
421440
toPartialLedgerConfig2
422441
where
423-
ProtocolParamsShelleyBased
424-
{ shelleyBasedInitialNonce
425-
, shelleyBasedLeaderCredentials
426-
} = protocolParamsShelleyBased
427-
428442
-- Era 1
429443

430444
genesis :: SL.ShelleyGenesis
@@ -434,7 +448,7 @@ protocolInfoShelleyBasedHardFork
434448
blockForging1 ::
435449
Tracer.Tracer m KESAgentClientTrace -> m [MkBlockForging m (ShelleyBlock proto1 era1)]
436450
(protocolInfo1, blockForging1) =
437-
protocolInfoTPraosShelleyBased
451+
protocolInfoProtoShelleyBased1
438452
protocolParamsShelleyBased
439453
(transCfg2 ^. L.tcPreviousEraConfigL)
440454
protVer1
@@ -457,11 +471,8 @@ protocolInfoShelleyBasedHardFork
457471
blockForging2 ::
458472
Tracer.Tracer m KESAgentClientTrace -> m [MkBlockForging m (ShelleyBlock proto2 era2)]
459473
(protocolInfo2, blockForging2) =
460-
protocolInfoTPraosShelleyBased
461-
ProtocolParamsShelleyBased
462-
{ shelleyBasedInitialNonce
463-
, shelleyBasedLeaderCredentials
464-
}
474+
protocolInfoProtoShelleyBased2
475+
protocolParamsShelleyBased
465476
transCfg2
466477
protVer2
467478

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)