Skip to content

Commit

Permalink
move BlocksMade to core (BaseTypes)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Corduan committed Oct 11, 2021
1 parent dde7fc5 commit 062ccaa
Show file tree
Hide file tree
Showing 24 changed files with 88 additions and 69 deletions.
4 changes: 2 additions & 2 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs
Expand Up @@ -43,7 +43,7 @@ import Cardano.Ledger.Alonzo.TxInfo (validScript)
import qualified Cardano.Ledger.Alonzo.TxSeq as Alonzo (TxSeq (..), hashTxSeq)
import Cardano.Ledger.Alonzo.TxWitness (TxWitness (..))
import Cardano.Ledger.AuxiliaryData (AuxiliaryDataHash (..), ValidateAuxiliaryData (..))
import qualified Cardano.Ledger.BaseTypes as Shelley
import Cardano.Ledger.BaseTypes (BlocksMade (..))
import Cardano.Ledger.Coin
import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Crypto as CC
Expand Down Expand Up @@ -178,7 +178,7 @@ instance
pp = sgProtocolParams sg

instance (CC.Crypto c) => UsesTxOut (AlonzoEra c) where
makeTxOut _proxy addr val = TxOut addr val Shelley.SNothing
makeTxOut _proxy addr val = TxOut addr val SNothing

instance CC.Crypto c => API.CLI (AlonzoEra c) where
evaluateMinFee = minfee
Expand Down
3 changes: 2 additions & 1 deletion eras/shelley-ma/impl/src/Cardano/Ledger/Allegra.hs
Expand Up @@ -19,11 +19,12 @@ module Cardano.Ledger.Allegra
)
where

import Cardano.Ledger.BaseTypes (BlocksMade (..))
import Cardano.Ledger.Crypto (Crypto)
import qualified Cardano.Ledger.Crypto as CC
import qualified Cardano.Ledger.Era as E (Era (Crypto))
import Cardano.Ledger.Shelley.API hiding (PParams, Tx, TxBody, TxOut, WitnessSet)
import Cardano.Ledger.Shelley.EpochBoundary (BlocksMade (..), emptySnapShots)
import Cardano.Ledger.Shelley.EpochBoundary (emptySnapShots)
import Cardano.Ledger.Shelley.LedgerState (minfee)
import qualified Cardano.Ledger.Shelley.PParams as Shelley (PParamsUpdate)
import Cardano.Ledger.Shelley.Tx (WitnessSet)
Expand Down
3 changes: 2 additions & 1 deletion eras/shelley-ma/impl/src/Cardano/Ledger/Mary.hs
Expand Up @@ -18,12 +18,13 @@ module Cardano.Ledger.Mary
)
where

