Skip to content

Conversation

kayvank
Copy link

@kayvank kayvank commented Aug 5, 2025

Rename PoolParams to StatekPoolParams, to avoid confusion with protocol parameters

Description

This PR is for issue #5191, Rename PoolParams to StatekPoolParams, to avoid confusion with protocol parameters

Checklist

  • [x ] Commits in meaningful sequence and with useful messages.
  • Tests added or updated when needed.
  • CHANGELOG.md files updated for packages with externally visible changes.
    NOTE: New section is never added with the code changes. (See RELEASING.md).
  • Versions updated in .cabal and CHANGELOG.md files when necessary, according to the
    versioning process.
  • Version bounds in .cabal files updated when necessary.
    NOTE: If bounds change in a cabal file, that package itself must have a version increase. (See RELEASING.md).
  • Code formatted (use scripts/fourmolize.sh).
  • Cabal files formatted (use scripts/cabal-format.sh).
  • CDDL files are up to date (use scripts/gen-cddl.sh)
  • hie.yaml updated (use scripts/gen-hie.sh).
  • Self-reviewed the diff.

@kayvank
Copy link
Author

kayvank commented Aug 5, 2025

PR is in draft mode pending 3 more changes

  1. This PR made changes to many directories; thus, the corresponding CHANGELOG for all those sub-projects needs to be updated, yes?

  2. We should also change the module name from Cardano.Ledger.PoolParams to Cardano.Ledger.StakePoolParams yes?

  3. StatkePoolParams data members should start with sp, yes?

Rename PoolParams to StatekPoolParams, to avoid confusion with protocol parameters

-- | A stake pool.
data PoolParams = PoolParams
data StakePoolParams = StakePoolParams
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all member should change such that instead of starting with pp , start with sp, yes?

Copy link
Contributor

@teodanciu teodanciu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't realize this was in Draft, so I went through it.
Most of my comments are about the following:
In PState, we already have psStakePoolParams and psFutureStakePoolParams, so no need to duplicate Stake .
And a few minor missed ones.

My take on your questions:

  1. This PR made changes to many directories; thus, the corresponding CHANGELOG for all those sub-projects needs to be updated, yes?

Yes, but only for things that are visible from outside the packages - not internal names.

  1. We should also change the module name from Cardano.Ledger.PoolParams to Cardano.Ledger.StakePoolParams yes?

I don't see why not. It would be good to do int a way that preserves git history

  1. StatkePoolParams data members should start with sp, yes?

I would say even spp for prefix.

Will leave it to Alexey to approve, but otherwise looks good to me - barring the things above ^ .

explainWit "poolparams :: (PoolParams c)" univ $
WitUniv era -> Specification StakePoolParams
witStakePoolParamsSpec univ =
explainWit "poolparams :: (StakePoolParams c)" univ $
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed one here:

Suggested change
explainWit "poolparams :: (StakePoolParams c)" univ $
explainWit "stakePoolParams :: (StakePoolParams c)" univ $

