-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Shelley ledger integration in the Ouroboros consensus layer
--   
--   Shelley ledger integration in the Ouroboros consensus layer
@package ouroboros-consensus-shelley
@version 0.1.0.0

module Ouroboros.Consensus.Shelley.Protocol.Crypto
class (Crypto c, DSignable c OCertSignable c, DSignable c Hash c EraIndependentTxBody, KESignable c BHBody c, VRFSignable c Seed) => PraosCrypto c
data StandardCrypto
instance Cardano.Ledger.Crypto.Crypto Ouroboros.Consensus.Shelley.Protocol.Crypto.StandardCrypto
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto Ouroboros.Consensus.Shelley.Protocol.Crypto.StandardCrypto

module Ouroboros.Consensus.Shelley.Eras
data ShelleyEra c

-- | The era after Shelley is Allegra, the illegitimate daughter of Byron.
--   
--   In this era, we introduce time locks and miscellaneous fixes for the
--   Shelley era.
--   
--   TODO #2668 Change this to the proper Allegra era
type AllegraEra c = ShelleyEra c

-- | The era after Allegra is Mary (Shelley), the wife of Percy Shelley.
--   
--   In this era, we introduce multi-asset (hence MA-ry).
--   
--   TODO #2668 Change this to the proper Mary era
type MaryEra c = ShelleyEra c

-- | The Shelley era with standard crypto
type StandardShelley = ShelleyEra StandardCrypto

-- | The Allegra era with standard crypto
type StandardAllegra = AllegraEra StandardCrypto

-- | The Mary era with standard crypto
type StandardMary = MaryEra StandardCrypto
class (PraosCrypto Crypto era, ShelleyBased era, GetLedgerView era, ApplyBlock era, ApplyTx era) => ShelleyBasedEra era

-- | The <a>Crypto</a> type family conflicts with the <a>Crypto</a> class.
--   To avoid having to import one or both of them qualified, define
--   <a>EraCrypto</a> as an alias of the former: /return the crypto used by
--   this era/.
type EraCrypto era = Crypto era
data StandardCrypto

module Ouroboros.Consensus.Shelley.Ledger.Block
class (PraosCrypto Crypto era, ShelleyBased era, GetLedgerView era, ApplyBlock era, ApplyTx era) => ShelleyBasedEra era
newtype ShelleyHash c
ShelleyHash :: HashHeader c -> ShelleyHash c
[unShelleyHash] :: ShelleyHash c -> HashHeader c

-- | Newtype wrapper to avoid orphan instances
--   
--   The phantom type parameter is there to record the additional
--   information we need to work with this block. Most of the code here
--   does not care, but we may need different additional information when
--   running the chain.
data ShelleyBlock era
ShelleyBlock :: !Block era -> !ShelleyHash (EraCrypto era) -> ShelleyBlock era
[shelleyBlockRaw] :: ShelleyBlock era -> !Block era
[shelleyBlockHeaderHash] :: ShelleyBlock era -> !ShelleyHash (EraCrypto era)
mkShelleyBlock :: ShelleyBasedEra era => Block era -> ShelleyBlock era
class HasHeader Header blk => GetHeader blk
getHeader :: GetHeader blk => blk -> Header blk

-- | Check whether the header is the header of the block.
--   
--   For example, by checking whether the hash of the body stored in the
--   header matches that of the block.
blockMatchesHeader :: GetHeader blk => Header blk -> blk -> Bool

-- | When the given header is the header of an Epoch Boundary Block,
--   returns its epoch number.
headerIsEBB :: GetHeader blk => Header blk -> Maybe EpochNo
data family Header blk
mkShelleyHeader :: ShelleyBasedEra era => BHeader (EraCrypto era) -> Header (ShelleyBlock era)

-- | Context identifying what kind of block we have
--   
--   In almost all places we will use <a>NestedCtxt</a> rather than
--   <a>NestedCtxt_</a>.
data family NestedCtxt_ blk :: Type -> Type -> Type -> Type
encodeShelleyBlock :: ShelleyBasedEra era => ShelleyBlock era -> Encoding
decodeShelleyBlock :: ShelleyBasedEra era => Decoder s (ByteString -> ShelleyBlock era)
shelleyBinaryBlockInfo :: ShelleyBasedEra era => ShelleyBlock era -> BinaryBlockInfo
encodeShelleyHeader :: ShelleyBasedEra era => Header (ShelleyBlock era) -> Encoding
decodeShelleyHeader :: ShelleyBasedEra era => Decoder s (ByteString -> Header (ShelleyBlock era))

-- | From <tt>cardano-ledger-specs</tt> to <tt>ouroboros-consensus</tt>
fromShelleyPrevHash :: PrevHash (EraCrypto era) -> ChainHash (ShelleyBlock era)

