package tezos-protocol-011-PtHangz2

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Basic roll manipulation.

The storage related to roll (i.e. `Storage.Roll`) is not used outside of this module. And, this interface enforces the invariant that a roll is always either in the limbo list or owned by a delegate.

type Tezos_protocol_environment_011_PtHangz2.Error_monad.error +=
  1. | Consume_roll_change
  2. | No_roll_for_delegate
  3. | No_roll_snapshot_for_cycle of Cycle_repr.t
  4. | Unregistered_delegate of Tezos_protocol_environment_011_PtHangz2.Signature.Public_key_hash.t

init ctxt returns a new context initialized from ctxt where the next roll to be allocated is the first roll, i.e. (Storage.Roll.Next.get ctxt) = Roll_repr.first. This function returns a {!Storage_error Existing_key} error if the context has already been initialized.

init_first_cycles ctxt computes a new context from ctxt where the store has been prepared to save roll snapshots for all cycles from 0 to Constants.preserved_cycles + 2:

1. rolls for all cycles in the interval (0, preserved_cycles) are frozen (after taking a snapshot), 2. a snapshot is taken for rolls of cycle preserved_cycles + 1, 3. rolls for cycle preserved_cycles + 2 are ready for a snapshot, i.e. the necessary storage has been prepared.

cycle_end ctxt last_cycle returns a new context after applying the end-of-cycle bookkeeping to ctxt:

1. clears cycle c = (last_cycle - preserved_cycles) if last_cycle >= preserved_cycles (this amounts to deleting the only snapshot left after the freezing of c), 2. freezes snapshot rolls for the cycle (last_cycle + preserved_cycles + 1) (this amounts to removing all snapshots for the cycle, except one randomly selected for computing baking rights), 3. makes cycle (last_cycle + preserved_cycles + 2) ready for snapshot.

snapshot_rolls ctxt creates roll snapshots for cycle c = level + preserved_cycles + 2. The returned context is such that:

1. the snapshot index associated to cycle c is incremented, 2. the rolls' owners are copied and associated to the snapshot id (c,index) (where index is the current snapshot index of cycle c), 3. the last roll for cycle c, and snapshot index is set to be the next roll of ctxt.

fold ctxt f init folds f on the list of all rolls from Roll_repr.first to Storage.Next.Roll of the context ctxt. Only rolls which have owners are considered, rolls without owners are skipped. The first parameter of f is a roll r, the second parameter of f is the owner of r, and the last parameter is the initial value of the accumulator.

module Delegate : sig ... end
module Contract : sig ... end

get_change ctxt delegate returns the amount of change held by delegate in context ctxt. The change is the part of the staking balance of a delegate that is not part of a roll, i.e., the amount of staking balance (smaller than the value of a roll) not being taken into account for baking rights computation.

update_tokens_per_roll ctxt am performs the following actions:

1. set the constant tokens_per_roll to am, 2. if the constant was increased by tpram, then add the amount nr * tpram to each delegate, where nr is the delegate's number of rolls, 3. if the constant was instead decreased by tpram, then remove the amount nr * tpram from all delegates.

get_contract_delegate ctxt contract returns the public key hash of the delegate whose contract is contract in context ctxt.

OCaml

Innovation. Community. Security.