Mavryk_raw_protocol_alpha.Apply
This module supports advancing the ledger state by applying operation
s.
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 Mavryk_protocol_environment_alpha.Error_monad.error +=
| Internal_operation_replay of Apply_internal_results.packed_internal_operation
| Empty_transaction of Alpha_context.Contract.t
type mode =
| Application of {
block_header : Alpha_context.Block_header.t;
fitness : Alpha_context.Fitness.t;
payload_producer : Alpha_context.Consensus_key.t;
block_producer : Alpha_context.Consensus_key.t;
predecessor_level : Alpha_context.Level.t;
predecessor_round : Alpha_context.Round.t;
}
| Full_construction of {
block_data_contents : Alpha_context.Block_header.contents;
predecessor_hash : Mavryk_protocol_environment_alpha.Block_hash.t;
payload_producer : Alpha_context.Consensus_key.t;
block_producer : Alpha_context.Consensus_key.t;
round : Alpha_context.Round.t;
predecessor_level : Alpha_context.Level.t;
predecessor_round : Alpha_context.Round.t;
}
| Partial_construction of {
predecessor_fitness : Alpha_context.Fitness.raw;
}
This mode is mainly intended to be used by a mempool.
*)type application_state = {
ctxt : Alpha_context.context;
chain_id : Mavryk_protocol_environment_alpha.Chain_id.t;
mode : mode;
op_count : int;
migration_balance_updates : Alpha_context.Receipt.balance_updates;
liquidity_baking_toggle_ema : Alpha_context.Per_block_votes.Liquidity_baking_toggle_EMA.t;
adaptive_issuance_vote_ema : Alpha_context.Per_block_votes.Adaptive_issuance_launch_EMA.t;
adaptive_issuance_launch_cycle : Alpha_context.Cycle.t option;
implicit_operations_results : Apply_results.packed_successful_manager_operation_result
list;
}
val begin_application :
Alpha_context.context ->
Mavryk_protocol_environment_alpha.Chain_id.t ->
migration_balance_updates:Alpha_context.Receipt.balance_updates ->
migration_operation_results:Alpha_context.Migration.origination_result list ->
predecessor_fitness:Alpha_context.Fitness.raw ->
Alpha_context.Block_header.t ->
application_state Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
Initialize an application_state
for the application of an existing block.
val begin_full_construction :
Alpha_context.context ->
Mavryk_protocol_environment_alpha.Chain_id.t ->
migration_balance_updates:Alpha_context.Receipt.balance_updates ->
migration_operation_results:Alpha_context.Migration.origination_result list ->
predecessor_timestamp:Mavryk_protocol_environment_alpha.Time.t ->
predecessor_level:Alpha_context.Level.t ->
predecessor_round:Alpha_context.Round.t ->
predecessor_hash:Mavryk_protocol_environment_alpha.Block_hash.t ->
timestamp:Mavryk_protocol_environment_alpha.Time.t ->
Alpha_context.Block_header.contents ->
application_state Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
Initialize an application_state
for the construction of a fresh block.
val begin_partial_construction :
Alpha_context.context ->
Mavryk_protocol_environment_alpha.Chain_id.t ->
migration_balance_updates:Alpha_context.Receipt.balance_updates ->
migration_operation_results:Alpha_context.Migration.origination_result list ->
predecessor_hash:Mavryk_protocol_environment_alpha.Block_hash.t ->
predecessor_fitness:Alpha_context.Fitness.raw ->
application_state Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
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.
val apply_operation :
application_state ->
Mavryk_protocol_environment_alpha.Operation_hash.t ->
Alpha_context.packed_operation ->
(application_state * Apply_results.packed_operation_metadata)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
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:
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.
val finalize_block :
application_state ->
Alpha_context.Block_header.shell_header option ->
(Mavryk_protocol_environment_alpha.Updater.validation_result
* Apply_results.block_metadata)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
Finalize the application of a block depending on its mode.
val value_of_key :
Alpha_context.context ->
Mavryk_protocol_environment_alpha.Context.Cache.key ->
Mavryk_protocol_environment_alpha.Context.Cache.value
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
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