-- | The state used by the POOL rule, which tracks stake pool information.
data PState era = PState
{ psStakePoolParams :: !(Map (KeyHash 'StakePool) PoolParams)
{ psStakeStakePoolParams :: !(Map (KeyHash 'StakePool) StakePoolParams)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we need duplicated Stake here:

Suggested change
{ psStakeStakePoolParams :: !(Map (KeyHash 'StakePool) StakePoolParams)
{ psStakePoolParams :: !(Map (KeyHash 'StakePool) StakePoolParams)

{ psStakeStakePoolParams :: !(Map (KeyHash 'StakePool) StakePoolParams)
-- ^ The stake pool parameters.
, psFutureStakePoolParams :: !(Map (KeyHash 'StakePool) PoolParams)
, psFutureStakeStakePoolParams :: !(Map (KeyHash 'StakePool) StakePoolParams)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, stake is already in the name:

Suggested change
, psFutureStakeStakePoolParams :: !(Map (KeyHash 'StakePool) StakePoolParams)
, psFutureStakePoolParams :: !(Map (KeyHash 'StakePool) StakePoolParams)

Comment on lines +266 to +267
[ "stakeStakePoolParams" .= psStakeStakePoolParams
, "futureStakeStakePoolParams" .= psFutureStakeStakePoolParams
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values in the keys should also not be duplicated:

Suggested change
[ "stakeStakePoolParams" .= psStakeStakePoolParams
, "futureStakeStakePoolParams" .= psFutureStakeStakePoolParams
[ "stakePoolParams" .= psStakePoolParams
, "futureStakePoolParams" .= psFutureStakePoolParams

Comment on lines +484 to +485
psStakeStakePoolParamsL :: Lens' (PState era) (Map (KeyHash 'StakePool) StakePoolParams)
psStakeStakePoolParamsL = lens psStakeStakePoolParams (\ds u -> ds {psStakeStakePoolParams = u})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra Stake:

Suggested change
psStakeStakePoolParamsL :: Lens' (PState era) (Map (KeyHash 'StakePool) StakePoolParams)
psStakeStakePoolParamsL = lens psStakeStakePoolParams (\ds u -> ds {psStakeStakePoolParams = u})
psStakePoolParamsL :: Lens' (PState era) (Map (KeyHash 'StakePool) StakePoolParams)
psStakePoolParamsL = lens psStakePoolParams (\ds u -> ds {psStakePoolParams = u})

in [ "stake" .= ssStake
, "delegations" .= ssDelegations
, "poolParams" .= ssPoolParams
, "poolParams" .= ssStakePoolParams
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, "poolParams" .= ssStakePoolParams
, "stakePoolParams" .= ssStakePoolParams

--
-- > let lookupRefund = lookupDepositDState (certDState dpState)
-- > let isRegPoolId = (`Map.member` psStakePoolParams (certPState dpState))
-- > let isRegPoolId = (`Map.member` psStakeStakePoolParams (certPState dpState))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove the duplicate Stake in PState this will be:

Suggested change
-- > let isRegPoolId = (`Map.member` psStakeStakePoolParams (certPState dpState))
-- > let isRegPoolId = (`Map.member` psStakePoolParams (certPState dpState))

-- If this value is not at least as large as the 'pledgeRatioP',
-- the stake pool will not earn any rewards for the given epoch.
, poolParamsP :: !PoolParams
, poolParamsP :: !StakePoolParams
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this too?

Suggested change
, poolParamsP :: !StakePoolParams
, stakePoolParamsP :: !StakePoolParams

Comment on lines +114 to +115
psStakeStakePoolParamsL,
psFutureStakeStakePoolParamsL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the removing of the extra Stake in core these will be:

Suggested change
psStakeStakePoolParamsL,
psFutureStakeStakePoolParamsL,
psStakePoolParamsL,
psFutureStakePoolParamsL,

, stakeNotVoted :: Coin
, delegatees :: Map (Credential 'Staking) DRep
, poolParams :: Map (KeyHash 'StakePool) PoolParams
, poolParams :: Map (KeyHash 'StakePool) StakePoolParams
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is not so important, but we could change it too, for consistency:

Suggested change
, poolParams :: Map (KeyHash 'StakePool) StakePoolParams
, stakePoolParams :: Map (KeyHash 'StakePool) StakePoolParams

@kayvank
Copy link
Author

kayvank commented Aug 5, 2025

Sorry, I didn't realize this was in Draft, so I went through it. Most of my comments are about the following: In PState, we already have psStakePoolParams and psFutureStakePoolParams, so no need to duplicate Stake . And a few minor missed ones.

My take on your questions:

  1. This PR made changes to many directories; thus, the corresponding CHANGELOG for all those sub-projects needs to be updated, yes?

Yes, but only for things that are visible from outside the packages - not internal names.

  1. We should also change the module name from Cardano.Ledger.PoolParams to Cardano.Ledger.StakePoolParams yes?

I don't see why not. It would be good to do int a way that preserves git history

  1. StatkePoolParams data members should start with sp, yes?

I would say even spp for prefix.

Will leave it to Alexey to approve, but otherwise looks good to me - barring the things above ^ .

Thank you for taking the time to go through the PR. I'll fix the issues you pointed out later today, after hours :)

@teodanciu
Copy link
Contributor

teodanciu commented Aug 5, 2025

Also, I realize now that this PR is quite conflicting with: #5196, which is redefining PoolParams in a different module.
(maybe a be a good idea to coordinate on this ?) unless you're already aware of it. It's fine if it's just a matter of solving git conflicts, just pointing it out in case there's some misunderstanding.

@kayvank
Copy link
Author

kayvank commented Aug 5, 2025

Also, I realize now that this PR is quite conflicting with: #5196, which is redefining PoolParams in a different module. (maybe a be a good idea to coordinate on this ?) unless you're already aware of it. It's fine if it's just a matter of solving git conflicts, just pointing it out in case there's some misunderstanding.

I was not aware of #5196. I should've gone through the pending PRs 1st. I did a preliminary rabae with #5156 , which resulted in 76 conflicts as of now.
Yes, it is best to coordinate. Thank you for pointing that out.
Perhaps it would be prudent to wait for #5196 to be merged into master, then rebase from master. What do you think?

@tzw3
Copy link

tzw3 commented Aug 5, 2025

one question: this file libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/Orphans.hs matches the pattern PoolParams , but it is skipped now, will/should it be renamed ?

@kayvank
Copy link
Author

kayvank commented Aug 6, 2025

one question: this file libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/Orphans.hs matches the pattern PoolParams , but it is skipped now, will/should it be renamed ?

I think it might be best to wait for the earlier PR, #5196, to be completed before continuing with this work. For now, I have stopped working on this draft PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants