Skip to content

Commit

Permalink
Remove EpochInterval and co. from BaseTypes
Browse files Browse the repository at this point in the history
Both `EpochInterval` and `addEpochInterval` was moved to `cardano-slotting`
in `cardano-base` as part of IntersectMBO/cardano-base#456.
Import them from there.
  • Loading branch information
Lucsanszky committed Feb 16, 2024
1 parent b475b32 commit 17e4470
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 27 deletions.
3 changes: 1 addition & 2 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/PParams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ module Cardano.Ledger.Shelley.PParams (
where

import Cardano.Ledger.BaseTypes (
EpochInterval (..),
NonNegativeInterval,
Nonce (NeutralNonce),
ProtVer (..),
Expand Down Expand Up @@ -73,7 +72,7 @@ import Cardano.Ledger.HKD (HKD, HKDFunctor (..))
import Cardano.Ledger.Keys (GenDelegs, KeyHash, KeyRole (..))
import Cardano.Ledger.Orphans ()
import Cardano.Ledger.Shelley.Era (ShelleyEra)
import Cardano.Ledger.Slot (EpochNo (..), SlotNo (..))
import Cardano.Ledger.Slot (EpochNo (..), SlotNo (..), EpochInterval(..))
import Control.DeepSeq (NFData)
import Control.Monad (unless)
import Data.Aeson (FromJSON (..), Key, KeyValue, ToJSON (..), object, pairs, (.!=), (.:), (.:?), (.=))
Expand Down
3 changes: 1 addition & 2 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Pool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import Cardano.Ledger.BaseTypes (
Globals (..),
Network,
ShelleyBase,
addEpochInterval,
epochInfoPure,
invalidKey,
networkId,
Expand All @@ -50,7 +49,7 @@ import Cardano.Ledger.Shelley.Era (ShelleyEra, ShelleyPOOL)
import qualified Cardano.Ledger.Shelley.HardForks as HardForks
import Cardano.Ledger.Shelley.LedgerState (PState (..), payPoolDeposit)
import qualified Cardano.Ledger.Shelley.SoftForks as SoftForks
import Cardano.Ledger.Slot (EpochNo (..), SlotNo, epochInfoEpoch)
import Cardano.Ledger.Slot (EpochNo (..), SlotNo, epochInfoEpoch, addEpochInterval)
import Control.DeepSeq
import Control.Monad (forM_, when)
import Control.Monad.Trans.Reader (asks)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import Cardano.Ledger.Binary.Crypto
import Cardano.Ledger.Binary.Decoding.Decoder
import Cardano.Ledger.Binary.Version (Version, byronProtVer)
import Cardano.Slotting.Block (BlockNo (..))
import Cardano.Slotting.Slot (EpochNo (..), EpochSize (..), SlotNo (..), WithOrigin (..))
import Cardano.Slotting.Slot (EpochNo (..), EpochSize (..), SlotNo (..), WithOrigin (..), EpochInterval (..))
import Cardano.Slotting.Time (SystemStart (..))
import Codec.CBOR.ByteArray (ByteArray (..))
import Codec.CBOR.ByteArray.Sliced (SlicedByteArray, fromByteArray)
Expand Down Expand Up @@ -646,6 +646,8 @@ instance DecCBOR BlockNo where
decCBOR = fromPlainDecoder decode
{-# INLINE decCBOR #-}

deriving instance DecCBOR EpochInterval

--------------------------------------------------------------------------------
-- Plutus
--------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ import Cardano.Ledger.Binary.Crypto
import Cardano.Ledger.Binary.Encoding.Encoder
import Cardano.Ledger.Binary.Version (Version, byronProtVer, getVersion64)
import Cardano.Slotting.Block (BlockNo (..))
import Cardano.Slotting.Slot (EpochNo (..), EpochSize (..), SlotNo (..), WithOrigin (..))
import Cardano.Slotting.Slot (EpochNo (..), EpochSize (..), SlotNo (..), WithOrigin (..), EpochInterval (..))
import Cardano.Slotting.Time (SystemStart (..))
import Codec.CBOR.ByteArray (ByteArray (..))
import Codec.CBOR.ByteArray.Sliced (SlicedByteArray (SBA), fromByteArray)
Expand Down Expand Up @@ -1147,6 +1147,8 @@ instance EncCBOR BlockNo where
encCBOR = fromPlainEncoding . Serialise.encode
encodedSizeExpr size = encodedSizeExpr size . fmap unBlockNo

deriving instance EncCBOR EpochInterval

--------------------------------------------------------------------------------
-- Plutus
--------------------------------------------------------------------------------
Expand Down
16 changes: 1 addition & 15 deletions libs/cardano-ledger-core/src/Cardano/Ledger/BaseTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ module Cardano.Ledger.BaseTypes (
activeSlotLog,
module Data.Maybe.Strict,
BlocksMade (..),
EpochInterval (..),
addEpochInterval,
kindObject,

-- * Indices
Expand Down Expand Up @@ -168,7 +166,7 @@ import Data.Text (Text)
import qualified Data.Text as Text
import Data.Text.Encoding (encodeUtf8)
import Data.Typeable (Typeable)
import Data.Word (Word16, Word32, Word64, Word8)
import Data.Word (Word16, Word64, Word8)
import GHC.Exception.Type (Exception)
import GHC.Generics (Generic)
import GHC.Stack (HasCallStack)
Expand Down Expand Up @@ -835,18 +833,6 @@ toAnchorPairs vote@(Anchor _ _) =
instance Default Network where
def = Mainnet

-- | Denotes a positive change in the EpochNo
newtype EpochInterval = EpochInterval
{ unEpochInterval :: Word32
}
deriving (Eq, Ord, Generic)
deriving (Show) via Quiet EpochInterval
deriving newtype (NoThunks, NFData, ToJSON, FromJSON, EncCBOR, DecCBOR, ToCBOR, FromCBOR)

-- | Add a EpochInterval (a positive change) to an EpochNo to get a new EpochNo
addEpochInterval :: EpochNo -> EpochInterval -> EpochNo
addEpochInterval (EpochNo n) (EpochInterval m) = EpochNo (n + fromIntegral m)

class Inject t s where
inject :: t -> s
default inject :: t ~ s => t -> s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ module Cardano.Ledger.Core.PParams (
where

import Cardano.Ledger.BaseTypes (
EpochInterval (..),
NonNegativeInterval,
Nonce (..),
ProtVer,
Expand All @@ -92,6 +91,7 @@ import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Core.Era (Era (..), PreviousEra, ProtVerAtMost)
import Cardano.Ledger.HKD (HKD, HKDFunctor (..), NoUpdate (..))
import Cardano.Ledger.Plutus.ToPlutusData (ToPlutusData (..))
import Cardano.Ledger.Slot (EpochInterval(..))
import Control.DeepSeq (NFData)
import Control.Monad.Identity (Identity)
import Data.Aeson (FromJSON, ToJSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module Cardano.Ledger.Plutus.ToPlutusData where

import Cardano.Ledger.BaseTypes (
BoundedRational (boundRational, unboundRational),
EpochInterval (..),
NonNegativeInterval,
ProtVer (..),
UnitInterval,
Expand All @@ -20,6 +19,7 @@ import Cardano.Ledger.Plutus.CostModels (
mkCostModelsLenient,
)
import Cardano.Ledger.Plutus.ExUnits (ExUnits (..), Prices (..))
import Cardano.Ledger.Slot (EpochInterval(EpochInterval))
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Ratio ((%))
Expand Down
3 changes: 1 addition & 2 deletions libs/cardano-ledger-core/src/Cardano/Ledger/Plutus/TxInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import Cardano.Crypto.Hash.Class (hashToBytes)
import Cardano.Ledger.Address (Addr (..), RewardAccount (..))
import Cardano.Ledger.BaseTypes (
BoundedRational (unboundRational),
EpochInterval (..),
EpochNo (..),
TxIx,
certIxToInt,
Expand All @@ -72,7 +71,7 @@ import Cardano.Ledger.Plutus.ExUnits (ExUnits (..))
import Cardano.Ledger.SafeHash (SafeHash, extractHash)
import Cardano.Ledger.TxIn (TxId (..), TxIn (..), txInToText)
import Cardano.Slotting.EpochInfo (EpochInfo, epochInfoSlotToUTCTime)
import Cardano.Slotting.Slot (SlotNo (..))
import Cardano.Slotting.Slot (SlotNo (..), EpochInterval (..))
import Cardano.Slotting.Time (SystemStart)
import Control.DeepSeq (NFData (..), rwhnf)
import Data.Aeson (ToJSON (..), Value (String))
Expand Down
4 changes: 3 additions & 1 deletion libs/cardano-ledger-core/src/Cardano/Ledger/Slot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module Cardano.Ledger.Slot (
EpochNo (..),
EpochSize (..),
EpochInfo,
EpochInterval (..),
addEpochInterval,
-- Block number
BlockNo (..),
epochInfoEpoch,
Expand All @@ -24,7 +26,7 @@ import Cardano.Ledger.BaseTypes (ShelleyBase)
import Cardano.Slotting.Block (BlockNo (..))
import Cardano.Slotting.EpochInfo (EpochInfo)
import qualified Cardano.Slotting.EpochInfo as EI
import Cardano.Slotting.Slot (EpochNo (..), EpochSize (..), SlotNo (..))
import Cardano.Slotting.Slot (EpochNo (..), EpochSize (..), SlotNo (..), EpochInterval (..), addEpochInterval)
import Control.Monad.Trans (lift)
import Data.Functor.Identity (Identity)
import Data.Word (Word64)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import Cardano.Ledger.BaseTypes (
BlocksMade (..),
CertIx (..),
DnsName,
EpochInterval (..),
Network (..),
NonNegativeInterval,
Nonce (..),
Expand Down Expand Up @@ -125,6 +124,7 @@ import Cardano.Ledger.PoolParams (
StakePoolRelay (..),
)
import Cardano.Ledger.SafeHash (SafeHash, unsafeMakeSafeHash)
import Cardano.Ledger.Slot (EpochInterval (..))
import Cardano.Ledger.TxIn (TxId (..), TxIn (..))
import Cardano.Ledger.UMap (
RDPair (..),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Cardano.Ledger.Plutus.TxInfo
import Cardano.Ledger.PoolDistr
import Cardano.Ledger.PoolParams
import Cardano.Ledger.SafeHash
import Cardano.Ledger.Slot
import Cardano.Ledger.TxIn
import Cardano.Ledger.UMap
import Cardano.Ledger.UTxO
Expand Down

0 comments on commit 17e4470

Please sign in to comment.