-- | From <tt>ouroboros-consensus</tt> to <tt>cardano-ledger-specs</tt>
toShelleyPrevHash :: ChainHash (Header (ShelleyBlock era)) -> PrevHash (EraCrypto era)
instance NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyHash c)
instance Cardano.Ledger.Crypto.Crypto c => Cardano.Binary.FromCBOR.FromCBOR (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyHash c)
instance Cardano.Ledger.Crypto.Crypto c => Cardano.Binary.ToCBOR.ToCBOR (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyHash c)
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyHash c)
instance GHC.Show.Show (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyHash c)
instance GHC.Classes.Ord (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyHash c)
instance GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyHash c)
instance GHC.Generics.Generic (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => GHC.Show.Show (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => GHC.Show.Show (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => GHC.Classes.Eq (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => NoThunks.Class.NoThunks (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance GHC.Show.Show (Ouroboros.Consensus.Block.NestedContent.NestedCtxt_ (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) f a)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Block.Abstract.ConvertRawHash (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Data.Typeable.Internal.Typeable era => Ouroboros.Network.Util.ShowProxy.ShowProxy (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Data.Typeable.Internal.Typeable era => Ouroboros.Network.Util.ShowProxy.ShowProxy (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Block.Abstract.GetHeader (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Network.Block.HasHeader (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Network.Block.HasHeader (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Block.Abstract.GetPrevHash (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Data.FingerTree.Measured Ouroboros.Network.Block.BlockMeasure (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Network.Block.StandardHash (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.HeaderValidation.HasAnnTip (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Ouroboros.Consensus.Util.DepPair.TrivialDependency (Ouroboros.Consensus.Block.NestedContent.NestedCtxt_ (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) f)
instance Ouroboros.Consensus.Util.DepPair.SameDepIndex (Ouroboros.Consensus.Block.NestedContent.NestedCtxt_ (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) f)
instance Ouroboros.Consensus.Block.NestedContent.HasNestedContent f (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Cardano.Binary.ToCBOR.ToCBOR (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Cardano.Binary.FromCBOR.FromCBOR (Cardano.Binary.Annotated.Annotator (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Cardano.Binary.ToCBOR.ToCBOR (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Cardano.Binary.FromCBOR.FromCBOR (Cardano.Binary.Annotated.Annotator (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Util.Condense.Condense (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Util.Condense.Condense (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Cardano.Ledger.Crypto.Crypto c => Codec.Serialise.Class.Serialise (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyHash c)
instance Ouroboros.Consensus.Util.Condense.Condense (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyHash c)

module Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion
data ShelleyNodeToNodeVersion
ShelleyNodeToNodeVersion1 :: ShelleyNodeToNodeVersion
data ShelleyNodeToClientVersion
ShelleyNodeToClientVersion1 :: ShelleyNodeToClientVersion

-- | New queries introduced
ShelleyNodeToClientVersion2 :: ShelleyNodeToClientVersion
instance GHC.Enum.Bounded Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion.ShelleyNodeToNodeVersion
instance GHC.Enum.Enum Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion.ShelleyNodeToNodeVersion
instance GHC.Classes.Ord Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion.ShelleyNodeToNodeVersion
instance GHC.Classes.Eq Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion.ShelleyNodeToNodeVersion
instance GHC.Show.Show Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion.ShelleyNodeToNodeVersion
instance GHC.Enum.Bounded Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion.ShelleyNodeToClientVersion
instance GHC.Enum.Enum Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion.ShelleyNodeToClientVersion
instance GHC.Classes.Ord Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion.ShelleyNodeToClientVersion
instance GHC.Classes.Eq Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion.ShelleyNodeToClientVersion
instance GHC.Show.Show Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion.ShelleyNodeToClientVersion
instance Ouroboros.Consensus.Node.NetworkProtocolVersion.HasNetworkProtocolVersion (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Ouroboros.Consensus.Node.NetworkProtocolVersion.SupportedNetworkProtocolVersion (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)

module Ouroboros.Consensus.Shelley.Ledger.Integrity

-- | Verify whether a header is not corrupted
verifyHeaderIntegrity :: ShelleyBasedEra era => Word64 -> Header (ShelleyBlock era) -> Bool

-- | Verifies whether the block is not corrupted by checking its signature
--   and witnesses
verifyBlockIntegrity :: ShelleyBasedEra era => Word64 -> ShelleyBlock era -> Bool

module Ouroboros.Consensus.Shelley.Ledger.Config

-- | Static configuration required to work with this type of blocks
data family BlockConfig blk
mkShelleyBlockConfig :: ShelleyBasedEra era => ProtVer -> ShelleyGenesis era -> [VKey 'BlockIssuer (EraCrypto era)] -> BlockConfig (ShelleyBlock era)

-- | Static configuration required for serialisation and deserialisation of
--   types pertaining to this type of block.
--   
--   Data family instead of type family to get better type inference.
data family CodecConfig blk

-- | Config needed for the <a>NodeInitStorage</a> class. Defined here to
--   avoid circular dependencies.
data family StorageConfig blk

-- | Compact variant of <a>ShelleyGenesis</a> with some fields erased that
--   are only used on start-up and that should not be kept in memory
--   forever.
--   
--   Concretely:
--   
--   <ul>
--   <li>The <tt>sgInitialFunds</tt> field is erased. It is only used to
--   set up the initial UTxO in tests and testnets.</li>
--   <li>The <tt>sgStaking</tt> field is erased. It is only used to
--   register initial stake pools in tests and benchmarks.</li>
--   </ul>
data CompactGenesis era
getCompactGenesis :: CompactGenesis era -> ShelleyGenesis era

-- | Compacts the given <a>ShelleyGenesis</a>.
compactGenesis :: ShelleyGenesis era -> CompactGenesis era
instance GHC.Generics.Generic (Ouroboros.Consensus.Block.Abstract.BlockConfig (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance NoThunks.Class.NoThunks (Ouroboros.Consensus.Block.Abstract.CodecConfig (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance GHC.Generics.Generic (Ouroboros.Consensus.Block.Abstract.CodecConfig (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance NoThunks.Class.NoThunks (Ouroboros.Consensus.Block.Abstract.StorageConfig (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance GHC.Generics.Generic (Ouroboros.Consensus.Block.Abstract.StorageConfig (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Cardano.Ledger.Era.Era era => Cardano.Binary.ToCBOR.ToCBOR (Ouroboros.Consensus.Shelley.Ledger.Config.CompactGenesis era)
instance Cardano.Ledger.Era.Era era => Cardano.Binary.FromCBOR.FromCBOR (Ouroboros.Consensus.Shelley.Ledger.Config.CompactGenesis era)
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Ledger.Config.CompactGenesis era)
instance GHC.Show.Show (Ouroboros.Consensus.Shelley.Ledger.Config.CompactGenesis era)
instance GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Ledger.Config.CompactGenesis era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => GHC.Show.Show (Ouroboros.Consensus.Block.Abstract.BlockConfig (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => NoThunks.Class.NoThunks (Ouroboros.Consensus.Block.Abstract.BlockConfig (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Ledger.Config.CompactGenesis era)


-- | Hot key
--   
--   Intended for qualified import
module Ouroboros.Consensus.Shelley.Protocol.HotKey

-- | We call the relative periods that a KES key is valid its evolution, to
--   avoid confusion with absolute periods.
type KESEvolution = Period
data KESInfo
KESInfo :: !KESPeriod -> !KESPeriod -> !KESEvolution -> KESInfo
[kesStartPeriod] :: KESInfo -> !KESPeriod

-- | Currently derived from <tt>TPraosParams</tt>: &gt; kesEndPeriod =
--   kesStartPeriod + tpraosMaxKESEvo
[kesEndPeriod] :: KESInfo -> !KESPeriod

-- | Current evolution or <i>relative period</i>.
--   
--   Invariant: &gt; kesStartPeriod + kesEvolution in [kesStartPeriod,
--   kesEndPeriod)
[kesEvolution] :: KESInfo -> !KESEvolution

-- | Return the absolute KES period
kesAbsolutePeriod :: KESInfo -> KESPeriod
data KESStatus

-- | The given period is before the start period of the KES key.
BeforeKESStart :: KESPeriod -> KESPeriod -> KESStatus

-- | Relative period or evolution corresponding to the given absolute
--   period
InKESRange :: KESEvolution -> KESStatus

-- | The given period is after the end period of the KES key.
AfterKESEnd :: KESPeriod -> KESPeriod -> KESStatus

-- | Return the evolution of the given KES period, <i>when</i> it falls
--   within the range of the <a>HotKey</a> (<tt>[hkStart, hkEnd)</tt>).
--   
--   Note that the upper bound is exclusive, the spec says: &gt; c0 &lt;=
--   kesPeriod s &lt; c0 + MaxKESEvo
kesStatus :: KESInfo -> KESPeriod -> KESStatus

-- | Failed to evolve the KES key.
data KESEvolutionError

-- | The KES key could not be evolved to the target period.
KESCouldNotEvolve :: KESInfo -> KESPeriod -> KESEvolutionError

-- | Target period outside the range of the current KES key. Typically the
--   current KES period according to the wallclock slot.
KESKeyAlreadyPoisoned :: KESInfo -> KESPeriod -> KESEvolutionError

-- | Result of evolving the KES key.
type KESEvolutionInfo = UpdateInfo KESInfo KESInfo KESEvolutionError

-- | API to interact with the key.
data HotKey c m
HotKey :: (KESPeriod -> m KESEvolutionInfo) -> m KESInfo -> m Bool -> (forall toSign. (KESignable c toSign, HasCallStack) => toSign -> m (SignedKES c toSign)) -> HotKey c m

-- | Evolve the KES signing key to the given absolute KES period.
--   
--   When the key cannot evolve anymore, we poison it.
[evolve] :: HotKey c m -> KESPeriod -> m KESEvolutionInfo

-- | Return <a>KESInfo</a> of the signing key.
[getInfo] :: HotKey c m -> m KESInfo

-- | Return <a>True</a> when the signing key is poisoned because it
--   expired.
[isPoisoned] :: HotKey c m -> m Bool

-- | Sign the given <tt>toSign</tt> with the current signing key.
--   
--   PRECONDITION: the key is not poisoned.
--   
--   POSTCONDITION: the signature is in normal form.
[sign_] :: HotKey c m -> forall toSign. (KESignable c toSign, HasCallStack) => toSign -> m (SignedKES c toSign)
sign :: (KESignable c toSign, HasCallStack) => HotKey c m -> toSign -> m (SignedKES c toSign)
mkHotKey :: forall m c. (Crypto c, IOLike m) => SignKeyKES c -> KESPeriod -> Word64 -> m (HotKey c m)
instance NoThunks.Class.NoThunks Ouroboros.Consensus.Shelley.Protocol.HotKey.KESInfo
instance GHC.Generics.Generic Ouroboros.Consensus.Shelley.Protocol.HotKey.KESInfo
instance GHC.Show.Show Ouroboros.Consensus.Shelley.Protocol.HotKey.KESInfo
instance GHC.Show.Show Ouroboros.Consensus.Shelley.Protocol.HotKey.KESEvolutionError
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Protocol.HotKey.KESKey c)
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Protocol.HotKey.KESState c)
instance Cardano.Ledger.Crypto.Crypto c => NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Protocol.HotKey.KESState c)
instance Cardano.Ledger.Crypto.Crypto c => NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Protocol.HotKey.KESKey c)


-- | Assorted utility functions for Shelley protocol integration.
--   
--   In particular, various things we need for integration with the
--   <tt>delegation</tt> package from cardano-ledger-specs.
module Ouroboros.Consensus.Shelley.Protocol.Util

-- | Verify whether a slot represents a change to a new epoch with regard
--   to some other slot.
--   
--   PRECONDITION: the two slots must be in the same era.
isNewEpoch :: EpochInfo Identity -> WithOrigin SlotNo -> SlotNo -> Bool

-- | Return the first slot in the epoch of the given slot.
firstSlotOfEpochOfSlot :: EpochInfo Identity -> SlotNo -> SlotNo


-- | Transitional Praos.
--   
--   Transitional praos allows for the overlaying of Praos with an overlay
--   schedule determining slots to be produced by BFT
module Ouroboros.Consensus.Shelley.Protocol
data TPraos c

-- | Transitional Praos consensus state.
--   
--   In addition to the <a>ChainDepState</a> provided by the ledger, we
--   track the slot number of the last applied header.
data TPraosState c
TPraosState :: !WithOrigin SlotNo -> !ChainDepState c -> TPraosState c
[tpraosStateLastSlot] :: TPraosState c -> !WithOrigin SlotNo
[tpraosStateChainDepState] :: TPraosState c -> !ChainDepState c

-- | View of the ledger tip for chain selection.
--   
--   We order between chains as follows:
--   
--   <ol>
--   <li>By chain length, with longer chains always preferred.</li>
--   <li>If the tip of each chain has the same slot number, we prefer the
--   one tip that we produced ourselves.</li>
--   <li>If the tip of each chain was issued by the same agent, then we
--   prefer the chain whose tip has the highest ocert issue number.</li>
--   <li>By the leader value of the chain tip, with lower values
--   preferred.</li>
--   </ol>
data TPraosChainSelectView c
TPraosChainSelectView :: BlockNo -> SlotNo -> SelfIssued -> VKey 'BlockIssuer c -> Word64 -> OutputVRF (VRF c) -> TPraosChainSelectView c
[csvChainLength] :: TPraosChainSelectView c -> BlockNo
[csvSlotNo] :: TPraosChainSelectView c -> SlotNo
[csvSelfIssued] :: TPraosChainSelectView c -> SelfIssued
[csvIssuer] :: TPraosChainSelectView c -> VKey 'BlockIssuer c
[csvIssueNo] :: TPraosChainSelectView c -> Word64
[csvLeaderVRF] :: TPraosChainSelectView c -> OutputVRF (VRF c)

-- | Separate type instead of <a>Bool</a> for the custom <a>Ord</a>
--   instance + documentation.
data SelfIssued

-- | A block we produced ourself
SelfIssued :: SelfIssued

-- | A block produced by another node
NotSelfIssued :: SelfIssued
data TPraosFields c toSign
TPraosFields :: SignedKES c toSign -> toSign -> TPraosFields c toSign
[tpraosSignature] :: TPraosFields c toSign -> SignedKES c toSign
[tpraosToSign] :: TPraosFields c toSign -> toSign
forgeTPraosFields :: (PraosCrypto c, KESignable c toSign, Monad m) => HotKey c m -> CanBeLeader (TPraos c) -> IsLeader (TPraos c) -> (TPraosToSign c -> toSign) -> m (TPraosFields c toSign)

-- | Fields arising from transitional praos execution which must be
--   included in the block signature.
data TPraosToSign c
TPraosToSign :: VKey 'BlockIssuer c -> VerKeyVRF c -> CertifiedVRF c Nonce -> CertifiedVRF c Natural -> OCert c -> TPraosToSign c

-- | Verification key for the issuer of this block.
--   
--   Note that unlike in Classic/BFT where we have a key for the genesis
--   delegate on whose behalf we are issuing this block, this key
--   corresponds to the stake pool/core node actually forging the block.
[tpraosToSignIssuerVK] :: TPraosToSign c -> VKey 'BlockIssuer c
[tpraosToSignVrfVK] :: TPraosToSign c -> VerKeyVRF c

-- | Verifiable result containing the updated nonce value.
[tpraosToSignEta] :: TPraosToSign c -> CertifiedVRF c Nonce

-- | Verifiable proof of the leader value, used to determine whether the
--   node has the right to issue a block in this slot.
--   
--   We include a value here even for blocks forged under the BFT schedule.
--   It is not required that such a value be verifiable (though by default
--   it will be verifiably correct, but unused.)
[tpraosToSignLeader] :: TPraosToSign c -> CertifiedVRF c Natural

-- | Lightweight delegation certificate mapping the cold (DSIGN) key to the
--   online KES key.
[tpraosToSignOCert] :: TPraosToSign c -> OCert c

-- | Because we are using the executable spec, rather than implementing the
--   protocol directly here, we have a fixed header type rather than an
--   abstraction. So our validate view is fixed to this.
type TPraosValidateView c = BHeader c

-- | TPraos parameters that are node independent
data TPraosParams
TPraosParams :: !Word64 -> !ActiveSlotCoeff -> !SecurityParam -> !Word64 -> !Word64 -> !MaxMajorProtVer -> !Word64 -> !Network -> !Nonce -> TPraosParams

-- | See <a>slotsPerKESPeriod</a>.
[tpraosSlotsPerKESPeriod] :: TPraosParams -> !Word64

-- | Active slots coefficient. This parameter represents the proportion of
--   slots in which blocks should be issued. This can be interpreted as the
--   probability that a party holding all the stake will be elected as
--   leader for a given slot.
[tpraosLeaderF] :: TPraosParams -> !ActiveSlotCoeff

-- | See <a>securityParameter</a>.
[tpraosSecurityParam] :: TPraosParams -> !SecurityParam

-- | Maximum number of KES iterations, see <a>maxKESEvo</a>.
[tpraosMaxKESEvo] :: TPraosParams -> !Word64

-- | Quorum for update system votes and MIR certificates, see
--   <a>quorum</a>.
[tpraosQuorum] :: TPraosParams -> !Word64

-- | All blocks invalid after this protocol version, see <a>maxMajorPV</a>.
[tpraosMaxMajorPV] :: TPraosParams -> !MaxMajorProtVer

-- | Maximum number of lovelace in the system, see
--   <a>maxLovelaceSupply</a>.
[tpraosMaxLovelaceSupply] :: TPraosParams -> !Word64

-- | Testnet or mainnet?
[tpraosNetworkId] :: TPraosParams -> !Network

-- | Initial nonce used for the TPraos protocol state. Typically this is
--   derived from the hash of the Shelley genesis config JSON file, but
--   different values may be used for testing purposes.
--   
--   NOTE: this is only used when translating the Byron
--   <a>ChainDepState</a> to the Shelley <a>ChainDepState</a>, at which
--   point we'll need access to the initial nonce at runtime. TODO #2326.
[tpraosInitialNonce] :: TPraosParams -> !Nonce
mkTPraosParams :: MaxMajorProtVer -> Nonce -> ShelleyGenesis era -> TPraosParams
data TPraosCanBeLeader c
TPraosCanBeLeader :: !OCert c -> !VKey 'BlockIssuer c -> !SignKeyVRF c -> TPraosCanBeLeader c

-- | Certificate delegating rights from the stake pool cold key (or genesis
--   stakeholder delegate cold key) to the online KES key.
[tpraosCanBeLeaderOpCert] :: TPraosCanBeLeader c -> !OCert c

-- | Stake pool cold key or genesis stakeholder delegate cold key.
[tpraosCanBeLeaderColdVerKey] :: TPraosCanBeLeader c -> !VKey 'BlockIssuer c
[tpraosCanBeLeaderSignKeyVRF] :: TPraosCanBeLeader c -> !SignKeyVRF c

-- | Assembled proof that the issuer has the right to issue a block in the
--   selected slot.
data TPraosIsLeader c
TPraosIsLeader :: CertifiedVRF c Nonce -> CertifiedVRF c Natural -> Maybe (Hash c (VerKeyVRF c)) -> TPraosIsLeader c
[tpraosIsLeaderEta] :: TPraosIsLeader c -> CertifiedVRF c Nonce
[tpraosIsLeaderProof] :: TPraosIsLeader c -> CertifiedVRF c Natural

-- | When in the overlay schedule (otherwise <a>Nothing</a>), return the
--   hash of the VRF verification key in the overlay schedule
[tpraosIsLeaderGenVRFHash] :: TPraosIsLeader c -> Maybe (Hash c (VerKeyVRF c))
mkShelleyGlobals :: EpochInfo Identity -> TPraosParams -> Globals

-- | The maximum major protocol version.
--   
--   Must be at least the current major protocol version. For Cardano
--   mainnet, the Shelley era has major protocol verison <b>2</b>.
newtype MaxMajorProtVer
MaxMajorProtVer :: Natural -> MaxMajorProtVer
[getMaxMajorProtVer] :: MaxMajorProtVer -> Natural
class (Crypto c, DSignable c OCertSignable c, DSignable c Hash c EraIndependentTxBody, KESignable c BHBody c, VRFSignable c Seed) => PraosCrypto c
data StandardCrypto

-- | Expresses that, whilst we believe ourselves to be a leader for this
--   slot, we are nonetheless unable to forge a block.
data TPraosCannotForge c

-- | The KES key in our operational certificate can't be used because the
--   current (wall clock) period is before the start period of the key.
--   current KES period.
--   
--   Note: the opposite case, i.e., the wall clock period being after the
--   end period of the key, is caught when trying to update the key in
--   <a>updateForgeState</a>.
TPraosCannotForgeKeyNotUsableYet :: !KESPeriod -> !KESPeriod -> TPraosCannotForge c

-- | We are a genesis delegate, but our VRF key (second argument) does not
--   match the registered key for that delegate (first argument).
TPraosCannotForgeWrongVRF :: !Hash c (VerKeyVRF c) -> !Hash c (VerKeyVRF c) -> TPraosCannotForge c
tpraosCheckCanForge :: ConsensusConfig (TPraos c) -> Hash c (VerKeyVRF c) -> SlotNo -> IsLeader (TPraos c) -> KESInfo -> Either (TPraosCannotForge c) ()

-- | Static configuration required to run the consensus protocol
--   
--   Every method in the <a>ConsensusProtocol</a> class takes the consensus
--   configuration as a parameter, so having this as a data family rather
--   than a type family resolves most ambiguity.
--   
--   Defined out of the class so that protocols can define this type
--   without having to define the entire protocol at the same time (or
--   indeed in the same module).
data family ConsensusConfig p

-- | " Ticked " piece of state (<tt>LedgerState</tt>, <tt>LedgerView</tt>,
--   <tt>ChainIndepState</tt>)
--   
--   Ticking refers to the passage of time (the ticking of the clock). When
--   a piece of state is marked as ticked, it means that time-related
--   changes have been applied to the state (or forecast).
--   
--   Some examples of time related changes:
--   
--   <ul>
--   <li>Scheduled delegations might have been applied in Byron</li>
--   <li>New leader schedule computed for Shelley</li>
--   <li>Transition from Byron to Shelley activated in the hard fork
--   combinator.</li>
--   <li>Nonces switched out at the start of a new epoch.</li>
--   </ul>
data family Ticked st
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Protocol.TPraosFields c toSign)
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Protocol.TPraosToSign c)
instance NoThunks.Class.NoThunks Ouroboros.Consensus.Shelley.Protocol.MaxMajorProtVer
instance GHC.Generics.Generic Ouroboros.Consensus.Shelley.Protocol.MaxMajorProtVer
instance GHC.Show.Show Ouroboros.Consensus.Shelley.Protocol.MaxMajorProtVer
instance GHC.Classes.Eq Ouroboros.Consensus.Shelley.Protocol.MaxMajorProtVer
instance NoThunks.Class.NoThunks Ouroboros.Consensus.Shelley.Protocol.TPraosParams
instance GHC.Generics.Generic Ouroboros.Consensus.Shelley.Protocol.TPraosParams
instance GHC.Generics.Generic (Ouroboros.Consensus.Protocol.Abstract.ConsensusConfig (Ouroboros.Consensus.Shelley.Protocol.TPraos c))
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Protocol.TPraosCanBeLeader c)
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Protocol.TPraosIsLeader c)
instance GHC.Classes.Eq Ouroboros.Consensus.Shelley.Protocol.SelfIssued
instance GHC.Show.Show Ouroboros.Consensus.Shelley.Protocol.SelfIssued
instance Cardano.Ledger.Crypto.Crypto c => GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Protocol.TPraosChainSelectView c)
instance Cardano.Ledger.Crypto.Crypto c => GHC.Show.Show (Ouroboros.Consensus.Shelley.Protocol.TPraosChainSelectView c)
instance GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Protocol.TPraosState c)
instance GHC.Show.Show (Ouroboros.Consensus.Shelley.Protocol.TPraosState c)
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Protocol.TPraosState c)
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Protocol.TPraosCannotForge c)
instance (NoThunks.Class.NoThunks toSign, Shelley.Spec.Ledger.API.Protocol.PraosCrypto c) => NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Protocol.TPraosFields c toSign)
instance (GHC.Show.Show toSign, Shelley.Spec.Ledger.API.Protocol.PraosCrypto c) => GHC.Show.Show (Ouroboros.Consensus.Shelley.Protocol.TPraosFields c toSign)
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto c => GHC.Show.Show (Ouroboros.Consensus.Shelley.Protocol.TPraosToSign c)
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto c => GHC.Show.Show (Ouroboros.Consensus.Shelley.Protocol.TPraosCannotForge c)
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto c => NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Protocol.TPraosState c)
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto c => Codec.Serialise.Class.Serialise (Ouroboros.Consensus.Shelley.Protocol.TPraosState c)
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto c => Ouroboros.Consensus.Protocol.Abstract.ConsensusProtocol (Ouroboros.Consensus.Shelley.Protocol.TPraos c)
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto c => GHC.Classes.Ord (Ouroboros.Consensus.Shelley.Protocol.TPraosChainSelectView c)
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto c => Ouroboros.Consensus.Protocol.Abstract.ChainSelection (Ouroboros.Consensus.Shelley.Protocol.TPraos c)
instance GHC.Classes.Ord Ouroboros.Consensus.Shelley.Protocol.SelfIssued
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto c => NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Protocol.TPraosIsLeader c)
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto c => NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Protocol.TPraosCanBeLeader c)
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto c => NoThunks.Class.NoThunks (Ouroboros.Consensus.Protocol.Abstract.ConsensusConfig (Ouroboros.Consensus.Shelley.Protocol.TPraos c))
instance Shelley.Spec.Ledger.API.Protocol.PraosCrypto c => NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Protocol.TPraosToSign c)
instance (Ouroboros.Consensus.Util.Condense.Condense toSign, Shelley.Spec.Ledger.API.Protocol.PraosCrypto c) => Ouroboros.Consensus.Util.Condense.Condense (Ouroboros.Consensus.Shelley.Protocol.TPraosFields c toSign)

module Ouroboros.Consensus.Shelley.Ledger.TPraos
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Block.SupportsProtocol.BlockSupportsProtocol (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Protocol.Signed.SignedHeader (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))

module Ouroboros.Consensus.Shelley.Ledger.Ledger
newtype ShelleyLedgerError era
BBodyError :: BlockTransitionError era -> ShelleyLedgerError era
class (PraosCrypto Crypto era, ShelleyBased era, GetLedgerView era, ApplyBlock era, ApplyTx era) => ShelleyBasedEra era
data ShelleyTip era
ShelleyTip :: !SlotNo -> !BlockNo -> !HeaderHash (ShelleyBlock era) -> ShelleyTip era
[shelleyTipSlotNo] :: ShelleyTip era -> !SlotNo
[shelleyTipBlockNo] :: ShelleyTip era -> !BlockNo
[shelleyTipHash] :: ShelleyTip era -> !HeaderHash (ShelleyBlock era)
shelleyTipToPoint :: WithOrigin (ShelleyTip era) -> Point (ShelleyBlock era)
shelleyLedgerTipPoint :: LedgerState (ShelleyBlock era) -> Point (ShelleyBlock era)

-- | Information required to determine the hard fork point from Shelley to
--   the next ledger
newtype ShelleyTransition
ShelleyTransitionInfo :: Word32 -> ShelleyTransition

-- | The number of blocks in this epoch past the voting deadline
--   
--   We record this to make sure that we can tell the HFC about hard forks
--   if and only if we are certain:
--   
--   <ol>
--   <li>Blocks that came in within an epoch after the 4k/f voting deadline
--   are not relevant (10k<i>f - 2 * 3k</i>f).</li>
--   <li>Since there are slots between blocks, we are probably only sure
--   that there will be no more relevant block when we have seen the first
--   block after the deadline.</li>
--   <li>If we count how many blocks we have seen post deadline, and we
--   have reached k of them, we know that that last pre-deadline block
--   won't be rolled back anymore.</li>
--   <li>At this point we can look at the ledger state and see which
--   proposals we accepted in the voting period, if any, and notify the HFC
--   is one of them indicates a transition.</li>
--   </ol>
[shelleyAfterVoting] :: ShelleyTransition -> Word32

-- | Ledger state associated with a block
data family LedgerState blk

-- | " Ticked " piece of state (<tt>LedgerState</tt>, <tt>LedgerView</tt>,
--   <tt>ChainIndepState</tt>)
--   
--   Ticking refers to the passage of time (the ticking of the clock). When
--   a piece of state is marked as ticked, it means that time-related
--   changes have been applied to the state (or forecast).
--   
--   Some examples of time related changes:
--   
--   <ul>
--   <li>Scheduled delegations might have been applied in Byron</li>
--   <li>New leader schedule computed for Shelley</li>
--   <li>Transition from Byron to Shelley activated in the hard fork
--   combinator.</li>
--   <li>Nonces switched out at the start of a new epoch.</li>
--   </ul>
data family Ticked st
data ShelleyLedgerConfig era
ShelleyLedgerConfig :: !CompactGenesis era -> !Globals -> ShelleyLedgerConfig era
[shelleyLedgerCompactGenesis] :: ShelleyLedgerConfig era -> !CompactGenesis era

-- | Derived from <a>shelleyLedgerGenesis</a> but we store a cached version
--   because it used very often.
[shelleyLedgerGlobals] :: ShelleyLedgerConfig era -> !Globals
shelleyLedgerGenesis :: ShelleyLedgerConfig era -> ShelleyGenesis era
mkShelleyLedgerConfig :: ShelleyGenesis era -> EpochInfo Identity -> MaxMajorProtVer -> ShelleyLedgerConfig era
shelleyEraParams :: SafeBeforeEpoch -> ShelleyGenesis era -> EraParams

-- | Separate variant of <a>shelleyEraParams</a> to be used for a
--   Shelley-only chain.
shelleyEraParamsNeverHardForks :: ShelleyGenesis era -> EraParams
getPParams :: NewEpochState era -> PParams era
encodeShelleyAnnTip :: ShelleyBasedEra era => AnnTip (ShelleyBlock era) -> Encoding
decodeShelleyAnnTip :: ShelleyBasedEra era => Decoder s (AnnTip (ShelleyBlock era))
decodeShelleyLedgerState :: forall era s. ShelleyBasedEra era => Decoder s (LedgerState (ShelleyBlock era))
encodeShelleyLedgerState :: ShelleyBasedEra era => LedgerState (ShelleyBlock era) -> Encoding
encodeShelleyHeaderState :: ShelleyBasedEra era => HeaderState (ShelleyBlock era) -> Encoding
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyLedgerError era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyLedgerConfig era)
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyLedgerConfig era)
instance NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyTip era)
instance GHC.Generics.Generic (Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyTip era)
instance GHC.Show.Show (Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyTip era)
instance GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyTip era)
instance NoThunks.Class.NoThunks Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyTransition
instance GHC.Generics.Generic Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyTransition
instance GHC.Show.Show Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyTransition
instance GHC.Classes.Eq Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyTransition
instance NoThunks.Class.NoThunks (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance GHC.Generics.Generic (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance NoThunks.Class.NoThunks (Ouroboros.Consensus.Ticked.Ticked (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)))
instance GHC.Generics.Generic (Ouroboros.Consensus.Ticked.Ticked (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyLedgerError era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => GHC.Show.Show (Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyLedgerError era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => GHC.Show.Show (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => GHC.Classes.Eq (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Ledger.Basics.IsLedger (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Ledger.SupportsProtocol.LedgerSupportsProtocol (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.HeaderValidation.ValidateEnvelope (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => NoThunks.Class.NoThunks (Ouroboros.Consensus.Shelley.Ledger.Ledger.ShelleyLedgerError era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Ledger.Abstract.ApplyBlock (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)) (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Ledger.Abstract.UpdateLedger (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Ouroboros.Consensus.Ledger.Basics.GetTip (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Ouroboros.Consensus.Ledger.Basics.GetTip (Ouroboros.Consensus.Ticked.Ticked (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)))
instance Ouroboros.Consensus.HardFork.Abstract.HasHardForkHistory (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Ledger.CommonProtocolParams.CommonProtocolParams (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.HeaderValidation.BasicEnvelopeValidation (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)

module Ouroboros.Consensus.Shelley.Ledger.Query

-- | Different queries supported by the ledger, indexed by the result type.
data family Query blk :: Type -> Type

-- | Is the given query supported by the given
--   <a>ShelleyNodeToClientVersion</a>?
querySupportedVersion :: Query (ShelleyBlock era) result -> ShelleyNodeToClientVersion -> Bool
newtype NonMyopicMemberRewards era
NonMyopicMemberRewards :: Map (Either Coin (Credential 'Staking era)) (Map (KeyHash 'StakePool (EraCrypto era)) Coin) -> NonMyopicMemberRewards era
[unNonMyopicMemberRewards] :: NonMyopicMemberRewards era -> Map (Either Coin (Credential 'Staking era)) (Map (KeyHash 'StakePool (EraCrypto era)) Coin)
encodeShelleyQuery :: ShelleyBasedEra era => Query (ShelleyBlock era) result -> Encoding
decodeShelleyQuery :: ShelleyBasedEra era => Decoder s (SomeSecond Query (ShelleyBlock era))
encodeShelleyResult :: ShelleyBasedEra era => Query (ShelleyBlock era) result -> result -> Encoding
decodeShelleyResult :: ShelleyBasedEra era => Query (ShelleyBlock era) result -> forall s. Decoder s result
instance GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Ledger.Query.NonMyopicMemberRewards era)
instance GHC.Show.Show (Ouroboros.Consensus.Shelley.Ledger.Query.NonMyopicMemberRewards era)
instance GHC.Classes.Eq (Ouroboros.Consensus.Ledger.Query.Query (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) result)
instance GHC.Show.Show (Ouroboros.Consensus.Ledger.Query.Query (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) result)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Codec.Serialise.Class.Serialise (Ouroboros.Consensus.Shelley.Ledger.Query.NonMyopicMemberRewards era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Ledger.Query.QueryLedger (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Data.Typeable.Internal.Typeable era => Ouroboros.Network.Util.ShowProxy.ShowProxy (Ouroboros.Consensus.Ledger.Query.Query (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Ouroboros.Consensus.Util.DepPair.SameDepIndex (Ouroboros.Consensus.Ledger.Query.Query (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Network.Protocol.LocalStateQuery.Type.ShowQuery (Ouroboros.Consensus.Ledger.Query.Query (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))


-- | Shelley mempool integration
module Ouroboros.Consensus.Shelley.Ledger.Mempool
data ApplyTxError era
ApplyTxError :: [PredicateFailure (LEDGERS era)] -> ApplyTxError era

-- | Generalized transaction
--   
--   The mempool (and, accordingly, blocks) consist of "generalized
--   transactions"; this could be "proper" transactions (transferring
--   funds) but also other kinds of things such as update proposals,
--   delegations, etc.
data family GenTx blk

-- | A generalized transaction, <a>GenTx</a>, identifier.
data family TxId tx
mkShelleyTx :: ShelleyBasedEra era => Tx era -> GenTx (ShelleyBlock era)

-- | <a>txInBlockSize</a> is used to estimate how many transactions we can
--   grab from the Mempool to put into the block we are going to forge
--   without exceeding the maximum block body size according to the ledger.
--   If we exceed that limit, we will have forged a block that is invalid
--   according to the ledger. We ourselves won't even adopt it, causing us
--   to lose our slot, something we must try to avoid.
--   
--   For this reason it is better to overestimate the size of a transaction
--   than to underestimate. The only downside is that we maybe could have
--   put one (or more?) transactions extra in that block.
--   
--   As the sum of the serialised transaction sizes is not equal to the
--   size of the serialised block body (<a>TxSeq</a>) consisting of those
--   transactions (see cardano-node#1545 for an example), we account for
--   some extra overhead per transaction as a safety margin.
--   
--   Also see <a>perTxOverhead</a>.
fixedBlockBodyOverhead :: Num a => a

-- | See <a>fixedBlockBodyOverhead</a>.
perTxOverhead :: Num a => a
instance GHC.Generics.Generic (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance NoThunks.Class.NoThunks (Ouroboros.Consensus.Ledger.SupportsMempool.TxId (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)))
instance Cardano.Ledger.Era.Era era => Cardano.Binary.ToCBOR.ToCBOR (Ouroboros.Consensus.Ledger.SupportsMempool.TxId (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)))
instance Cardano.Ledger.Era.Era era => Cardano.Binary.FromCBOR.FromCBOR (Ouroboros.Consensus.Ledger.SupportsMempool.TxId (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)))
instance GHC.Classes.Ord (Ouroboros.Consensus.Ledger.SupportsMempool.TxId (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)))
instance GHC.Classes.Eq (Ouroboros.Consensus.Ledger.SupportsMempool.TxId (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => NoThunks.Class.NoThunks (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => GHC.Classes.Eq (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Data.Typeable.Internal.Typeable era => Ouroboros.Network.Util.ShowProxy.ShowProxy (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Data.Typeable.Internal.Typeable era => Ouroboros.Network.Util.ShowProxy.ShowProxy (Shelley.Spec.Ledger.API.Mempool.ApplyTxError era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Ledger.SupportsMempool.LedgerSupportsMempool (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Data.Typeable.Internal.Typeable era => Ouroboros.Network.Util.ShowProxy.ShowProxy (Ouroboros.Consensus.Ledger.SupportsMempool.TxId (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Ledger.SupportsMempool.HasTxId (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Ledger.SupportsMempool.HasTxs (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Cardano.Binary.ToCBOR.ToCBOR (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Cardano.Binary.FromCBOR.FromCBOR (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Util.Condense.Condense (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Ouroboros.Consensus.Util.Condense.Condense (Ouroboros.Consensus.Ledger.SupportsMempool.GenTxId (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => GHC.Show.Show (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance GHC.Show.Show (Ouroboros.Consensus.Ledger.SupportsMempool.GenTxId (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))

module Ouroboros.Consensus.Shelley.Ledger.Forge
forgeShelleyBlock :: forall m era. (ShelleyBasedEra era, Monad m) => HotKey (EraCrypto era) m -> TPraosCanBeLeader (EraCrypto era) -> TopLevelConfig (ShelleyBlock era) -> BlockNo -> SlotNo -> TickedLedgerState (ShelleyBlock era) -> [GenTx (ShelleyBlock era)] -> TPraosIsLeader (EraCrypto era) -> m (ShelleyBlock era)

module Ouroboros.Consensus.Shelley.Ledger.Inspect
data ProtocolUpdate era
ProtocolUpdate :: UpdateProposal era -> UpdateState (EraCrypto era) -> ProtocolUpdate era
[protocolUpdateProposal] :: ProtocolUpdate era -> UpdateProposal era
[protocolUpdateState] :: ProtocolUpdate era -> UpdateState (EraCrypto era)

-- | Update proposal
--   
--   As in Byron, a proposal is a partial map from parameters to their
--   values.
data UpdateProposal era
UpdateProposal :: PParamsUpdate era -> Maybe ProtVer -> EpochNo -> UpdateProposal era

-- | The protocol parameters changed by this update proposal
--   
--   An update is <i>identified</i> by how it updates the protocol
--   parameters.
[proposalParams] :: UpdateProposal era -> PParamsUpdate era

-- | New version (if changed by this proposal)
--   
--   The protocol version itself is also considered to be just another
--   parameter, and parameters can change <i>without</i> changing the
--   protocol version, although a convention <i>could</i> be established
--   that the protocol version must change if any of the parameters do; but
--   the specification itself does not mandate this.
--   
--   We record the version separately for the convenience of the HFC.
[proposalVersion] :: UpdateProposal era -> Maybe ProtVer

-- | The <a>EpochNo</a> the proposal becomes active in, if it is adopted
[proposalEpoch] :: UpdateProposal era -> EpochNo

-- | Proposal state
--   
--   The update mechanism in Shelley is simpler than it is in Byron. There
--   is no distinction between votes and proposals: to "vote" for a
--   proposal one merely submits the exact same proposal. There is also no
--   separate endorsement step. The procedure is as follows:
--   
--   <ol>
--   <li>During each epoch, a genesis key can submit (via its delegates)
--   zero, one, or many proposals; each submission overrides the previous
--   one.</li>
--   <li>"Voting" (submitting of proposals) ends <tt>2 *
--   stabilityWindow</tt> slots (i.e. <tt>6k/f</tt>) before the end of the
--   epoch. In other words, proposals for the upcoming epoch must be
--   submitted within the first <tt>4k/f</tt> slots of this one.</li>
--   <li>At the end of an epoch, if the majority of nodes (as determined by
--   the <tt>Quorum</tt> specification constant, which must be greater than
--   half the nodes) have most recently submitted the same exact proposal,
--   then it is adopted.</li>
--   <li>The next epoch is always started with a clean slate, proposals
--   from the previous epoch that didn't make it are discarded (except for
--   "future proposals" that are explicitly marked for future epochs).</li>
--   </ol>
data UpdateState c
UpdateState :: [KeyHash 'Genesis c] -> Bool -> UpdateState c

-- | The genesis delegates that voted for this proposal
[proposalVotes] :: UpdateState c -> [KeyHash 'Genesis c]

-- | Has this proposal reached sufficient votes to be adopted?
[proposalReachedQuorum] :: UpdateState c -> Bool
protocolUpdates :: forall era. ShelleyGenesis era -> LedgerState (ShelleyBlock era) -> [ProtocolUpdate era]
data ShelleyLedgerUpdate era
ShelleyUpdatedProtocolUpdates :: [ProtocolUpdate era] -> ShelleyLedgerUpdate era
instance GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Ledger.Inspect.UpdateProposal era)
instance GHC.Show.Show (Ouroboros.Consensus.Shelley.Ledger.Inspect.UpdateProposal era)
instance GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Ledger.Inspect.UpdateState c)
instance GHC.Show.Show (Ouroboros.Consensus.Shelley.Ledger.Inspect.UpdateState c)
instance GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Ledger.Inspect.ProtocolUpdate era)
instance GHC.Show.Show (Ouroboros.Consensus.Shelley.Ledger.Inspect.ProtocolUpdate era)
instance GHC.Classes.Eq (Ouroboros.Consensus.Shelley.Ledger.Inspect.ShelleyLedgerUpdate era)
instance GHC.Show.Show (Ouroboros.Consensus.Shelley.Ledger.Inspect.ShelleyLedgerUpdate era)
instance Ouroboros.Consensus.Util.Condense.Condense (Ouroboros.Consensus.Shelley.Ledger.Inspect.ShelleyLedgerUpdate era)
instance Ouroboros.Consensus.Ledger.Inspect.InspectLedger (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)

module Ouroboros.Consensus.Shelley.Ledger

module Ouroboros.Consensus.Shelley.Node.Serialisation
instance GHC.Show.Show (Ouroboros.Consensus.Shelley.Node.Serialisation.ShelleyEncoderException era)
instance Data.Typeable.Internal.Typeable era => GHC.Exception.Type.Exception (Ouroboros.Consensus.Shelley.Node.Serialisation.ShelleyEncoderException era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Serialisation.SerialiseNodeToClient (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Util.SomeSecond Ouroboros.Consensus.Ledger.Query.Query (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.HasBinaryBlockInfo (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.ChainDB.Impl.Types.SerialiseDiskConstraints (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.EncodeDisk (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.DecodeDisk (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Data.ByteString.Lazy.Internal.ByteString -> Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.EncodeDisk (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.DecodeDisk (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Data.ByteString.Lazy.Internal.ByteString -> Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.EncodeDisk (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.DecodeDisk (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Ledger.Basics.LedgerState (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance (Shelley.Spec.Ledger.API.ShelleyBasedEra era, Ouroboros.Consensus.Shelley.Eras.EraCrypto era GHC.Types.~ c) => Ouroboros.Consensus.Storage.Serialisation.EncodeDisk (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Shelley.Protocol.TPraosState c)
instance (Shelley.Spec.Ledger.API.ShelleyBasedEra era, Ouroboros.Consensus.Shelley.Eras.EraCrypto era GHC.Types.~ c) => Ouroboros.Consensus.Storage.Serialisation.DecodeDisk (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Shelley.Protocol.TPraosState c)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.EncodeDisk (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.HeaderValidation.AnnTip (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.DecodeDisk (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.HeaderValidation.AnnTip (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Run.SerialiseNodeToNodeConstraints (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Serialisation.SerialiseNodeToNode (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Ouroboros.Consensus.Node.Serialisation.SerialiseNodeToNode (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Network.Block.Serialised (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Serialisation.SerialiseNodeToNode (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Ouroboros.Consensus.Node.Serialisation.SerialiseNodeToNode (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Storage.Serialisation.SerialisedHeader (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Serialisation.SerialiseNodeToNode (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Serialisation.SerialiseNodeToNode (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Ledger.SupportsMempool.GenTxId (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Run.SerialiseNodeToClientConstraints (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Serialisation.SerialiseNodeToClient (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Ouroboros.Consensus.Node.Serialisation.SerialiseNodeToClient (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Network.Block.Serialised (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Serialisation.SerialiseNodeToClient (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Ledger.SupportsMempool.GenTx (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Serialisation.SerialiseNodeToClient (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Shelley.Spec.Ledger.API.Mempool.ApplyTxError era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Serialisation.SerialiseResult (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era) (Ouroboros.Consensus.Ledger.Query.Query (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era))
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.ReconstructNestedCtxt Ouroboros.Consensus.Block.Abstract.Header (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.EncodeDiskDepIx (Ouroboros.Consensus.Block.NestedContent.NestedCtxt Ouroboros.Consensus.Block.Abstract.Header) (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.EncodeDiskDep (Ouroboros.Consensus.Block.NestedContent.NestedCtxt Ouroboros.Consensus.Block.Abstract.Header) (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.DecodeDiskDepIx (Ouroboros.Consensus.Block.NestedContent.NestedCtxt Ouroboros.Consensus.Block.Abstract.Header) (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Storage.Serialisation.DecodeDiskDep (Ouroboros.Consensus.Block.NestedContent.NestedCtxt Ouroboros.Consensus.Block.Abstract.Header) (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)

module Ouroboros.Consensus.Shelley.Node
protocolInfoShelley :: forall m c f. (IOLike m, ShelleyBasedEra (ShelleyEra c), Foldable f) => ProtocolParamsShelley c f -> ProtocolInfo m (ShelleyBlock (ShelleyEra c))

-- | Parameters needed to run Shelley
data ProtocolParamsShelley c f
ProtocolParamsShelley :: ShelleyGenesis (ShelleyEra c) -> Nonce -> ProtVer -> f (TPraosLeaderCredentials c) -> ProtocolParamsShelley c f
[$sel:shelleyGenesis:ProtocolParamsShelley] :: ProtocolParamsShelley c f -> ShelleyGenesis (ShelleyEra c)

-- | The initial nonce, typically derived from the hash of Genesis config
--   JSON file.
--   
--   WARNING: chains using different values of this parameter will be
--   mutually incompatible.
[$sel:shelleyInitialNonce:ProtocolParamsShelley] :: ProtocolParamsShelley c f -> Nonce
[$sel:shelleyProtVer:ProtocolParamsShelley] :: ProtocolParamsShelley c f -> ProtVer
[$sel:shelleyLeaderCredentials:ProtocolParamsShelley] :: ProtocolParamsShelley c f -> f (TPraosLeaderCredentials c)

-- | Parameters needed to run Allegra
data ProtocolParamsAllegra c f
ProtocolParamsAllegra :: ProtVer -> f (TPraosLeaderCredentials c) -> ProtocolParamsAllegra c f
[$sel:allegraProtVer:ProtocolParamsAllegra] :: ProtocolParamsAllegra c f -> ProtVer
[$sel:allegraLeaderCredentials:ProtocolParamsAllegra] :: ProtocolParamsAllegra c f -> f (TPraosLeaderCredentials c)

-- | Parameters needed to run Mary
data ProtocolParamsMary c f
ProtocolParamsMary :: ProtVer -> f (TPraosLeaderCredentials c) -> ProtocolParamsMary c f
[$sel:maryProtVer:ProtocolParamsMary] :: ProtocolParamsMary c f -> ProtVer
[$sel:maryLeaderCredentials:ProtocolParamsMary] :: ProtocolParamsMary c f -> f (TPraosLeaderCredentials c)
protocolClientInfoShelley :: ProtocolClientInfo (ShelleyBlock era)

-- | Shelley genesis information
--   
--   Note that this is needed only for a pure Shelley network, hence it
--   being defined here rather than in its own module. In mainnet, Shelley
--   will transition naturally from Byron, and thus will never have its own
--   genesis information.
data ShelleyGenesis era
ShelleyGenesis :: !UTCTime -> !Word32 -> !Network -> !Rational -> !Word64 -> !EpochSize -> !Word64 -> !Word64 -> !NominalDiffTime -> !Word64 -> !Word64 -> !PParams era -> !Map (KeyHash 'Genesis (Crypto era)) (GenDelegPair (Crypto era)) -> !Map (Addr era) Coin -> !ShelleyGenesisStaking era -> ShelleyGenesis era
[sgSystemStart] :: ShelleyGenesis era -> !UTCTime
[sgNetworkMagic] :: ShelleyGenesis era -> !Word32
[sgNetworkId] :: ShelleyGenesis era -> !Network
[sgActiveSlotsCoeff] :: ShelleyGenesis era -> !Rational
[sgSecurityParam] :: ShelleyGenesis era -> !Word64
[sgEpochLength] :: ShelleyGenesis era -> !EpochSize
[sgSlotsPerKESPeriod] :: ShelleyGenesis era -> !Word64
[sgMaxKESEvolutions] :: ShelleyGenesis era -> !Word64
[sgSlotLength] :: ShelleyGenesis era -> !NominalDiffTime
[sgUpdateQuorum] :: ShelleyGenesis era -> !Word64
[sgMaxLovelaceSupply] :: ShelleyGenesis era -> !Word64
[sgProtocolParams] :: ShelleyGenesis era -> !PParams era
[sgGenDelegs] :: ShelleyGenesis era -> !Map (KeyHash 'Genesis (Crypto era)) (GenDelegPair (Crypto era))
[sgInitialFunds] :: ShelleyGenesis era -> !Map (Addr era) Coin
[sgStaking] :: ShelleyGenesis era -> !ShelleyGenesisStaking era

-- | Genesis Shelley staking configuration.
--   
--   This allows us to configure some initial stake pools and delegation to
--   them, in order to test Praos in a static configuration, without
--   requiring on-chain registration and delegation.
--   
--   For simplicity, pools defined in the genesis staking do not pay
--   deposits for their registration.
data ShelleyGenesisStaking era
ShelleyGenesisStaking :: !Map (KeyHash 'StakePool (Crypto era)) (PoolParams era) -> !Map (KeyHash 'Staking (Crypto era)) (KeyHash 'StakePool (Crypto era)) -> ShelleyGenesisStaking era

-- | Pools to register
--   
--   The key in this map is the hash of the public key of the _pool_. This
--   need not correspond to any payment or staking key, but must correspond
--   to the cold key held by <tt>TPraosIsCoreNode</tt>.
[sgsPools] :: ShelleyGenesisStaking era -> !Map (KeyHash 'StakePool (Crypto era)) (PoolParams era)

-- | Stake-holding key hash credentials and the pools to delegate that
--   stake to. We require the raw staking key hash in order to:
--   
--   <ul>
--   <li>Avoid pointer addresses, which would be tricky when there's no
--   slot or transaction to point to.</li>
--   <li>Avoid script credentials.</li>
--   </ul>
[sgsStake] :: ShelleyGenesisStaking era -> !Map (KeyHash 'Staking (Crypto era)) (KeyHash 'StakePool (Crypto era))
data TPraosLeaderCredentials c
TPraosLeaderCredentials :: SignKeyKES c -> TPraosCanBeLeader c -> Text -> TPraosLeaderCredentials c

-- | The unevolved signing KES key (at evolution 0).
--   
--   Note that this is not inside <a>TPraosCanBeLeader</a> since it gets
--   evolved automatically, whereas <a>TPraosCanBeLeader</a> does not
--   change.
[$sel:tpraosLeaderCredentialsInitSignKey:TPraosLeaderCredentials] :: TPraosLeaderCredentials c -> SignKeyKES c
[$sel:tpraosLeaderCredentialsCanBeLeader:TPraosLeaderCredentials] :: TPraosLeaderCredentials c -> TPraosCanBeLeader c

-- | Identifier for this set of credentials.
--   
--   Useful when the node is running with multiple sets of credentials.
[$sel:tpraosLeaderCredentialsLabel:TPraosLeaderCredentials] :: TPraosLeaderCredentials c -> Text
shelleyBlockForging :: forall m era. (ShelleyBasedEra era, IOLike m) => TPraosParams -> TPraosLeaderCredentials (EraCrypto era) -> m (BlockForging m (ShelleyBlock era))
tpraosBlockIssuerVKey :: TPraosLeaderCredentials c -> VKey 'BlockIssuer c
data ProtVer
ProtVer :: !Natural -> !Natural -> ProtVer
[pvMajor] :: ProtVer -> !Natural
[pvMinor] :: ProtVer -> !Natural

-- | Evolving nonce type.
data Nonce
Nonce :: !Hash Blake2b_256 Nonce -> Nonce

-- | Identity element
NeutralNonce :: Nonce

-- | The maximum major protocol version.
--   
--   Must be at least the current major protocol version. For Cardano
--   mainnet, the Shelley era has major protocol verison <b>2</b>.
newtype MaxMajorProtVer
MaxMajorProtVer :: Natural -> MaxMajorProtVer
[getMaxMajorProtVer] :: MaxMajorProtVer -> Natural

-- | Empty genesis staking
emptyGenesisStaking :: ShelleyGenesisStaking era

-- | Check the validity of the genesis config. To be used in conjunction
--   with <a>assertWithMsg</a>.
validateGenesis :: ShelleyBasedEra era => ShelleyGenesis era -> Either String ()
instance Ouroboros.Consensus.Config.SupportsNode.ConfigSupportsNode (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.InitStorage.NodeInitStorage (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
instance Shelley.Spec.Ledger.API.ShelleyBasedEra era => Ouroboros.Consensus.Node.Run.RunNode (Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock era)
