Skip to content

Commit 02ed285

Browse files
authored
Merge pull request #5196 from IntersectMBO/aniketd/stakepoolstate
Introduce `StakePoolState` to be used instead of `PoolParams`
2 parents e74f56f + fbdc826 commit 02ed285

File tree

94 files changed

+799
-589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+799
-589
lines changed

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/TxInfo.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ import Cardano.Ledger.Plutus.Language (
7575
SLanguage (..),
7676
)
7777
import Cardano.Ledger.Plutus.TxInfo
78-
import Cardano.Ledger.PoolParams (PoolParams (..))
7978
import Cardano.Ledger.Rules.ValidationMode (Inject (..))
80-
import Cardano.Ledger.State (UTxO (..))
79+
import Cardano.Ledger.State (PoolParams (..), UTxO (..))
8180
import Cardano.Ledger.TxIn (TxIn (..), txInToText)
8281
import Cardano.Ledger.Val (zero)
8382
import Cardano.Slotting.EpochInfo (EpochInfo)

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec/Invalid.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import Cardano.Ledger.Plutus (
3131
hashPlutusScript,
3232
withSLanguage,
3333
)
34-
import Cardano.Ledger.Shelley.LedgerState (epochStatePoolParamsL, nesEsL)
34+
import Cardano.Ledger.Shelley.LedgerState (epochStateStakePoolsL, nesEsL)
3535
import Cardano.Ledger.Shelley.Rules (ShelleyUtxowPredFailure (..))
3636
import qualified Data.Map.Strict as Map
3737
import Data.Maybe (isJust)
@@ -159,7 +159,7 @@ spec = describe "Invalid transactions" $ do
159159
it "No ExtraRedeemers on same script certificates" $ do
160160
Positive n <- arbitrary
161161
replicateM_ n $ freshKeyHash >>= registerPool
162-
pools <- getsNES $ nesEsL . epochStatePoolParamsL
162+
pools <- getsNES $ nesEsL . epochStateStakePoolsL
163163
poolId <- elements $ Map.keys pools
164164
let scriptHash = alwaysSucceedsNoDatumHash
165165
cred = ScriptHashObj scriptHash
@@ -256,7 +256,7 @@ spec = describe "Invalid transactions" $ do
256256
let scriptHash = alwaysSucceedsWithDatumHash
257257
Positive n <- arbitrary
258258
replicateM_ n $ freshKeyHash >>= registerPool
259-
pools <- getsNES $ nesEsL . epochStatePoolParamsL
259+
pools <- getsNES $ nesEsL . epochStateStakePoolsL
260260
poolId <- elements $ Map.keys pools
261261
let cred = ScriptHashObj scriptHash
262262
certs =

eras/conway/impl/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## 1.20.0.0
44

5+
* Deprecate `PoolParams` in favor of `StakePoolState`. #5196
6+
* Update `DRepPulser` and `RatifyEnv` to use `StakePoolState` instead of `PoolParams`.
57
* Better predicate failures for incorrect deposits and refunds.
68
* Add `hardforkConwayDELEGIncorrectDepositsAndRefunds` for protocol 11 onwards, to `Conway.Era`.
79
* Add `DepositIncorrectDELEG` and `RefundIncorrectDELEG` to `ConwayDelegPredFailure`.

eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,11 @@ import Cardano.Ledger.Conway.Governance.Proposals
215215
import Cardano.Ledger.Conway.State
216216
import Cardano.Ledger.Core
217217
import Cardano.Ledger.Credential (Credential)
218-
import Cardano.Ledger.PoolParams (PoolParams (ppRewardAccount))
219218
import Cardano.Ledger.Shelley.LedgerState (
220219
EpochState (..),
221220
NewEpochState (..),
222221
epochStateGovStateL,
223-
epochStatePoolParamsL,
222+
epochStateStakePoolsL,
224223
esLStateL,
225224
lsCertState,
226225
lsUTxOState,
@@ -513,7 +512,7 @@ setFreshDRepPulsingState epochNo stakePoolDistr epochState = do
513512
, dpProposals = proposalsActions props
514513
, dpProposalDeposits = proposalsDeposits props
515514
, dpGlobals = globals
516-
, dpPoolParams = epochState ^. epochStatePoolParamsL
515+
, dpStakePools = epochState ^. epochStateStakePoolsL
517516
}
518517
)
519518
pure $ epochState & epochStateGovStateL .~ govState'
@@ -561,14 +560,14 @@ defaultStakePoolVote ::
561560
-- | Specify the key hash of the pool whose default vote should be returned.
562561
KeyHash 'StakePool ->
563562
-- | Registered Stake Pools
564-
Map (KeyHash 'StakePool) PoolParams ->
563+
Map (KeyHash 'StakePool) StakePoolState ->
565564
-- | Delegations of staking credneitals to a DRep
566565
Accounts era ->
567566
DefaultVote
568567
defaultStakePoolVote poolId poolParams accounts =
569568
toDefaultVote $ do
570569
spp <- Map.lookup poolId poolParams
571-
accountState <- Map.lookup (raCredential $ ppRewardAccount spp) (accounts ^. accountsMapL)
570+
accountState <- Map.lookup (raCredential $ spsRewardAccount spp) (accounts ^. accountsMapL)
572571
accountState ^. dRepDelegationAccountStateL
573572
where
574573
toDefaultVote (Just DRepAlwaysAbstain) = DefaultAbstain

eras/conway/impl/src/Cardano/Ledger/Conway/Governance/DRepPulser.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ import Cardano.Ledger.Conway.Governance.Procedures (GovActionState)
7171
import Cardano.Ledger.Conway.State hiding (balance)
7272
import Cardano.Ledger.Core
7373
import Cardano.Ledger.Credential (Credential (..))
74-
import Cardano.Ledger.PoolParams (PoolParams)
7574
import Control.DeepSeq (NFData (..), deepseq)
7675
import Control.Monad.Trans.Reader (Reader, runReader)
7776
import Control.State.Transition.Extended
@@ -283,7 +282,7 @@ data DRepPulser era (m :: Type -> Type) ans where
283282
, dpProposalDeposits :: !(Map (Credential 'Staking) (CompactForm Coin))
284283
-- ^ Snapshot of the proposal-deposits per reward-account-staking-credential
285284
, dpGlobals :: !Globals
286-
, dpPoolParams :: !(Map (KeyHash 'StakePool) PoolParams)
285+
, dpStakePools :: !(Map (KeyHash 'StakePool) StakePoolState)
287286
-- ^ Snapshot of the parameters of stake pools -
288287
-- this is needed to get the reward account for SPO vote calculation
289288
} ->
@@ -339,7 +338,7 @@ instance
339338
, noThunks ctxt (dpProposals drp)
340339
, noThunks ctxt (dpProposalDeposits drp)
341340
, noThunks ctxt (dpGlobals drp)
342-
, noThunks ctxt (dpPoolParams drp)
341+
, noThunks ctxt (dpStakePools drp)
343342
]
344343

345344
instance
@@ -411,7 +410,7 @@ finishDRepPulser (DRPulsing (DRepPulser {..})) =
411410
, reCurrentEpoch = dpCurrentEpoch
412411
, reCommitteeState = dpCommitteeState
413412
, reAccounts = dpAccounts
414-
, rePoolParams = dpPoolParams
413+
, reStakePools = dpStakePools
415414
}
416415
!ratifySig = RatifySignal dpProposals
417416
!ratifyState =

eras/conway/impl/src/Cardano/Ledger/Conway/Governance/Internal.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ import Cardano.Ledger.Conway.PParams (
110110
import Cardano.Ledger.Conway.State
111111
import Cardano.Ledger.Core
112112
import Cardano.Ledger.Credential (Credential (..))
113-
import Cardano.Ledger.PoolParams (PoolParams)
114113
import Cardano.Ledger.Shelley.LedgerState (epochStateStakeDistrL)
115114
import Control.DeepSeq (NFData (rnf), deepseq)
116115
import Data.Aeson (ToJSON (..), (.=))
@@ -568,7 +567,7 @@ data RatifyEnv era = RatifyEnv
568567
, reCurrentEpoch :: EpochNo
569568
, reCommitteeState :: CommitteeState era
570569
, reAccounts :: Accounts era
571-
, rePoolParams :: Map (KeyHash 'StakePool) PoolParams
570+
, reStakePools :: Map (KeyHash 'StakePool) StakePoolState
572571
}
573572
deriving (Generic)
574573

@@ -652,7 +651,7 @@ instance
652651
!> To reCurrentEpoch
653652
!> To reCommitteeState
654653
!> To reAccounts
655-
!> To rePoolParams
654+
!> To reStakePools
656655

657656
instance
658657
(Era era, DecCBOR (InstantStake era), DecCBOR (Accounts era)) =>

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Cert.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ certTransition = do
220220
TRC (CertEnv pp currentEpoch committee committeeProposals, certState, c) <- judgmentContext
221221
let
222222
certPState = certState ^. certPStateL
223-
pools = psStakePoolParams certPState
223+
pools = psStakePools certPState
224224
case c of
225225
ConwayTxCertDeleg delegCert -> do
226226
trans @(EraRule "DELEG" era) $ TRC (ConwayDelegEnv pp pools, certState, delegCert)

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Deleg.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import Cardano.Ledger.Conway.TxCert (
5454
Delegatee (DelegStake, DelegStakeVote, DelegVote),
5555
)
5656
import Cardano.Ledger.Credential (Credential)
57-
import Cardano.Ledger.PoolParams (PoolParams)
5857
import Control.DeepSeq (NFData)
5958
import Control.Monad (forM_, guard, unless)
6059
import Control.State.Transition (
@@ -83,7 +82,7 @@ import NoThunks.Class (NoThunks)
8382

8483
data ConwayDelegEnv era = ConwayDelegEnv
8584
{ cdePParams :: PParams era
86-
, cdePools :: Map (KeyHash 'StakePool) PoolParams
85+
, cdePools :: Map (KeyHash 'StakePool) StakePoolState
8786
}
8887
deriving (Generic)
8988

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Epoch.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,11 @@ epochTransition = do
302302
trans @(EraRule "SNAP" era) $ TRC (SnapEnv ledgerState0 curPParams, snapshots0, ())
303303

304304
-- Activate future StakePools
305-
let newStakePoolParams = eval (psStakePoolParams pState0 psFutureStakePoolParams pState0)
305+
let newStakePools = eval (psStakePools pState0 psFutureStakePools pState0)
306306
pState1 =
307307
pState0
308-
{ psStakePoolParams = newStakePoolParams
309-
, psFutureStakePoolParams = Map.empty
308+
{ psStakePools = newStakePools
309+
, psFutureStakePools = Map.empty
310310
}
311311
PoolreapState utxoState1 chainAccountState1 certState1 <-
312312
trans @(EraRule "POOLREAP" era) $

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Gov.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ govTransition = do
458458
certDState = certState ^. certDStateL
459459
committeeState = vsCommitteeState certVState
460460
knownDReps = vsDReps certVState
461-
knownStakePools = psStakePoolParams certPState
461+
knownStakePools = psStakePools certPState
462462
knownCommitteeMembers = authorizedHotCommitteeCredentials committeeState
463463

464464
expectedNetworkId <- liftSTS $ asks networkId

0 commit comments

Comments
 (0)