Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a pure Mary mode #2754

Merged
merged 1 commit into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import Ouroboros.Consensus.Cardano.ShelleyHFC

type ProtocolByron = HardForkProtocol '[ ByronBlock ]
type ProtocolShelley = HardForkProtocol '[ ShelleyBlock StandardShelley ]
type ProtocolMary = HardForkProtocol '[ ShelleyBlock StandardMary ]
type ProtocolCardano = HardForkProtocol '[ ByronBlock
, ShelleyBlock StandardShelley
, ShelleyBlock StandardAllegra
Expand All @@ -82,17 +83,23 @@ type ProtocolCardano = HardForkProtocol '[ ByronBlock

-- | Consensus protocol to use
data Protocol (m :: Type -> Type) blk p where
-- | Run PBFT against the real Byron ledger
-- | Run PBFT against the Byron ledger
ProtocolByron
:: ProtocolParamsByron
-> Protocol m ByronBlockHFC ProtocolByron

-- | Run TPraos against the real Shelley ledger
-- | Run TPraos against the Shelley ledger
ProtocolShelley
:: ProtocolParamsShelleyBased StandardShelley []
-> ProtocolParamsShelley
-> Protocol m (ShelleyBlockHFC StandardShelley) ProtocolShelley

-- | Run TPraos against the Mary ledger
ProtocolMary
:: ProtocolParamsShelleyBased StandardMary []
-> ProtocolParamsMary
-> Protocol m (ShelleyBlockHFC StandardMary) ProtocolMary

-- | Run the protocols of /the/ Cardano block
ProtocolCardano
:: ProtocolParamsByron
Expand All @@ -114,6 +121,7 @@ data Protocol (m :: Type -> Type) blk p where
verifyProtocol :: Protocol m blk p -> (p :~: BlockProtocol blk)
verifyProtocol ProtocolByron{} = Refl
verifyProtocol ProtocolShelley{} = Refl
verifyProtocol ProtocolMary{} = Refl
verifyProtocol ProtocolCardano{} = Refl

{-------------------------------------------------------------------------------
Expand All @@ -129,6 +137,9 @@ protocolInfo (ProtocolByron params) =
protocolInfo (ProtocolShelley paramsShelleyBased paramsShelley) =
inject $ protocolInfoShelley paramsShelleyBased paramsShelley

protocolInfo (ProtocolMary paramsShelleyBased paramsMary) =
inject $ protocolInfoMary paramsShelleyBased paramsMary

protocolInfo (ProtocolCardano
paramsByron
paramsShelleyBased
Expand All @@ -155,6 +166,7 @@ protocolInfo (ProtocolCardano
runProtocol :: Protocol m blk p -> Dict (RunNode blk)
runProtocol ProtocolByron{} = Dict
runProtocol ProtocolShelley{} = Dict
runProtocol ProtocolMary{} = Dict
runProtocol ProtocolCardano{} = Dict

{-------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
module Ouroboros.Consensus.Shelley.Node (
protocolInfoShelleyBased
, protocolInfoShelley
, protocolInfoMary
, ProtocolParamsShelleyBased (..)
, ProtocolParamsShelley (..)
, ProtocolParamsAllegra (..)
Expand Down Expand Up @@ -248,6 +249,17 @@ protocolInfoShelley protocolParamsShelleyBased
} =
protocolInfoShelleyBased protocolParamsShelleyBased protVer

protocolInfoMary ::
forall m c f. (IOLike m, ShelleyBasedEra (MaryEra c), Foldable f)
=> ProtocolParamsShelleyBased (MaryEra c) f
-> ProtocolParamsMary
-> ProtocolInfo m (ShelleyBlock (MaryEra c))
protocolInfoMary protocolParamsShelleyBased
ProtocolParamsMary {
maryProtVer = protVer
} =
protocolInfoShelleyBased protocolParamsShelleyBased protVer

protocolInfoShelleyBased ::
forall m era f. (IOLike m, ShelleyBasedEra era, Foldable f)
=> ProtocolParamsShelleyBased era f
Expand Down