Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

638-Allow next leadership-schedule at 4k/f #639

Merged
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
7 changes: 6 additions & 1 deletion cardano-api/internal/Cardano/Api/LedgerState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1792,14 +1792,19 @@ nextEpochEligibleLeadershipSlots sbe sGen serCurrEpochState ptclState poolid (Vr
Slot.epochInfoRange eInfo (currentEpoch `Slot.addEpochInterval` Slot.EpochInterval 1)

-- First we check if we are within 3k/f slots of the end of the current epoch.
-- In Conway era onwards, we use 4k/f slots instead of 3k/f slots.
-- see: https://ouroboros-consensus.cardano.intersectmbo.org/docs/for-developers/Glossary#epoch-structure
-- Why? Because the stake distribution is stable at this point.
-- k is the security parameter
-- f is the active slot coefficient
let stabilityWindowR :: Rational
stabilityWindowR = fromIntegral (3 * sgSecurityParam sGen) / Ledger.unboundRational (sgActiveSlotsCoeff sGen)
stabilityWindowR =
fromIntegral (stabilityWindowConst * sgSecurityParam sGen)
/ Ledger.unboundRational (sgActiveSlotsCoeff sGen)
stabilityWindowSlots :: SlotNo
stabilityWindowSlots = fromIntegral @Word64 $ floor $ fromRational @Double stabilityWindowR
stableStakeDistribSlot = currentEpochLastSlot - stabilityWindowSlots
stabilityWindowConst = caseShelleyToBabbageOrConwayEraOnwards (const 3) (const 4) sbe

case cTip of
ChainTipAtGenesis -> Left LeaderErrGenesisSlot
Expand Down
Loading