Skip to content

Commit 52ca639

Browse files
committed
Praos: use larger nonce stabilization window starting in Conway
1 parent 7c1f44c commit 52ca639

File tree

4 files changed

+48
-16
lines changed

4 files changed

+48
-16
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Non-Breaking
2+
3+
- Change the randomness stabilization window for Conway (and future eras) to
4+
`4k/f` instead of `3k/f` (one stability window) that was used for Babbage and
5+
TPraos-based eras. See erratum 17.3 in the Shelley ledger specs for context.
6+
7+
Note that this is a backwards-incompatible change for all existing chains
8+
containing (at least one full epoch worth of) Conway blocks.

ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/Node.hs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,13 @@ protocolInfoCardano paramsCardano
730730
praosMaxMajorPV = maxMajorProtVer,
731731
praosMaxLovelaceSupply = SL.sgMaxLovelaceSupply genesisShelley,
732732
praosNetworkId = SL.sgNetworkId genesisShelley,
733-
praosSystemStart = SystemStart $ SL.sgSystemStart genesisShelley
733+
praosSystemStart = SystemStart $ SL.sgSystemStart genesisShelley,
734+
praosRandomnessStabilisationWindow =
735+
-- This value is used for all Praos eras /except/ Babbage, see
736+
-- 'partialConsensusConfigBabbage'.
737+
SL.computeRandomnessStabilisationWindow
738+
(SL.sgSecurityParam genesisShelley)
739+
(SL.mkActiveSlotCoeff $ SL.sgActiveSlotsCoeff genesisShelley)
734740
}
735741

736742
PraosParams { praosSlotsPerKESPeriod, praosMaxKESEvo } = praosParams
@@ -827,7 +833,17 @@ protocolInfoCardano paramsCardano
827833

828834
partialConsensusConfigBabbage ::
829835
PartialConsensusConfig (BlockProtocol (ShelleyBlock (Praos c) (BabbageEra c)))
830-
partialConsensusConfigBabbage = praosParams
836+
partialConsensusConfigBabbage = praosParams {
837+
-- For Praos in Babbage (just as in all TPraos eras) we use the
838+
-- smaller (3k/f vs 4k/f slots) stability window here for
839+
-- backwards-compatibility. See erratum 17.3 in the Shelley ledger
840+
-- specs for context.
841+
praosRandomnessStabilisationWindow =
842+
SL.computeStabilityWindow
843+
(SL.sgSecurityParam genesisShelley)
844+
(SL.mkActiveSlotCoeff $ SL.sgActiveSlotsCoeff genesisShelley)
845+
}
846+
831847

832848
partialLedgerConfigBabbage :: PartialLedgerConfig (ShelleyBlock (Praos c) (BabbageEra c))
833849
partialLedgerConfigBabbage =
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Breaking
2+
3+
- Add `praosRandomnessStabilisationWindow` to `PraosParams`, allowing to
4+
configure in which slot the epoch nonce is snapshotted (which can now vary
5+
between different eras).

