-
Notifications
You must be signed in to change notification settings - Fork 174
Description
Blocked on #5576
We need to introduce a new type that will contain not only the stake for a staking credential, but also the associated delegation:
data StakeWithDelegation = StakeWithDelegation
{ swdStake :: {-# UNPACK #-} !(NonZero (CompactForm Coin))
, swdDelegation :: !(KeyHash StakePool)
}
newtype ActiveStake = ActiveStake
{ unActiveStake :: VMap VB VB (Credential Staking) StakeWithDelegation
}This will properly describe the invariant of the active stake in the snapshots: we only care about non-zero stake that is "active", i.e. has an active delegation to a registered stake pool.
This approach will let us remove ssDelegations field and will later reduce the number of tables needed for LedgerHD, since ssActiveStake and ssDelegations can be combined into a single field:
data SnapShot = SnapShot
- { ssActiveStake :: !Stake
+ { ssActiveStake :: !ActiveStake
- , ssDelegations :: !(VMap VB VB (Credential Staking) (KeyHash StakePool)) This will also result in some nice computational optimizations:
As part of the resolveInstantStake we already lookup the actual delegation, but ignore the result. We just need to retain the result and this will let us avoid:
- A whole another iteration over accounts map:
https://github.com/IntersectMBO/cardano-ledger/blob/c0cc1c99232c06d2c65789794f6c10b39cedcdb7/libs/cardano-ledger-core/src/Cardano/Ledger/State/SnapShots.hs#L445C5-L455 - Redundant lookup in the rewards pulser:
poolId <- VMap.lookup cred fvDelegs
This work has already been partially started in this branch and can be picked up where it was left off: https://github.com/IntersectMBO/cardano-ledger/tree/lehins/subsume-delegs-to-active-stake
Metadata
Metadata
Assignees
Labels
Type
Projects
Status