package tezos-protocol-020-PsParisC

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

The aim of this module is to manage operations involving tokens such as minting, transferring, and burning. Every constructor of the types giver, container, or receiver represents a kind of account that holds a given (or possibly infinite) amount of tokens.

Tokens can be transferred from a giver to a receiver. To uniformly handle all cases, special constructors of givers and receivers may be used. For example, the giver `Minted is used to express a transfer of minted tokens to a receiver, and the receiver `Burned is used to express the action of burning a given amount of tokens taken from a giver. Thanks to uniformity, it is easier to track transfers of tokens throughout the protocol by running grep -R "Token.transfer" src/proto_alpha.

For backward compatibility purpose, an ANTI-PATTERN is used to redistribute slashing to denunciator; this redistribution technic should not be mimicked if it can be avoided (see https://gitlab.com/tezos/tezos/-/issues/4787). The anti-pattern works as follows: The part of slashed amounts that goes to the author of the denunciation are not directly distributed to him. Tokens are transferred to a burning sink, then minted from an infinite source ( see `Double_signing_punishments, and `Sc_rollup_refutation_rewards ). Again, this is an ANTI-PATTERN that should not be mimicked.

container is the type of token holders with finite capacity, and whose assets are contained in the context. An account may have several token holders, that can serve as sources and/or sinks. For example, an implicit account d serving as a delegate has a token holder for its own spendable balance, and another token holder for its frozen deposits.

type container = [
  1. | `Contract of Contract_repr.t
    (*

    Implicit account's or Originated contract's spendable balance

    *)
  2. | `Collected_commitments of Blinded_public_key_hash.t
    (*

    Pre-funded account waiting for the commited pkh and activation code to be revealed to unlock the funds

    *)
  3. | `Frozen_deposits of Frozen_staker_repr.t
    (*

    Frozen tokens of a staker for consensus security deposits.

    *)
  4. | `Unstaked_frozen_deposits of Unstaked_frozen_staker_repr.t * Cycle_repr.t
    (*

    Frozen tokens of a contract that have been unstaked at the given cycle.

    *)
  5. | `Block_fees
    (*

    Current block's fees collection

    *)
  6. | `Frozen_bonds of Contract_repr.t * Bond_id_repr.t
    (*

    Frozen tokens of a contract for bond deposits (currently used by rollups)

    *)
]
type infinite_source = [
  1. | `Invoice
    (*

    Tokens minted during a protocol upgrade, typically to fund the development of some part of the amendment.

    *)
  2. | `Bootstrap
    (*

    Bootstrap accounts funding

    *)
  3. | `Initial_commitments
    (*

    Funding of Genesis' prefunded accounts requiring an activation

    *)
  4. | `Revelation_rewards
    (*

    Seed nonce revelation rewards

    *)
  5. | `Attesting_rewards
    (*

    Consensus attesting rewards

    *)
  6. | `Baking_rewards
    (*

    Consensus baking fixed rewards

    *)
  7. | `Baking_bonuses
    (*

    Consensus baking variable bonus

    *)
  8. | `Minted
    (*

    Generic source for test purpose

    *)
  9. | `Liquidity_baking_subsidies
    (*

    Subsidy for liquidity-baking contract

    *)
  10. | `Sc_rollup_refutation_rewards
    (*

    Sc_rollup refutation rewards (slashing redistribution)

    *)
]

infinite_source defines types of tokens providers which are considered to be ** of infinite capacity.

type giver = [
  1. | infinite_source
  2. | container
]

giver is the type of token providers. Token providers that are not containers are considered to have infinite capacity.

type infinite_sink = [
  1. | `Storage_fees
    (*

    Fees burnt to compensate storage usage

    *)
  2. | `Double_signing_punishments
    (*

    Consensus slashing

    *)
  3. | `Lost_attesting_rewards of Tezos_protocol_environment_020_PsParisC.Signature.Public_key_hash.t * bool * bool
    (*

    Consensus rewards not distributed because the participation of the delegate was too low.

    *)
  4. | `Sc_rollup_refutation_punishments
    (*

    Smart rollups refutation slashing

    *)
  5. | `Burned
    (*

    Generic sink mainly for test purpose

    *)
]
type receiver = [
  1. | infinite_sink
  2. | container
]

receiver is the type of token receivers. Token receivers that are not containers are considered to have infinite capacity.

balance ctxt container returns a new context because of an access to carbonated data, and the balance associated to the token holder. This function may fail if allocated ctxt container returns false. Returns an error with the message "get_balance" if container refers to an originated contract that is not allocated.

This function is only defined on the few cases for which it is actually needed.

transfer_n ?origin ctxt givers receiver transfers amount Tez from giver to receiver for each (giver, amount) pair in givers, and returns a new context, and the list of corresponding balance updates. The function behaves as though transfer ?origin ctxt giver receiver amount was invoked for each pair (giver, amount) in givers, however a single balance update is generated for the total amount transferred to receiver. When givers is an empty list, the function does nothing to the context, and returns an empty list of balance updates.

transfer ?origin ctxt giver receiver amount transfers amount Tez from giver giver to receiver receiver, and returns a new context, and the list of corresponding balance updates tagged with origin. By default, ~origin is set to Receipt_repr.Block_application. Returns Storage_ErrorMissing_key if giver refers to a contract that is not allocated. Returns a Balance_too_low error if giver refers to a contract whose balance is less than amount. Returns a Subtraction_underflow error if giver is not a contract and its balance is less than amount. Returns a Empty_implicit_delegated_contract error if giver is an implicit contract that delegates to a different contract, and whose balance is equal to amount. Returns a Non_existing_contract error if receiver refers to an originated contract that is not allocated. Returns a Non_existing_contract error if amount <> Tez_repr.zero, and receiver refers to an originated contract that is not allocated. Returns a Addition_overflow error if receiver refers to a receiver whose balance is greater than Int64.max - amount. Returns a Wrong_level error if src or receiver refer to a level that is not the current level.

module Internal_for_tests : sig ... end
OCaml

Innovation. Community. Security.