{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

-- | Newtypes around type families so that they can be partially applied
module Ouroboros.Consensus.TypeFamilyWrappers
  ( -- * Block based
    WrapApplyTxErr (..)
  , WrapCannotForge (..)
  , WrapEnvelopeErr (..)
  , WrapForgeStateInfo (..)
  , WrapForgeStateUpdateError (..)
  , WrapGenTxId (..)
  , WrapHeaderHash (..)
  , WrapLedgerConfig (..)
  , WrapLedgerErr (..)
  , WrapLedgerEvent (..)
  , WrapLedgerUpdate (..)
  , WrapLedgerWarning (..)
  , WrapTentativeHeaderState (..)
  , WrapTentativeHeaderView (..)
  , WrapTipInfo (..)
  , WrapTxIn (..)
  , WrapTxMeasurePhase1 (..)
  , WrapTxMeasurePhase2 (..)
  , WrapTxOut (..)
  , WrapValidatedGenTx (..)
  , WrapPerasVote (..)
  , WrapPerasCert (..)
  , WrapPerasError (..)
  , WrapPerasCrypto (..)
  , WrapPerasVotingCommitteeScheme (..)
  , WrapPerasPrivateKey (..)
  , WrapPerasVotingCommittee (..)

    -- * Protocol based
  , WrapCanBeLeader (..)
  , WrapChainDepState (..)
  , WrapChainOrderConfig (..)
  , WrapConsensusConfig (..)
  , WrapIsLeader (..)
  , WrapLedgerView (..)
  , WrapTiebreakerView (..)
  , WrapValidateView (..)
  , WrapValidationErr (..)
  , WrapReasonForSwitch (..)

    -- * Versioning
  , WrapNodeToClientVersion (..)
  , WrapNodeToNodeVersion (..)

    -- * Type family instances
  , Ticked (..)
  ) where

import Cardano.Binary (FromCBOR, ToCBOR)
import Codec.Serialise (Serialise)
import Control.Exception (Exception)
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Committee.Class (VotingCommittee)
import Ouroboros.Consensus.Committee.Crypto (PrivateKey)
import Ouroboros.Consensus.HeaderValidation
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Ledger.Inspect
import Ouroboros.Consensus.Ledger.SupportsMempool
import Ouroboros.Consensus.Node.NetworkProtocolVersion
import Ouroboros.Consensus.Protocol.Abstract

{-------------------------------------------------------------------------------
  Block based
-------------------------------------------------------------------------------}

newtype WrapApplyTxErr blk = WrapApplyTxErr {forall blk. WrapApplyTxErr blk -> ApplyTxErr blk
unwrapApplyTxErr :: ApplyTxErr blk}
newtype WrapCannotForge blk = WrapCannotForge {forall blk. WrapCannotForge blk -> CannotForge blk
unwrapCannotForge :: CannotForge blk}
newtype WrapEnvelopeErr blk = WrapEnvelopeErr {forall blk. WrapEnvelopeErr blk -> OtherHeaderEnvelopeError blk
unwrapEnvelopeErr :: OtherHeaderEnvelopeError blk}
newtype WrapForgeStateInfo blk = WrapForgeStateInfo {forall blk. WrapForgeStateInfo blk -> ForgeStateInfo blk
unwrapForgeStateInfo :: ForgeStateInfo blk}
newtype WrapForgeStateUpdateError blk = WrapForgeStateUpdateError {forall blk.
WrapForgeStateUpdateError blk -> ForgeStateUpdateError blk
unwrapForgeStateUpdateError :: ForgeStateUpdateError blk}
newtype WrapGenTxId blk = WrapGenTxId {forall blk. WrapGenTxId blk -> GenTxId blk
unwrapGenTxId :: GenTxId blk}
newtype WrapHeaderHash blk = WrapHeaderHash {forall blk. WrapHeaderHash blk -> HeaderHash blk
unwrapHeaderHash :: HeaderHash blk}
newtype WrapLedgerConfig blk = WrapLedgerConfig {forall blk. WrapLedgerConfig blk -> LedgerConfig blk
unwrapLedgerConfig :: LedgerConfig blk}
newtype WrapLedgerEvent blk = WrapLedgerEvent {forall blk. WrapLedgerEvent blk -> AuxLedgerEvent blk
unwrapLedgerEvent :: AuxLedgerEvent blk}
newtype WrapLedgerErr blk = WrapLedgerErr {forall blk. WrapLedgerErr blk -> LedgerError blk
unwrapLedgerErr :: LedgerError blk}
newtype WrapLedgerUpdate blk = WrapLedgerUpdate {forall blk. WrapLedgerUpdate blk -> LedgerUpdate blk
unwrapLedgerUpdate :: LedgerUpdate blk}
newtype WrapLedgerWarning blk = WrapLedgerWarning {forall blk. WrapLedgerWarning blk -> LedgerWarning blk
unwrapLedgerWarning :: LedgerWarning blk}
newtype WrapTentativeHeaderState blk = WrapTentativeHeaderState {forall blk.
WrapTentativeHeaderState blk -> TentativeHeaderState blk
unwrapTentativeHeaderState :: TentativeHeaderState blk}
newtype WrapTentativeHeaderView blk = WrapTentativeHeaderView {forall blk. WrapTentativeHeaderView blk -> TentativeHeaderView blk
unwrapTentativeHeaderView :: TentativeHeaderView blk}
newtype WrapTipInfo blk = WrapTipInfo {forall blk. WrapTipInfo blk -> TipInfo blk
unwrapTipInfo :: TipInfo blk}

-- | A data family wrapper for @'Validated' . 'GenTx'@
--
-- 'Validated' is is data family, so this is an outlier in this module full of
-- type family wrappers. However, the standard functor composition operator @f
-- :.: g@ incurs some type classes instances that are inappropriate when the
-- outer type constructor @f@ is a family and hence non-parametric (eg @'Eq' (f
-- :.: g)@ requires @'Data.Functor.Classes.Eq1' f)). The bespoke composition
-- 'WrapValidatedGenTx' therefore serves much the same purpose as the other
-- wrappers in this module.
newtype WrapValidatedGenTx blk = WrapValidatedGenTx {forall blk. WrapValidatedGenTx blk -> Validated (GenTx blk)
unwrapValidatedGenTx :: Validated (GenTx blk)}

