EpochTransition

scalus.cardano.ledger.epoch.internal.EpochTransition

The epoch transition: what the ledger does to its state at one epoch boundary, ledger-rules spec section 12.2.

The Emulator runs transition once for each boundary a slot change crosses, in order, spec [EB-1], [EB-1a]: unlike NEWEPOCH (conway Rules/NewEpoch.hs:165), which runs the boundary only when the new epoch follows the last one.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def instantStake(utxos: Utxos): Map[Credential, Coin]

The coin of the base-address outputs of utxos, per stake credential, the ledger's InstantStake: pointer, enterprise and Byron addresses add nothing (StakeRefBase only, conway State/Stake.hs:101-121), spec [SN-2], [SN-5]. EmulatorBase.stakeDistribution reads it too, spec [DM-15] (D80).

The coin of the base-address outputs of utxos, per stake credential, the ledger's InstantStake: pointer, enterprise and Byron addresses add nothing (StakeRefBase only, conway State/Stake.hs:101-121), spec [SN-2], [SN-5]. EmulatorBase.stakeDistribution reads it too, spec [DM-15] (D80).

Attributes

def rewardUpdate(go: StakeSnapshot, fee: Coin, blocksMadePrev: Map[PoolKeyHash, Long], reserves: Coin, env: EpochEnv): RewardUpdate

The reward update of an epoch, startStep and completeRupd run in one go (shelley LedgerState/PulsingReward.hs:99-212, 242-280; Rewards.hs:86-157, 291-393), ledger-rules spec [RW-1], [RW-2], [RW-13] to [RW-20], with exact rationals floored where the ledger floors, [RW-19].

The reward update of an epoch, startStep and completeRupd run in one go (shelley LedgerState/PulsingReward.hs:99-212, 242-280; Rewards.hs:86-157, 291-393), ledger-rules spec [RW-1], [RW-2], [RW-13] to [RW-20], with exact rationals floored where the ledger floors, [RW-19].

At PV >= 7 only, [RW-20]: rewards summed per credential and no registration prefilter; [EB-5] checks registration when it pays. Under Ideal, eta = 1 and every pool of go with stake earns with appPerf = 1, [RW-15], D70. The ledger's crashes become rules: expectedBlocks = 0 [RW-14], totalStake <= 0 [RW-16], nOpt = 0 [RW-17] (D71, D83).

Value parameters

blocksMadePrev

the blocks each pool made in the epoch before, nesBprev

fee

the fee snapshot, ssFee

go

the stake snapshot of two boundaries ago, ssStakeGo

reserves

the reserves after the boundary

Attributes

The stake snapshot of ledger, snapShotFromInstantStake (cardano-ledger-core State/SnapShots.hs:418-430), spec [SN-1] to [SN-8], [SN-10].

The stake snapshot of ledger, snapShotFromInstantStake (cardano-ledger-core State/SnapShots.hs:418-430), spec [SN-1] to [SN-8], [SN-10].

  • activeStake: each registered account that delegates to a pool, with the coin of the base-address outputs of its credential plus its balance, when that is above 0 (resolveActiveInstantStakeCredentials, State/Stake.hs:220-246), [SN-2] to [SN-5]. As in the ledger, the pool is not checked: DELEG accepts a delegation only to a registered pool, and POOLREAP clears the delegations to a retired one.
  • pools: every pool in stakePools, with its current params (resetStakePoolsSnapShot, State/SnapShots.hs:409-416), [SN-7]; the delegators of each are found by a scan of the accounts, [SN-10], since Scalus keeps no delegator set (D22, D51), and its fields are those of mkStakePoolSnapShot (:187-216), [SN-8].

Attributes

def totalObligation(certState: CertState, govState: GovState): Coin

Spec [EB-18]: the deposits the ledger owes, totalObligation (shelley LedgerState/Types.hs:690-691): the deposits of the accounts, pools and DReps of certState (conwayObligationCertState, conway State/CertState.hs:112-117) and of the proposals of govState (obligationGovState, conway Governance.hs:416-422). The Emulator genesis starts with it too, D52.

Spec [EB-18]: the deposits the ledger owes, totalObligation (shelley LedgerState/Types.hs:690-691): the deposits of the accounts, pools and DReps of certState (conwayObligationCertState, conway State/CertState.hs:112-117) and of the proposals of govState (obligationGovState, conway Governance.hs:416-422). The Emulator genesis starts with it too, D52.

Attributes

The ledger state, the epoch state and the current pparams after the epoch transition into epoch boundary, spec [EB-4], [EB-25], D88. env.params are the current pparams before it.

The ledger state, the epoch state and the current pparams after the epoch transition into epoch boundary, spec [EB-4], [EB-25], D88. env.params are the current pparams before it.

The steps run in the order of the table of spec section 12.2. A step whose phase has not landed is identity, spec [EB-24]. First [EB-5] applies pendingRewards (conway Rules/NewEpoch.hs:172-178), so SNAP sees the paid rewards and the reduced fees. Then, as conway Rules/Epoch.hs:276-378 runs them: SNAP ([EB-6]), POOLREAP ([EB-7] to [EB-9]), the pparams of the enact state ([EB-13]), the enactment of the pending ratify result ([EB-10] to [EB-14]), the voting state ([EB-15], [EB-16]), the treasury ([EB-17]), HARDFORK ([EB-19]) and RATIFY ([EB-20]), then deposited ([EB-18]) on the result: neither HARDFORK nor RATIFY changes a deposit. The blocks made move to the previous epoch and the last epoch becomes boundary, [EB-21] (conway Rules/NewEpoch.hs:182-192). Last, [EB-22] replaces pendingRewards with the reward update of the new epoch, [RW-21], read from the reserves after [EB-5] and from prevParams after [EB-13], [EB-22a].

Attributes