Module Mavryk_raw_protocol_alpha.Apply

This module supports advancing the ledger state by applying operations.

Each operation application takes and returns an application_state, representing the old and new state, respectively.

The Main module provides wrappers for the functionality in this module, satisfying the Protocol signature.

type mode =
  1. | Application of {
    1. block_header : Alpha_context.Block_header.t;
    2. fitness : Alpha_context.Fitness.t;
    3. payload_producer : Alpha_context.Consensus_key.t;
    4. block_producer : Alpha_context.Consensus_key.t;
    5. predecessor_level : Alpha_context.Level.t;
    6. predecessor_round : Alpha_context.Round.t;
    }
  2. | Full_construction of {
    1. block_data_contents : Alpha_context.Block_header.contents;
    2. predecessor_hash : Mavryk_protocol_environment_alpha.Block_hash.t;
    3. payload_producer : Alpha_context.Consensus_key.t;
    4. block_producer : Alpha_context.Consensus_key.t;
    5. round : Alpha_context.Round.t;
    6. predecessor_level : Alpha_context.Level.t;
    7. predecessor_round : Alpha_context.Round.t;
    }
  3. | Partial_construction of {
    1. predecessor_fitness : Alpha_context.Fitness.raw;
    }
    (*

    This mode is mainly intended to be used by a mempool.

    *)
type application_state = {
  1. ctxt : Alpha_context.context;
  2. chain_id : Mavryk_protocol_environment_alpha.Chain_id.t;
  3. mode : mode;
  4. op_count : int;
  5. migration_balance_updates : Alpha_context.Receipt.balance_updates;
  6. liquidity_baking_toggle_ema : Alpha_context.Per_block_votes.Liquidity_baking_toggle_EMA.t;
  7. adaptive_issuance_vote_ema : Alpha_context.Per_block_votes.Adaptive_issuance_launch_EMA.t;
  8. adaptive_issuance_launch_cycle : Alpha_context.Cycle.t option;
  9. implicit_operations_results : Apply_results.packed_successful_manager_operation_result list;
}

Initialize an application_state for the application of an existing block.

Initialize an application_state for the construction of a fresh block.

Initialize an application_state for the partial construction of a block. This is similar to construction but less information is required as this will not yield a final valid block.

Apply an operation, i.e. update the given context in accordance with the operation's semantic (or return an error if the operation is not applicable).

For non-manager operations, the application of a validated operation should always fully succeed.

For manager operations, the application has two stages. The first stage consists in updating the context to:

  • take the fees;
  • increment the account's counter;
  • decrease of the available block gas by operation's gas_limit.

These updates are mandatory. In particular, taking the fees is critically important. The Validate module is responsible for ensuring that the operation is solvable, i.e. that fees can be taken, i.e. that the first stage of manager operation application cannot fail. If this stage fails nevertheless, the function returns an error.

The second stage of this function (still in the case of a manager operation) consists in applying all the other effects, in accordance with the semantic of the operation's kind.

An error may happen during this second phase: in that case, the function returns the context obtained at the end of the first stage, and metadata that contain the error. This means that the operation has no other effects than those described above during the first phase.

Finalize the application of a block depending on its mode.

value_of_key ctxt k builds a value identified by key k so that it can be put into the cache.

module Internal_for_benchmark : sig ... end