ouroboros-consensus-protocol/src/ouroboros-consensus-protocol/Ouroboros/Consensus/Protocol/Praos.hs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import Cardano.Ledger.Keys (KeyHash, KeyRole (BlockIssuer),
4545
import qualified Cardano.Ledger.Keys as SL
4646
import Cardano.Ledger.PoolDistr
4747
(IndividualPoolStake (IndividualPoolStake))
48-
import Cardano.Ledger.Shelley.API (computeStabilityWindow)
4948
import qualified Cardano.Ledger.Shelley.API as SL
5049
import Cardano.Ledger.Slot (Duration (Duration), (+*))
5150
import Cardano.Protocol.TPraos.BHeader (BoundedNatural (bvValue),
@@ -183,29 +182,35 @@ forgePraosFields
183182
-- | Praos parameters that are node independent
184183
data PraosParams = PraosParams
185184
{ -- | See 'Globals.slotsPerKESPeriod'.
186-
praosSlotsPerKESPeriod :: !Word64,
185+
praosSlotsPerKESPeriod :: !Word64,
187186
-- | Active slots coefficient. This parameter represents the proportion
188187
-- of slots in which blocks should be issued. This can be interpreted as
189188
-- the probability that a party holding all the stake will be elected as
190189
-- leader for a given slot.
191-
praosLeaderF :: !SL.ActiveSlotCoeff,
190+
praosLeaderF :: !SL.ActiveSlotCoeff,
192191
-- | See 'Globals.securityParameter'.
193-
praosSecurityParam :: !SecurityParam,
192+
praosSecurityParam :: !SecurityParam,
194193
-- | Maximum number of KES iterations, see 'Globals.maxKESEvo'.
195-
praosMaxKESEvo :: !Word64,
194+
praosMaxKESEvo :: !Word64,
196195
-- | Quorum for update system votes and MIR certificates, see
197196
-- 'Globals.quorum'.
198-
praosQuorum :: !Word64,
197+
praosQuorum :: !Word64,
199198
-- | All blocks invalid after this protocol version, see
200199
-- 'Globals.maxMajorPV'.
201-
praosMaxMajorPV :: !MaxMajorProtVer,
200+
praosMaxMajorPV :: !MaxMajorProtVer,
202201
-- | Maximum number of lovelace in the system, see
203202
-- 'Globals.maxLovelaceSupply'.
204-
praosMaxLovelaceSupply :: !Word64,
203+
praosMaxLovelaceSupply :: !Word64,
205204
-- | Testnet or mainnet?
206-
praosNetworkId :: !SL.Network,
205+
praosNetworkId :: !SL.Network,
207206
-- | The system start, as projected from the chain's genesis block.
208-
praosSystemStart :: !SystemStart
207+
praosSystemStart :: !SystemStart,
208+
-- | The number of slots before the start of an epoch where the
209+
-- corresponding epoch nonce is snapshotted. This has to be at least one
210+
-- stability window such that the nonce is stable at the beginning of the
211+
-- epoch. Ouroboros Genesis requires this to be even larger, see
212+
-- 'SL.computeRandomnessStabilisationWindow'.
213+
praosRandomnessStabilisationWindow :: !Word64
209214
}
210215
deriving (Generic, NoThunks)
211216

@@ -462,7 +467,7 @@ instance PraosCrypto c => ConsensusProtocol (Praos c) where
462467
-- - Update the operational certificate counter.
463468
reupdateChainDepState
464469
_cfg@( PraosConfig
465-
PraosParams {praosSecurityParam, praosLeaderF}
470+
PraosParams {praosRandomnessStabilisationWindow}
466471
ei
467472
)
468473
b
@@ -473,7 +478,7 @@ instance PraosCrypto c => ConsensusProtocol (Praos c) where
473478
praosStateLabNonce = prevHashToNonce (Views.hvPrevHash b),
474479
praosStateEvolvingNonce = newEvolvingNonce,
475480
praosStateCandidateNonce =
476-
if slot +* Duration stabilityWindow < firstSlotNextEpoch
481+
if slot +* Duration praosRandomnessStabilisationWindow < firstSlotNextEpoch
477482
then newEvolvingNonce
478483
else praosStateCandidateNonce cs,
479484
praosStateOCertCounters =
@@ -489,8 +494,6 @@ instance PraosCrypto c => ConsensusProtocol (Praos c) where
489494
let nextEpoch = EpochNo $ currentEpochNo + 1
490495
epochInfoFirst epochInfoWithErr nextEpoch
491496
cs = tickedPraosStateChainDepState tcs
492-
stabilityWindow =
493-
computeStabilityWindow (maxRollbacks praosSecurityParam) praosLeaderF
494497
eta = vrfNonceValue (Proxy @c) $ Views.hvVrfRes b
495498
newEvolvingNonce = praosStateEvolvingNonce cs eta
496499
OCert _ n _ _ = Views.hvOCert b

0 commit comments

Comments
 (0)