Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/reward-calculation/HowRewardCalculationWorks.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ This is a Haskell Datatype (Map (Credential 'Staking) (KeyHash StakePool)), whi
Only registered credentials will receive rewards.

3. Information about which pool operators are currently registered to operate pools, and the parameters under which the pools operate.
This is a Haskell Datatype (Map (KeyHash StakePool) PoolParams), which we will call the `poolParamsMap` . Rewards for UTxO entries delegated
This is a Haskell Datatype (Map (KeyHash StakePool) StakePoolParams), which we will call the `poolParamsMap` . Rewards for UTxO entries delegated
to non registered Pools are distributed to either the Treasury or the Reserves.

4. Information about which pools are currently scheduled to retire, and when.
Expand Down Expand Up @@ -193,7 +193,7 @@ The actual values are stored in internal maps found in the type family `CertStat

Map (Credential 'Staking) (StrictMaybe (KeyHash 'StakePool)) -- The User registration map
Map (Credential 'Staking) Coin -- The User Rewards map
Map (KeyHash 'StakePool) PoolParams -- The StakePool registration map
Map (KeyHash 'StakePool) StakePoolParams -- The StakePool registration map
```

A `Reward` contains information about a computed reward, that has yet to be applied to the internal Rewards map.
Expand Down
4 changes: 2 additions & 2 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/TxInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import Cardano.Ledger.Plutus.Language (
SLanguage (..),
)
import Cardano.Ledger.Plutus.TxInfo
import Cardano.Ledger.PoolParams (PoolParams (..))
import Cardano.Ledger.PoolParams (StakePoolParams (..))
import Cardano.Ledger.Rules.ValidationMode (Inject (..))
import Cardano.Ledger.State (UTxO (..))
import Cardano.Ledger.TxIn (TxIn (..), txInToText)
Expand Down Expand Up @@ -349,7 +349,7 @@ transTxCertCommon = \case
Just $ PV1.DCertDelegDeRegKey (PV1.StakingHash (transCred stakeCred))
DelegStakeTxCert stakeCred keyHash ->
Just $ PV1.DCertDelegDelegate (PV1.StakingHash (transCred stakeCred)) (transKeyHash keyHash)
RegPoolTxCert (PoolParams {ppId, ppVrf}) ->
RegPoolTxCert (StakePoolParams {ppId, ppVrf}) ->
Just $
PV1.DCertPoolRegister
(transKeyHash ppId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Cardano.Ledger.Plutus (
hashPlutusScript,
withSLanguage,
)
import Cardano.Ledger.Shelley.LedgerState (epochStatePoolParamsL, nesEsL)
import Cardano.Ledger.Shelley.LedgerState (epochStateStakePoolParamsL, nesEsL)
import Cardano.Ledger.Shelley.Rules (ShelleyUtxowPredFailure (..))
import qualified Data.Map.Strict as Map
import Data.Maybe (isJust)
Expand Down Expand Up @@ -159,7 +159,7 @@ spec = describe "Invalid transactions" $ do
it "No ExtraRedeemers on same script certificates" $ do
Positive n <- arbitrary
replicateM_ n $ freshKeyHash >>= registerPool
pools <- getsNES $ nesEsL . epochStatePoolParamsL
pools <- getsNES $ nesEsL . epochStateStakePoolParamsL
poolId <- elements $ Map.keys pools
let scriptHash = alwaysSucceedsNoDatumHash
cred = ScriptHashObj scriptHash
Expand Down Expand Up @@ -256,7 +256,7 @@ spec = describe "Invalid transactions" $ do
let scriptHash = alwaysSucceedsWithDatumHash
Positive n <- arbitrary
replicateM_ n $ freshKeyHash >>= registerPool
pools <- getsNES $ nesEsL . epochStatePoolParamsL
pools <- getsNES $ nesEsL . epochStateStakePoolParamsL
poolId <- elements $ Map.keys pools
let cred = ScriptHashObj scriptHash
certs =
Expand Down
8 changes: 4 additions & 4 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ import Cardano.Ledger.Conway.Governance.Proposals
import Cardano.Ledger.Conway.State
import Cardano.Ledger.Core
import Cardano.Ledger.Credential (Credential)
import Cardano.Ledger.PoolParams (PoolParams (ppRewardAccount))
import Cardano.Ledger.PoolParams (StakePoolParams (ppRewardAccount))
import Cardano.Ledger.Shelley.LedgerState (
EpochState (..),
NewEpochState (..),
epochStateGovStateL,
epochStatePoolParamsL,
epochStateStakePoolParamsL,
esLStateL,
lsCertState,
lsUTxOState,
Expand Down Expand Up @@ -513,7 +513,7 @@ setFreshDRepPulsingState epochNo stakePoolDistr epochState = do
, dpProposals = proposalsActions props
, dpProposalDeposits = proposalsDeposits props
, dpGlobals = globals
, dpPoolParams = epochState ^. epochStatePoolParamsL
, dpStakePoolParams = epochState ^. epochStateStakePoolParamsL
}
)
pure $ epochState & epochStateGovStateL .~ govState'
Expand Down Expand Up @@ -561,7 +561,7 @@ defaultStakePoolVote ::
-- | Specify the key hash of the pool whose default vote should be returned.
KeyHash 'StakePool ->
-- | Registered Stake Pools
Map (KeyHash 'StakePool) PoolParams ->
Map (KeyHash 'StakePool) StakePoolParams ->
-- | Delegations of staking credneitals to a DRep
Accounts era ->
DefaultVote
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import Cardano.Ledger.Conway.Governance.Procedures (GovActionState)
import Cardano.Ledger.Conway.State hiding (balance)
import Cardano.Ledger.Core
import Cardano.Ledger.Credential (Credential (..))
import Cardano.Ledger.PoolParams (PoolParams)
import Cardano.Ledger.PoolParams (StakePoolParams)
import Control.DeepSeq (NFData (..), deepseq)
import Control.Monad.Trans.Reader (Reader, runReader)
import Control.State.Transition.Extended
Expand Down Expand Up @@ -283,7 +283,7 @@ data DRepPulser era (m :: Type -> Type) ans where
, dpProposalDeposits :: !(Map (Credential 'Staking) (CompactForm Coin))
-- ^ Snapshot of the proposal-deposits per reward-account-staking-credential
, dpGlobals :: !Globals
, dpPoolParams :: !(Map (KeyHash 'StakePool) PoolParams)
, dpStakePoolParams :: !(Map (KeyHash 'StakePool) StakePoolParams)
-- ^ Snapshot of the parameters of stake pools -
-- this is needed to get the reward account for SPO vote calculation
} ->
Expand Down Expand Up @@ -339,7 +339,7 @@ instance
, noThunks ctxt (dpProposals drp)
, noThunks ctxt (dpProposalDeposits drp)
, noThunks ctxt (dpGlobals drp)
, noThunks ctxt (dpPoolParams drp)
, noThunks ctxt (dpStakePoolParams drp)
]

instance
Expand Down Expand Up @@ -411,7 +411,7 @@ finishDRepPulser (DRPulsing (DRepPulser {..})) =
, reCurrentEpoch = dpCurrentEpoch
, reCommitteeState = dpCommitteeState
, reAccounts = dpAccounts
, rePoolParams = dpPoolParams
, reStakePoolParams = dpStakePoolParams
}
!ratifySig = RatifySignal dpProposals
!ratifyState =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ import Cardano.Ledger.Conway.PParams (
import Cardano.Ledger.Conway.State
import Cardano.Ledger.Core
import Cardano.Ledger.Credential (Credential (..))
import Cardano.Ledger.PoolParams (PoolParams)
import Cardano.Ledger.PoolParams (StakePoolParams)
import Cardano.Ledger.Shelley.LedgerState (epochStateStakeDistrL)
import Control.DeepSeq (NFData (rnf), deepseq)
import Data.Aeson (ToJSON (..), (.=))
Expand Down Expand Up @@ -568,7 +568,7 @@ data RatifyEnv era = RatifyEnv
, reCurrentEpoch :: EpochNo
, reCommitteeState :: CommitteeState era
, reAccounts :: Accounts era
, rePoolParams :: Map (KeyHash 'StakePool) PoolParams
, reStakePoolParams :: Map (KeyHash 'StakePool) StakePoolParams
}
deriving (Generic)

Expand Down Expand Up @@ -652,7 +652,7 @@ instance
!> To reCurrentEpoch
!> To reCommitteeState
!> To reAccounts
!> To rePoolParams
!> To reStakePoolParams

instance
(Era era, DecCBOR (InstantStake era), DecCBOR (Accounts era)) =>
Expand Down
2 changes: 1 addition & 1 deletion eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Cert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ certTransition = do
TRC (CertEnv pp currentEpoch committee committeeProposals, certState, c) <- judgmentContext
let
certPState = certState ^. certPStateL
pools = psStakePoolParams certPState
pools = psStakeStakePoolParams certPState
case c of
ConwayTxCertDeleg delegCert -> do
trans @(EraRule "DELEG" era) $ TRC (ConwayDelegEnv pp pools, certState, delegCert)
Expand Down
4 changes: 2 additions & 2 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Deleg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import Cardano.Ledger.Conway.TxCert (
Delegatee (DelegStake, DelegStakeVote, DelegVote),
)
import Cardano.Ledger.Credential (Credential)
import Cardano.Ledger.PoolParams (PoolParams)
import Cardano.Ledger.PoolParams (StakePoolParams)
import Control.DeepSeq (NFData)
import Control.Monad (forM_, guard, unless)
import Control.State.Transition (
Expand Down Expand Up @@ -83,7 +83,7 @@ import NoThunks.Class (NoThunks)

data ConwayDelegEnv era = ConwayDelegEnv
{ cdePParams :: PParams era
, cdePools :: Map (KeyHash 'StakePool) PoolParams
, cdePools :: Map (KeyHash 'StakePool) StakePoolParams
}
deriving (Generic)

Expand Down
6 changes: 3 additions & 3 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Epoch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ epochTransition = do
trans @(EraRule "SNAP" era) $ TRC (SnapEnv ledgerState0 curPParams, snapshots0, ())

-- Activate future StakePools
let newStakePoolParams = eval (psStakePoolParams pState0 ⨃ psFutureStakePoolParams pState0)
let newStakeStakePoolParams = eval (psStakeStakePoolParams pState0 ⨃ psFutureStakeStakePoolParams pState0)
pState1 =
pState0
{ psStakePoolParams = newStakePoolParams
, psFutureStakePoolParams = Map.empty
{ psStakeStakePoolParams = newStakeStakePoolParams
, psFutureStakeStakePoolParams = Map.empty
}
PoolreapState utxoState1 chainAccountState1 certState1 <-
trans @(EraRule "POOLREAP" era) $
Expand Down
2 changes: 1 addition & 1 deletion eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Gov.hs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ govTransition = do
certDState = certState ^. certDStateL
committeeState = vsCommitteeState certVState
knownDReps = vsDReps certVState
knownStakePools = psStakePoolParams certPState
knownStakePools = psStakeStakePoolParams certPState
knownCommitteeMembers = authorizedHotCommitteeCredentials committeeState

expectedNetworkId <- liftSTS $ asks networkId
Expand Down
4 changes: 2 additions & 2 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Ratify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ spoAcceptedRatio
RatifyEnv
{ reStakePoolDistr = PoolDistr individualPoolStake (CompactCoin totalActiveStake)
, reAccounts
, rePoolParams
, reStakePoolParams
}
GovActionState
{ gasStakePoolVotes
Expand All @@ -213,7 +213,7 @@ spoAcceptedRatio
Nothing
| HardForkInitiation {} <- pProcGovAction -> (yes, abstain)
| hardforkConwayBootstrapPhase pv -> (yes, abstain + stake)
| otherwise -> case defaultStakePoolVote poolId rePoolParams reAccounts of
| otherwise -> case defaultStakePoolVote poolId reStakePoolParams reAccounts of
DefaultNoConfidence
| NoConfidence {} <- pProcGovAction -> (yes + stake, abstain)
DefaultAbstain -> (yes, abstain + stake)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ conwayObligationCertState certState =
conwayCertsTotalDepositsTxBody ::
EraTxBody era => PParams era -> ConwayCertState era -> TxBody era -> Coin
conwayCertsTotalDepositsTxBody pp ConwayCertState {conwayCertPState} =
getTotalDepositsTxBody pp (`Map.member` psStakePoolParams conwayCertPState)
getTotalDepositsTxBody pp (`Map.member` psStakeStakePoolParams conwayCertPState)

conwayCertsTotalRefundsTxBody ::
(EraTxBody era, EraAccounts era) => PParams era -> ConwayCertState era -> TxBody era -> Coin
Expand Down
2 changes: 1 addition & 1 deletion eras/conway/impl/src/Cardano/Ledger/Conway/Transition.hs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ conwayRegisterInitialAccounts ShelleyGenesisStaking {sgsStake} nes =
& nesEsL . esLStateL . lsCertStateL . certDStateL . accountsL %~ \initAccounts ->
foldr registerAndDelegate initAccounts $ ListMap.toList sgsStake
where
stakePools = nes ^. nesEsL . esLStateL . lsCertStateL . certPStateL . psStakePoolParamsL
stakePools = nes ^. nesEsL . esLStateL . lsCertStateL . certPStateL . psStakeStakePoolParamsL
deposit = compactCoinOrError $ nes ^. nesEsL . curPParamsEpochStateL . ppKeyDepositL
registerAndDelegate (stakeKeyHash, stakePool) !accounts
| stakePool `Map.member` stakePools =
Expand Down
2 changes: 1 addition & 1 deletion eras/conway/impl/src/Cardano/Ledger/Conway/TxInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ transTxBodyWithdrawals txBody =
transTxCert ::
(ConwayEraTxCert era, TxCert era ~ ConwayTxCert era) => ProtVer -> TxCert era -> PV3.TxCert
transTxCert pv = \case
RegPoolTxCert PoolParams {ppId, ppVrf} ->
RegPoolTxCert StakePoolParams {ppId, ppVrf} ->
PV3.TxCertPoolRegister
(transKeyHash ppId)
(PV3.PubKeyHash (PV3.toBuiltin (hashToBytes (unVRFVerKeyHash ppVrf))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ import Test.Cardano.Ledger.Mary.Examples (exampleMultiAssetValue)
import Test.Cardano.Ledger.Shelley.Examples (
LedgerExamples (..),
examplePayKey,
examplePoolParams,
exampleStakeKey,
exampleStakePoolParams,
keyToCredential,
mkKeyHash,
)
Expand Down Expand Up @@ -115,7 +115,7 @@ exampleTxBodyConway =
exampleConwayCerts :: OSet.OSet (ConwayTxCert era)
exampleConwayCerts =
OSet.fromList -- TODO add all possible certificates
[ConwayTxCertPool (RegPool examplePoolParams)]
[ConwayTxCertPool (RegPool exampleStakePoolParams)]

exampleConwayGenesis :: ConwayGenesis
exampleConwayGenesis = expectedConwayGenesis
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ spec = do
expectDelegatedToPool cred poolKh

-- when pool is retired and re-registered in the same transaction, delegations are kept
pps <- freshPoolParams poolKh rewardAccount
pps <- freshStakePoolParams poolKh rewardAccount
poolExpiry >>= \pe ->
submitTx_ $
mkBasicTx mkBasicTxBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ spec = do
cred3 <- KeyHashObj <$> freshKeyHash @'Staking
cred4 <- KeyHashObj <$> freshKeyHash @'Staking
poolId <- freshKeyHash
poolParams <- freshPoolParams poolId (RewardAccount Testnet cred0)
poolParams <- freshStakePoolParams poolId (RewardAccount Testnet cred0)
dRepCred <- KeyHashObj <$> freshKeyHash @'DRepRole
let delegatee = DelegStakeVote poolId (DRepCredential dRepCred)
anchor <- arbitrary
Expand Down
12 changes: 6 additions & 6 deletions eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/ImpTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ import Cardano.Ledger.Conway.TxCert (Delegatee (..))
import Cardano.Ledger.Credential (Credential (..))
import Cardano.Ledger.DRep
import Cardano.Ledger.Plutus.Language (Language (..), SLanguage (..), hashPlutusScript)
import Cardano.Ledger.PoolParams (PoolParams (..), ppRewardAccount)
import Cardano.Ledger.PoolParams (StakePoolParams (..), ppRewardAccount)
import Cardano.Ledger.Shelley.LedgerState (
curPParamsEpochStateL,
epochStateGovStateL,
epochStatePoolParamsL,
epochStateStakePoolParamsL,
esLStateL,
lsCertStateL,
lsUTxOStateL,
Expand Down Expand Up @@ -977,7 +977,7 @@ getRatifyEnv = do
drepState <- getsNES $ nesEsL . esLStateL . lsCertStateL . certVStateL . vsDRepsL
committeeState <- getsNES $ nesEsL . esLStateL . lsCertStateL . certVStateL . vsCommitteeStateL
accounts <- getsNES (nesEsL . esLStateL . lsCertStateL . certDStateL . accountsL)
poolPs <- getsNES $ nesEsL . epochStatePoolParamsL
poolPs <- getsNES $ nesEsL . epochStateStakePoolParamsL
pure
RatifyEnv
{ reStakePoolDistr = poolDistr
Expand All @@ -987,7 +987,7 @@ getRatifyEnv = do
, reCurrentEpoch = eNo - 1
, reCommitteeState = committeeState
, reAccounts = accounts
, rePoolParams = poolPs
, reStakePoolParams = poolPs
}

ccShouldNotBeExpired ::
Expand Down Expand Up @@ -1694,7 +1694,7 @@ showConwayTxBalance pp certState utxo tx =
(lookupDepositDState $ certState ^. certDStateL)
(lookupDepositVState $ certState ^. certVStateL)
txBody
isRegPoolId = (`Map.member` (certState ^. certPStateL . psStakePoolParamsL))
isRegPoolId = (`Map.member` (certState ^. certPStateL . psStakeStakePoolParamsL))
withdrawals = fold . unWithdrawals $ txBody ^. withdrawalsTxBodyL

logConwayTxBalance ::
Expand Down Expand Up @@ -1778,7 +1778,7 @@ delegateSPORewardAddressToDRep_ ::
DRep ->
ImpTestM era ()
delegateSPORewardAddressToDRep_ kh stake drep = do
pp <- getRatifyEnv >>= expectJust . Map.lookup kh . rePoolParams
pp <- getRatifyEnv >>= expectJust . Map.lookup kh . reStakePoolParams
void $
delegateToDRep
(raCredential . ppRewardAccount $ pp)
Expand Down
Loading
Loading