newtype WrapTxMeasurePhase1 blk = WrapTxMeasurePhase1 {forall blk. WrapTxMeasurePhase1 blk -> TxMeasurePhase1 blk
unwrapTxMeasurePhase1 :: TxMeasurePhase1 blk}
newtype WrapTxMeasurePhase2 blk = WrapTxMeasurePhase2 {forall blk. WrapTxMeasurePhase2 blk -> TxMeasurePhase2 blk
unwrapTxMeasurePhase2 :: TxMeasurePhase2 blk}

newtype WrapTxIn blk = WrapTxIn {forall blk. WrapTxIn blk -> TxIn blk
unwrapTxIn :: TxIn blk}
newtype WrapTxOut blk = WrapTxOut {forall blk. WrapTxOut blk -> TxOut blk
unwrapTxOut :: TxOut blk}

{-------------------------------------------------------------------------------
  Consensus based
-------------------------------------------------------------------------------}

newtype WrapCanBeLeader blk = WrapCanBeLeader {forall blk. WrapCanBeLeader blk -> CanBeLeader (BlockProtocol blk)
unwrapCanBeLeader :: CanBeLeader (BlockProtocol blk)}
newtype WrapChainDepState blk = WrapChainDepState {forall blk.
WrapChainDepState blk -> ChainDepState (BlockProtocol blk)
unwrapChainDepState :: ChainDepState (BlockProtocol blk)}
newtype WrapChainOrderConfig blk = WrapChainOrderConfig
  {forall blk.
WrapChainOrderConfig blk
-> ChainOrderConfig (TiebreakerView (BlockProtocol blk))
unwrapChainOrderConfig :: ChainOrderConfig (TiebreakerView (BlockProtocol blk))}
newtype WrapConsensusConfig blk = WrapConsensusConfig {forall blk.
WrapConsensusConfig blk -> ConsensusConfig (BlockProtocol blk)
unwrapConsensusConfig :: ConsensusConfig (BlockProtocol blk)}
newtype WrapIsLeader blk = WrapIsLeader {forall blk. WrapIsLeader blk -> IsLeader (BlockProtocol blk)
unwrapIsLeader :: IsLeader (BlockProtocol blk)}
newtype WrapLedgerView blk = WrapLedgerView {forall blk. WrapLedgerView blk -> LedgerView (BlockProtocol blk)
unwrapLedgerView :: LedgerView (BlockProtocol blk)}
newtype WrapTiebreakerView blk = WrapTiebreakerView {forall blk.
WrapTiebreakerView blk -> TiebreakerView (BlockProtocol blk)
unwrapTiebreakerView :: TiebreakerView (BlockProtocol blk)}
newtype WrapValidateView blk = WrapValidateView {forall blk.
WrapValidateView blk -> ValidateView (BlockProtocol blk)
unwrapValidateView :: ValidateView (BlockProtocol blk)}
newtype WrapValidationErr blk = WrapValidationErr {forall blk.
WrapValidationErr blk -> ValidationErr (BlockProtocol blk)
unwrapValidationErr :: ValidationErr (BlockProtocol blk)}