import Cardano.Ledger.BaseTypes (BlocksMade (..))
import Cardano.Ledger.Crypto (Crypto)
import qualified Cardano.Ledger.Crypto as CC
import qualified Cardano.Ledger.Era as E (Era (Crypto))
import qualified Cardano.Ledger.Mary.Value as V (Value)
import Cardano.Ledger.Shelley.API hiding (TxBody)
import Cardano.Ledger.Shelley.EpochBoundary (BlocksMade (..), emptySnapShots)
import Cardano.Ledger.Shelley.EpochBoundary (emptySnapShots)
import Cardano.Ledger.Shelley.LedgerState (minfee)
import qualified Cardano.Ledger.Shelley.PParams as Shelley (PParamsUpdate)
import Cardano.Ledger.ShelleyMA
Expand Down
4 changes: 2 additions & 2 deletions eras/shelley/impl/src/Cardano/Ledger/Pretty.hs
Expand Up @@ -28,6 +28,7 @@ import Cardano.Ledger.Address
import Cardano.Ledger.AuxiliaryData (AuxiliaryDataHash (..))
import Cardano.Ledger.BaseTypes
( ActiveSlotCoeff,
BlocksMade (..),
BoundedRational (..),
DnsName,
FixedPoint,
Expand Down Expand Up @@ -71,8 +72,7 @@ import Cardano.Ledger.Shelley.Address.Bootstrap (BootstrapWitness (..), ChainCod
import Cardano.Ledger.Shelley.BlockChain (Block (..))
import Cardano.Ledger.Shelley.CompactAddr (CompactAddr (..), decompactAddr)
import Cardano.Ledger.Shelley.EpochBoundary
( BlocksMade (..),
SnapShot (..),
( SnapShot (..),
SnapShots (..),
Stake (..),
)
Expand Down
Expand Up @@ -18,6 +18,7 @@ import qualified Cardano.Chain.Common as Byron
import qualified Cardano.Chain.UTxO as Byron
import qualified Cardano.Crypto.Hash as Crypto
import qualified Cardano.Crypto.Hashing as Hashing
import Cardano.Ledger.BaseTypes (BlocksMade (..))
import Cardano.Ledger.Chain (pparamsToChainChecksPParams)
import Cardano.Ledger.Coin (CompactForm (CompactCoin))
import qualified Cardano.Ledger.Crypto as CC
Expand Down
3 changes: 2 additions & 1 deletion eras/shelley/impl/src/Cardano/Ledger/Shelley/API/Genesis.hs
Expand Up @@ -5,6 +5,7 @@

module Cardano.Ledger.Shelley.API.Genesis where

import Cardano.Ledger.BaseTypes (BlocksMade (..))
import Cardano.Ledger.Core (EraRule)
import Cardano.Ledger.Crypto (Crypto)
import Cardano.Ledger.Shelley (ShelleyEra)
Expand All @@ -25,7 +26,7 @@ import Cardano.Ledger.Shelley.API.Types
genesisUTxO,
word64ToCoin,
)
import Cardano.Ledger.Shelley.EpochBoundary (BlocksMade (..), emptySnapShots)
import Cardano.Ledger.Shelley.EpochBoundary (emptySnapShots)
import Cardano.Ledger.Val (Val ((<->)))
import Control.State.Transition (STS (State))
import Data.Default.Class (Default, def)
Expand Down
11 changes: 9 additions & 2 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/API/Wallet.hs
Expand Up @@ -55,7 +55,14 @@ import Cardano.Crypto.DSIGN.Class (decodeSignedDSIGN, sizeSigDSIGN, sizeVerKeyDS
import qualified Cardano.Crypto.VRF as VRF
import Cardano.Ledger.Address (Addr (..))
import Cardano.Ledger.BHeaderView (isOverlaySlot)
import Cardano.Ledger.BaseTypes (Globals (..), NonNegativeInterval, Seed, UnitInterval, epochInfo)
import Cardano.Ledger.BaseTypes
( BlocksMade,
Globals (..),
NonNegativeInterval,
Seed,
UnitInterval,
epochInfo,
)
import Cardano.Ledger.Coin (Coin (..))
import qualified Cardano.Ledger.Core as Core
import Cardano.Ledger.Credential (Credential (..))
Expand Down Expand Up @@ -489,7 +496,7 @@ getRewardProvenance globals newepochstate =
epochstate = nesEs newepochstate
maxsupply :: Coin
maxsupply = Coin (fromIntegral (maxLovelaceSupply globals))
blocksmade :: EB.BlocksMade (Crypto era)
blocksmade :: BlocksMade (Crypto era)
blocksmade = nesBprev newepochstate
epochnumber = nesEL newepochstate
slotsPerEpoch :: EpochSize
Expand Down
2 changes: 1 addition & 1 deletion eras/shelley/impl/src/Cardano/Ledger/Shelley/BlockChain.hs
Expand Up @@ -72,6 +72,7 @@ import qualified Cardano.Crypto.Hash.Class as Hash
import qualified Cardano.Crypto.VRF as VRF
import Cardano.Ledger.BaseTypes
( ActiveSlotCoeff,
BlocksMade (..),
Nonce (..),
Seed (..),
StrictMaybe (..),
Expand All @@ -93,7 +94,6 @@ import Cardano.Ledger.Serialization
encodeFoldableEncoder,
encodeFoldableMapEncoder,
)
import Cardano.Ledger.Shelley.EpochBoundary (BlocksMade (..))
import Cardano.Ledger.Shelley.Tx (Tx, segwitTx)
import Cardano.Ledger.Slot (SlotNo (..))
import Cardano.Ledger.TxIn (TxIn (..), txid)
Expand Down
25 changes: 7 additions & 18 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/EpochBoundary.hs
Expand Up @@ -19,7 +19,6 @@
-- This modules implements the necessary functions for the changes that can happen at epoch boundaries.
module Cardano.Ledger.Shelley.EpochBoundary
( Stake (..),
BlocksMade (..),
SnapShot (..),
SnapShots (..),
emptySnapShot,
Expand All @@ -29,12 +28,16 @@ module Cardano.Ledger.Shelley.EpochBoundary
obligation,
maxPool,
maxPool',

-- * Deprecated
BlocksMade,
)
where

import Cardano.Binary (FromCBOR (..), ToCBOR (..), encodeListLen)
import Cardano.Ledger.Address (Addr (..))
import Cardano.Ledger.BaseTypes (BoundedRational (..), NonNegativeInterval)
import qualified Cardano.Ledger.BaseTypes as Core (BlocksMade)
import Cardano.Ledger.Coin
( Coin (..),
coinToRational,
Expand All @@ -52,7 +55,6 @@ import Cardano.Ledger.Val ((<+>), (<×>))
import qualified Cardano.Ledger.Val as Val
import Control.DeepSeq (NFData)
import Control.SetAlgebra (dom, eval, setSingleton, (▷), (◁))
import Data.Aeson
import Data.Default.Class (Default, def)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
Expand All @@ -61,22 +63,6 @@ import GHC.Generics (Generic)
import GHC.Records (HasField, getField)
import NoThunks.Class (NoThunks (..))
import Numeric.Natural (Natural)
import Quiet

-- | Blocks made
newtype BlocksMade crypto = BlocksMade
{ unBlocksMade :: Map (KeyHash 'StakePool crypto) Natural
}
deriving (Eq, NoThunks, Generic, NFData)
deriving (Show) via Quiet (BlocksMade crypto)

deriving instance (CC.Crypto crypto) => ToJSON (BlocksMade crypto)

deriving instance (CC.Crypto crypto) => FromJSON (BlocksMade crypto)

deriving instance CC.Crypto crypto => ToCBOR (BlocksMade crypto)

deriving instance CC.Crypto crypto => FromCBOR (BlocksMade crypto)

-- | Type of stake as map from hash key to coins associated.
newtype Stake crypto = Stake
Expand Down Expand Up @@ -252,3 +238,6 @@ emptySnapShot = SnapShot (Stake Map.empty) Map.empty Map.empty

emptySnapShots :: SnapShots crypto
emptySnapShots = SnapShots emptySnapShot emptySnapShot emptySnapShot (Coin 0)

{-# DEPRECATED BlocksMade "Import from Cardano.Ledger.BaseTypes instead" #-}
type BlocksMade = Core.BlocksMade
4 changes: 2 additions & 2 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/LedgerState.hs
Expand Up @@ -103,6 +103,7 @@ import Cardano.Binary
import Cardano.Ledger.Address (Addr (..), bootstrapKeyHash, isBootstrapRedeemer)
import Cardano.Ledger.BaseTypes
( ActiveSlotCoeff,
BlocksMade (..),
BoundedRational (..),
NonNegativeInterval,
ShelleyBase,
Expand Down Expand Up @@ -152,8 +153,7 @@ import Cardano.Ledger.Shelley.Delegation.Certificates
requiresVKeyWitness,
)
import Cardano.Ledger.Shelley.EpochBoundary
( BlocksMade (..),
SnapShot (..),
( SnapShot (..),
SnapShots (..),
Stake (..),
aggregateUtxoCoinByCredential,
Expand Down
Expand Up @@ -19,12 +19,12 @@ import Cardano.Binary
decodeDouble,
encodeDouble,
)
import Cardano.Ledger.BaseTypes (BlocksMade (..))
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Credential (Credential (..))
import qualified Cardano.Ledger.Crypto as CC
import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..))
import Cardano.Ledger.SafeHash (SafeHash, unsafeMakeSafeHash)
import Cardano.Ledger.Shelley.EpochBoundary (BlocksMade (..))
import Cardano.Ledger.Shelley.Orphans ()
import Cardano.Ledger.Shelley.TxBody (PoolParams (..), RewardAcnt (..))
import Control.DeepSeq (NFData)
Expand Down
3 changes: 1 addition & 2 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Bbody.hs
Expand Up @@ -22,7 +22,7 @@ module Cardano.Ledger.Shelley.Rules.Bbody
where

import Cardano.Ledger.BHeaderView (BHeaderView (..), isOverlaySlot)
import Cardano.Ledger.BaseTypes (ShelleyBase, UnitInterval, epochInfo)
import Cardano.Ledger.BaseTypes (BlocksMade, ShelleyBase, UnitInterval, epochInfo)
import qualified Cardano.Ledger.Core as Core
import Cardano.Ledger.Era (Era (Crypto), SupportsSegWit (fromTxSeq, hashTxSeq))
import qualified Cardano.Ledger.Era as Era
Expand All @@ -31,7 +31,6 @@ import Cardano.Ledger.Keys (DSignable, Hash, coerceKeyRole)
import Cardano.Ledger.Serialization (ToCBORGroup)
import Cardano.Ledger.Shelley.BlockChain (Block (..), bBodySize, incrBlocks)
import Cardano.Ledger.Shelley.Constraints (UsesAuxiliary, UsesTxBody)
import Cardano.Ledger.Shelley.EpochBoundary (BlocksMade)
import Cardano.Ledger.Shelley.LedgerState
( AccountState,
LedgerState,
Expand Down
4 changes: 2 additions & 2 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Rupd.hs
Expand Up @@ -23,7 +23,8 @@ module Cardano.Ledger.Shelley.Rules.Rupd
where

import Cardano.Ledger.BaseTypes
( NonNegativeInterval,
( BlocksMade,
NonNegativeInterval,
ShelleyBase,
StrictMaybe (..),
UnitInterval,
Expand All @@ -36,7 +37,6 @@ import Cardano.Ledger.BaseTypes
import Cardano.Ledger.Coin (Coin (..))
import qualified Cardano.Ledger.Core as Core
import Cardano.Ledger.Era (Crypto, Era)
import Cardano.Ledger.Shelley.EpochBoundary (BlocksMade)
import Cardano.Ledger.Shelley.LedgerState
( EpochState,
PulsingRewUpdate (..),
Expand Down
6 changes: 3 additions & 3 deletions eras/shelley/test-suite/bench/BenchValidation.hs
Expand Up @@ -27,7 +27,8 @@ module BenchValidation
)
where

import Cardano.Ledger.BaseTypes (Globals (..))
import Cardano.Ledger.BaseTypes (Globals (..), unBlocksMade)
import Cardano.Ledger.Block (Block (..))
import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Crypto as CryptoClass
import Cardano.Ledger.Era (Era (..))
Expand All @@ -41,9 +42,8 @@ import Cardano.Ledger.Shelley.API.Protocol
updateChainDepState,
)
import Cardano.Ledger.Shelley.Bench.Gen (genBlock, genChainState)
import Cardano.Ledger.Shelley.BlockChain (Block (..), slotToNonce)
import Cardano.Ledger.Shelley.BlockChain (slotToNonce)
import Cardano.Ledger.Shelley.Constraints (TransValue)
import Cardano.Ledger.Shelley.EpochBoundary (unBlocksMade)
import Cardano.Ledger.Shelley.LedgerState
( NewEpochState,
nesBcur,
Expand Down
Expand Up @@ -28,7 +28,8 @@ where

import Cardano.Ledger.BHeaderView (BHeaderView)
import Cardano.Ledger.BaseTypes
( Globals (..),
( BlocksMade (..),
Globals (..),
Nonce (..),
ShelleyBase,
StrictMaybe (..),
Expand Down Expand Up @@ -59,7 +60,7 @@ import Cardano.Ledger.Shelley.API.Wallet
)
import Cardano.Ledger.Shelley.BlockChain (Block (..))
import Cardano.Ledger.Shelley.Constraints (UsesValue)
import Cardano.Ledger.Shelley.EpochBoundary (BlocksMade (..), emptySnapShots)
import Cardano.Ledger.Shelley.EpochBoundary (emptySnapShots)
import Cardano.Ledger.Shelley.LedgerState
( AccountState (..),
DPState (..),
Expand Down
Expand Up @@ -42,6 +42,7 @@ import qualified Cardano.Crypto.Hash as Hash
import Cardano.Ledger.AuxiliaryData (AuxiliaryDataHash (..))
import Cardano.Ledger.BaseTypes
( ActiveSlotCoeff,
BlocksMade (..),
DnsName,
NonNegativeInterval,
PositiveInterval,
Expand Down Expand Up @@ -69,7 +70,6 @@ import Cardano.Ledger.Shelley.Constraints
UsesTxOut,
UsesValue,
)
import Cardano.Ledger.Shelley.EpochBoundary (BlocksMade (..))
import Cardano.Ledger.Shelley.LedgerState (FutureGenDeleg)
import qualified Cardano.Ledger.Shelley.Metadata as MD
import Cardano.Ledger.Shelley.RewardProvenance
Expand Down
Expand Up @@ -46,7 +46,14 @@ module Test.Cardano.Ledger.Shelley.Examples.Combinators
)
where

import Cardano.Ledger.BaseTypes (NonNegativeInterval, Nonce (..), StrictMaybe (..), UnitInterval, (⭒))
import Cardano.Ledger.BaseTypes
( BlocksMade (..),
NonNegativeInterval,
Nonce (..),
StrictMaybe (..),
UnitInterval,
(⭒),
)
import Cardano.Ledger.Coin (Coin (..))
import qualified Cardano.Ledger.Core as Core
import Cardano.Ledger.Credential
Expand All @@ -65,7 +72,7 @@ import Cardano.Ledger.Shelley.BlockChain
bheader,
)
import Cardano.Ledger.Shelley.Constraints (UsesTxBody, UsesTxOut)
import Cardano.Ledger.Shelley.EpochBoundary (BlocksMade (..), SnapShot, SnapShots (..))
import Cardano.Ledger.Shelley.EpochBoundary (SnapShot, SnapShots (..))
import Cardano.Ledger.Shelley.LedgerState
( AccountState (..),
DPState (..),
Expand Down

0 comments on commit 062ccaa

Please sign in to comment.