package tezos-protocol-010-PtGRANAD
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=7062cd57addd452852598a2214ade393130efa087b99068d53713bdf912b3680
sha512=08e4091144a03ce3c107fb91a66501bd8b65ca3278917c455a2eaac6df3e108ade63f6ab8340a4bb152d60f404326e464d0ec95d26cafe8e82f870465d24a5fc
doc/tezos-protocol-010-PtGRANAD.raw/Tezos_raw_protocol_010_PtGRANAD/Roll_storage/index.html
Module Tezos_raw_protocol_010_PtGRANAD.Roll_storageSource
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_010_PtGRANAD.Error_monad.error += | Consume_roll_change| No_roll_for_delegate| No_roll_snapshot_for_cycle of Cycle_repr.t| Unregistered_delegate of Tezos_protocol_environment_010_PtGRANAD.Signature.Public_key_hash.t
val init :
Raw_context.t ->
Raw_context.t Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tinit 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.
val init_first_cycles :
Raw_context.t ->
Raw_context.t Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tinit_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.
val cycle_end :
Raw_context.t ->
Cycle_repr.t ->
Raw_context.t Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tcycle_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.
val snapshot_rolls :
Raw_context.t ->
Raw_context.t Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tsnapshot_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.
val fold :
Raw_context.t ->
f:
(Roll_repr.roll ->
Tezos_protocol_environment_010_PtGRANAD.Signature.Public_key.t ->
'a ->
'a Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.t) ->
'a ->
'a Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tfold 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.
val baking_rights_owner :
Raw_context.t ->
Level_repr.t ->
priority:int ->
Tezos_protocol_environment_010_PtGRANAD.Signature.Public_key.t
Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tMay return a No_roll_snapshot_for_cycle error.
val endorsement_rights_owner :
Raw_context.t ->
Level_repr.t ->
slot:int ->
Tezos_protocol_environment_010_PtGRANAD.Signature.Public_key.t
Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tMay return a No_roll_snapshot_for_cycle error.
val delegate_pubkey :
Raw_context.t ->
Tezos_protocol_environment_010_PtGRANAD.Signature.Public_key_hash.t ->
Tezos_protocol_environment_010_PtGRANAD.Signature.Public_key.t
Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tdelegate_pubkey ctxt delegate returns the public key of delegate found in context ctxt if there exists a registered contract.
val count_rolls :
Raw_context.t ->
Tezos_protocol_environment_010_PtGRANAD.Signature.Public_key_hash.t ->
int Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tcount_rolls ctxt delegate returns the number of rolls held by delegate in context ctxt.
val get_change :
Raw_context.t ->
Tezos_protocol_environment_010_PtGRANAD.Signature.Public_key_hash.t ->
Tez_repr.t Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tget_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.
val update_tokens_per_roll :
Raw_context.t ->
Tez_repr.t ->
Raw_context.t Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tupdate_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.
val get_contract_delegate :
Raw_context.t ->
Contract_repr.t ->
Tezos_protocol_environment_010_PtGRANAD.Signature.Public_key_hash.t option
Tezos_protocol_environment_010_PtGRANAD.Error_monad.tzresult
Tezos_protocol_environment_010_PtGRANAD.Lwt.tget_contract_delegate ctxt contract returns the public key hash of the delegate whose contract is contract in context ctxt.