newtype WrapReasonForSwitch blk = WrapReasonForSwitch {forall blk.
WrapReasonForSwitch blk -> ReasonForSwitch (WrapTiebreakerView blk)
unwrapReasonForSwitch :: ReasonForSwitch (WrapTiebreakerView blk)}

{-------------------------------------------------------------------------------
  Peras
-------------------------------------------------------------------------------}

newtype WrapPerasVote blk
  = WrapPerasVote
  { forall blk. WrapPerasVote blk -> PerasVote blk
unwrapPerasVote ::
      PerasVote blk
  }

deriving instance
  Show (PerasVote blk) =>
  Show (WrapPerasVote blk)
deriving instance
  Eq (PerasVote blk) =>
  Eq (WrapPerasVote blk)
deriving instance
  NoThunks (PerasVote blk) =>
  NoThunks (WrapPerasVote blk)
deriving instance
  Generic (WrapPerasVote blk)

newtype WrapPerasCert blk
  = WrapPerasCert
  { forall blk. WrapPerasCert blk -> PerasCert blk
unwrapPerasCert ::
      PerasCert blk
  }

deriving instance
  Show (PerasCert blk) =>
  Show (WrapPerasCert blk)
deriving instance
  Eq (PerasCert blk) =>
  Eq (WrapPerasCert blk)
deriving instance
  NoThunks (PerasCert blk) =>
  NoThunks (WrapPerasCert blk)
deriving instance
  Generic (WrapPerasCert blk)

newtype WrapPerasError blk
  = WrapPerasError
  { forall blk. WrapPerasError blk -> PerasError blk
unwrapPerasError ::
      PerasError blk
  }

deriving instance
  Show (PerasError blk) =>
  Show (WrapPerasError blk)
deriving instance
  Eq (PerasError blk) =>
  Eq (WrapPerasError blk)
deriving instance
  NoThunks (PerasError blk) =>
  NoThunks (WrapPerasError blk)
deriving instance
  Generic (WrapPerasError blk)
deriving instance
  ( Typeable blk
  , Exception (PerasError blk)
  ) =>
  Exception (WrapPerasError blk)

instance
  IsPerasError (PerasError blk) blk =>
  IsPerasError (WrapPerasError blk) blk
  where
  injectVotingCommitteeError :: PerasVotingCommitteeError blk -> WrapPerasError blk
injectVotingCommitteeError = VoidPerasError blk -> WrapPerasError blk
PerasError blk -> WrapPerasError blk
forall blk. PerasError blk -> WrapPerasError blk
WrapPerasError (VoidPerasError blk -> WrapPerasError blk)
-> (VotingCommitteeError
      (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    -> VoidPerasError blk)
-> VotingCommitteeError
     (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> WrapPerasError blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VotingCommitteeError
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> VoidPerasError blk
PerasVotingCommitteeError blk -> VoidPerasError blk
forall err blk.
IsPerasError err blk =>
PerasVotingCommitteeError blk -> err
injectVotingCommitteeError
  injectConversionError :: PerasConversionError -> WrapPerasError blk
injectConversionError = VoidPerasError blk -> WrapPerasError blk
PerasError blk -> WrapPerasError blk
forall blk. PerasError blk -> WrapPerasError blk
WrapPerasError (VoidPerasError blk -> WrapPerasError blk)
-> (PerasConversionError -> VoidPerasError blk)
-> PerasConversionError
-> WrapPerasError blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PerasConversionError -> VoidPerasError blk
forall err blk. IsPerasError err blk => PerasConversionError -> err
injectConversionError
  injectQuorumNotReachedError :: VoteWeight -> WrapPerasError blk
injectQuorumNotReachedError = VoidPerasError blk -> WrapPerasError blk
PerasError blk -> WrapPerasError blk
forall blk. PerasError blk -> WrapPerasError blk
WrapPerasError (VoidPerasError blk -> WrapPerasError blk)
-> (VoteWeight -> VoidPerasError blk)
-> VoteWeight
-> WrapPerasError blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VoteWeight -> VoidPerasError blk
forall err blk. IsPerasError err blk => VoteWeight -> err
injectQuorumNotReachedError

newtype WrapPerasCrypto blk
  = WrapPerasCrypto
  { forall blk. WrapPerasCrypto blk -> PerasCrypto blk
unwrapPerasCrypto ::
      PerasCrypto blk
  }

deriving instance
  Show (PerasCrypto blk) =>
  Show (WrapPerasCrypto blk)
deriving instance
  Eq (PerasCrypto blk) =>
  Eq (WrapPerasCrypto blk)
deriving instance
  NoThunks (PerasCrypto blk) =>
  NoThunks (WrapPerasCrypto blk)
deriving instance
  Generic (WrapPerasCrypto blk)

newtype WrapPerasVotingCommitteeScheme blk
  = WrapPerasVotingCommitteeScheme
  { forall blk.
WrapPerasVotingCommitteeScheme blk
-> PerasVotingCommitteeScheme blk
unwrapPerasVotingCommitteeScheme ::
      PerasVotingCommitteeScheme blk
  }

deriving instance
  Show (PerasVotingCommitteeScheme blk) =>
  Show (WrapPerasVotingCommitteeScheme blk)
deriving instance
  Eq (PerasVotingCommitteeScheme blk) =>
  Eq (WrapPerasVotingCommitteeScheme blk)
deriving instance
  NoThunks (PerasVotingCommitteeScheme blk) =>
  NoThunks (WrapPerasVotingCommitteeScheme blk)
deriving instance
  Generic (WrapPerasVotingCommitteeScheme blk)

newtype WrapPerasPrivateKey blk
  = WrapPerasPrivateKey
  { forall blk. WrapPerasPrivateKey blk -> PrivateKey (PerasCrypto blk)
unwrapPerasPrivateKey ::
      PrivateKey (PerasCrypto blk)
  }

deriving instance
  Show (PrivateKey (PerasCrypto blk)) =>
  Show (WrapPerasPrivateKey blk)
deriving instance
  Eq (PrivateKey (PerasCrypto blk)) =>
  Eq (WrapPerasPrivateKey blk)
deriving instance
  NoThunks (PrivateKey (PerasCrypto blk)) =>
  NoThunks (WrapPerasPrivateKey blk)
deriving instance
  Generic (WrapPerasPrivateKey blk)

newtype WrapPerasVotingCommittee blk
  = WrapPerasVotingCommittee
  { forall blk.
WrapPerasVotingCommittee blk
-> VotingCommittee
     (PerasCrypto blk) (PerasVotingCommitteeScheme blk)
unwrapPerasVotingCommittee ::
      VotingCommittee (PerasCrypto blk) (PerasVotingCommitteeScheme blk)
  }

deriving instance
  Show (VotingCommittee (PerasCrypto blk) (PerasVotingCommitteeScheme blk)) =>
  Show (WrapPerasVotingCommittee blk)
deriving instance
  Eq (VotingCommittee (PerasCrypto blk) (PerasVotingCommitteeScheme blk)) =>
  Eq (WrapPerasVotingCommittee blk)
deriving instance
  NoThunks (VotingCommittee (PerasCrypto blk) (PerasVotingCommitteeScheme blk)) =>
  NoThunks (WrapPerasVotingCommittee blk)
deriving instance
  Generic (WrapPerasVotingCommittee blk)

deriving newtype instance
  ( Typeable blk
  , FromCBOR (VotingCommittee (PerasCrypto blk) (PerasVotingCommitteeScheme blk))
  ) =>
  FromCBOR (WrapPerasVotingCommittee blk)

deriving newtype instance
  ( Typeable blk
  , ToCBOR (VotingCommittee (PerasCrypto blk) (PerasVotingCommitteeScheme blk))
  ) =>
  ToCBOR (WrapPerasVotingCommittee blk)

{-------------------------------------------------------------------------------
  Versioning
-------------------------------------------------------------------------------}

newtype WrapNodeToNodeVersion blk = WrapNodeToNodeVersion {forall blk. WrapNodeToNodeVersion blk -> BlockNodeToNodeVersion blk
unwrapNodeToNodeVersion :: BlockNodeToNodeVersion blk}
newtype WrapNodeToClientVersion blk = WrapNodeToClientVersion {forall blk.
WrapNodeToClientVersion blk -> BlockNodeToClientVersion blk
unwrapNodeToClientVersion :: BlockNodeToClientVersion blk}

{-------------------------------------------------------------------------------
  Instances
-------------------------------------------------------------------------------}

deriving instance Eq (ApplyTxErr blk) => Eq (WrapApplyTxErr blk)
deriving instance Eq (GenTxId blk) => Eq (WrapGenTxId blk)
deriving instance Eq (LedgerError blk) => Eq (WrapLedgerErr blk)
deriving instance Eq (LedgerUpdate blk) => Eq (WrapLedgerUpdate blk)
deriving instance Eq (LedgerWarning blk) => Eq (WrapLedgerWarning blk)
deriving instance Eq (OtherHeaderEnvelopeError blk) => Eq (WrapEnvelopeErr blk)
deriving instance Eq (TentativeHeaderState blk) => Eq (WrapTentativeHeaderState blk)
deriving instance Eq (TentativeHeaderView blk) => Eq (WrapTentativeHeaderView blk)
deriving instance Eq (TipInfo blk) => Eq (WrapTipInfo blk)
deriving instance Eq (Validated (GenTx blk)) => Eq (WrapValidatedGenTx blk)

deriving instance Ord (GenTxId blk) => Ord (WrapGenTxId blk)
deriving instance Ord (TentativeHeaderState blk) => Ord (WrapTentativeHeaderState blk)

deriving instance Show (ApplyTxErr blk) => Show (WrapApplyTxErr blk)
deriving instance Show (CannotForge blk) => Show (WrapCannotForge blk)
deriving instance Show (ForgeStateInfo blk) => Show (WrapForgeStateInfo blk)
deriving instance Show (ForgeStateUpdateError blk) => Show (WrapForgeStateUpdateError blk)
deriving instance Show (GenTxId blk) => Show (WrapGenTxId blk)
deriving instance Show (LedgerError blk) => Show (WrapLedgerErr blk)
deriving instance Show (LedgerUpdate blk) => Show (WrapLedgerUpdate blk)
deriving instance Show (LedgerWarning blk) => Show (WrapLedgerWarning blk)
deriving instance Show (OtherHeaderEnvelopeError blk) => Show (WrapEnvelopeErr blk)
deriving instance Show (TentativeHeaderState blk) => Show (WrapTentativeHeaderState blk)
deriving instance Show (TentativeHeaderView blk) => Show (WrapTentativeHeaderView blk)
deriving instance Show (TipInfo blk) => Show (WrapTipInfo blk)
deriving instance Show (Validated (GenTx blk)) => Show (WrapValidatedGenTx blk)
deriving instance Show (ReasonForSwitch (WrapTiebreakerView blk)) => Show (WrapReasonForSwitch blk)

deriving instance
  NoThunks (GenTxId blk) => NoThunks (WrapGenTxId blk)
deriving instance
  NoThunks (LedgerError blk) => NoThunks (WrapLedgerErr blk)
deriving instance
  NoThunks (OtherHeaderEnvelopeError blk) => NoThunks (WrapEnvelopeErr blk)
deriving instance
  NoThunks (TentativeHeaderState blk) => NoThunks (WrapTentativeHeaderState blk)
deriving instance
  NoThunks (TipInfo blk) => NoThunks (WrapTipInfo blk)
deriving instance
  NoThunks (Validated (GenTx blk)) => NoThunks (WrapValidatedGenTx blk)

deriving instance Show (TxIn blk) => Show (WrapTxIn blk)
deriving instance Eq (TxIn blk) => Eq (WrapTxIn blk)
deriving instance Ord (TxIn blk) => Ord (WrapTxIn blk)
deriving instance NoThunks (TxIn blk) => NoThunks (WrapTxIn blk)

deriving instance Show (TxOut blk) => Show (WrapTxOut blk)
deriving instance Eq (TxOut blk) => Eq (WrapTxOut blk)
deriving instance Ord (TxOut blk) => Ord (WrapTxOut blk)
deriving instance NoThunks (TxOut blk) => NoThunks (WrapTxOut blk)

{-------------------------------------------------------------------------------
  .. consensus based
-------------------------------------------------------------------------------}

deriving instance Eq (ChainDepState (BlockProtocol blk)) => Eq (WrapChainDepState blk)
deriving instance Eq (TiebreakerView (BlockProtocol blk)) => Eq (WrapTiebreakerView blk)
deriving instance Eq (ValidationErr (BlockProtocol blk)) => Eq (WrapValidationErr blk)

deriving instance Ord (TiebreakerView (BlockProtocol blk)) => Ord (WrapTiebreakerView blk)

deriving instance
  ChainOrder (TiebreakerView (BlockProtocol blk)) => ChainOrder (WrapTiebreakerView blk)

deriving instance Show (ChainDepState (BlockProtocol blk)) => Show (WrapChainDepState blk)
deriving instance Show (LedgerView (BlockProtocol blk)) => Show (WrapLedgerView blk)
deriving instance Show (TiebreakerView (BlockProtocol blk)) => Show (WrapTiebreakerView blk)
deriving instance Show (ValidationErr (BlockProtocol blk)) => Show (WrapValidationErr blk)

deriving instance NoThunks (ChainDepState (BlockProtocol blk)) => NoThunks (WrapChainDepState blk)
deriving instance NoThunks (TiebreakerView (BlockProtocol blk)) => NoThunks (WrapTiebreakerView blk)
deriving instance NoThunks (ValidationErr (BlockProtocol blk)) => NoThunks (WrapValidationErr blk)

{-------------------------------------------------------------------------------
  Versioning
-------------------------------------------------------------------------------}

deriving instance Show (BlockNodeToNodeVersion blk) => Show (WrapNodeToNodeVersion blk)
deriving instance Show (BlockNodeToClientVersion blk) => Show (WrapNodeToClientVersion blk)

deriving instance Eq (BlockNodeToNodeVersion blk) => Eq (WrapNodeToNodeVersion blk)
deriving instance Eq (BlockNodeToClientVersion blk) => Eq (WrapNodeToClientVersion blk)

{-------------------------------------------------------------------------------
  Serialise instances

  These are primarily useful in testing.
-------------------------------------------------------------------------------}

deriving instance Serialise (GenTxId blk) => Serialise (WrapGenTxId blk)
deriving instance Serialise (ChainDepState (BlockProtocol blk)) => Serialise (WrapChainDepState blk)
deriving instance Serialise (TipInfo blk) => Serialise (WrapTipInfo blk)

{-------------------------------------------------------------------------------
  Ticking

  These are just forwarding instances
-------------------------------------------------------------------------------}

newtype instance Ticked (WrapChainDepState blk) = WrapTickedChainDepState
  { forall blk.
Ticked (WrapChainDepState blk)
-> Ticked (ChainDepState (BlockProtocol blk))
unwrapTickedChainDepState :: Ticked (ChainDepState (BlockProtocol blk))
  }