package tezos-protocol-014-PtKathma
This module supports advancing the ledger state by applying operation
s.
Each operation application takes and returns an Alpha_context.t
, representing the old and new state, respectively.
The Main
module provides wrappers for the functionality in this module, satisfying the Protocol signature.
type Tezos_protocol_environment_014_PtKathma.Error_monad.error +=
| Internal_operation_replay of Apply_internal_results.packed_internal_contents
| Tx_rollup_feature_disabled
| Tx_rollup_invalid_transaction_ticket_amount
| Sc_rollup_feature_disabled
| Empty_transaction of Alpha_context.Contract.t
val begin_partial_construction :
Alpha_context.context ->
predecessor_level:Alpha_context.Level.t ->
toggle_vote:Liquidity_baking_repr.liquidity_baking_toggle_vote ->
(Alpha_context.t
* Apply_results.packed_successful_manager_operation_result list
* Alpha_context.Liquidity_baking.Toggle_EMA.t)
Tezos_protocol_environment_014_PtKathma.Error_monad.tzresult
Tezos_protocol_environment_014_PtKathma.Lwt.t
type 'a full_construction = {
ctxt : Alpha_context.context;
protocol_data : 'a;
payload_producer : Tezos_protocol_environment_014_PtKathma.Signature.public_key_hash;
block_producer : Tezos_protocol_environment_014_PtKathma.Signature.public_key_hash;
round : Alpha_context.Round.t;
implicit_operations_results : Apply_results.packed_successful_manager_operation_result list;
liquidity_baking_toggle_ema : Alpha_context.Liquidity_baking.Toggle_EMA.t;
}
val begin_full_construction :
Alpha_context.context ->
predecessor_timestamp:Tezos_protocol_environment_014_PtKathma.Time.t ->
predecessor_level:Alpha_context.Level.t ->
predecessor_round:Alpha_context.Round.t ->
round:Alpha_context.Round.t ->
Alpha_context.Block_header.contents ->
Alpha_context.Block_header.contents full_construction
Tezos_protocol_environment_014_PtKathma.Error_monad.tzresult
Tezos_protocol_environment_014_PtKathma.Lwt.t
val begin_application :
Alpha_context.context ->
Tezos_protocol_environment_014_PtKathma.Chain_id.t ->
Alpha_context.Block_header.t ->
Alpha_context.Fitness.t ->
predecessor_timestamp:Tezos_protocol_environment_014_PtKathma.Time.t ->
predecessor_level:Alpha_context.Level.t ->
predecessor_round:Alpha_context.Round.t ->
(Alpha_context.t
* Tezos_protocol_environment_014_PtKathma.Signature.public_key
* Tezos_protocol_environment_014_PtKathma.Signature.public_key_hash
* Apply_results.packed_successful_manager_operation_result list
* Alpha_context.Liquidity_baking.Toggle_EMA.t)
Tezos_protocol_environment_014_PtKathma.Error_monad.tzresult
Tezos_protocol_environment_014_PtKathma.Lwt.t
type apply_mode =
| Application of {
predecessor_block : Tezos_protocol_environment_014_PtKathma.Block_hash.t;
payload_hash : Block_payload_hash.t;
locked_round : Alpha_context.Round.t option;
predecessor_level : Alpha_context.Level.t;
predecessor_round : Alpha_context.Round.t;
round : Alpha_context.Round.t;
}
| Full_construction of {
predecessor_block : Tezos_protocol_environment_014_PtKathma.Block_hash.t;
payload_hash : Block_payload_hash.t;
predecessor_level : Alpha_context.Level.t;
predecessor_round : Alpha_context.Round.t;
round : Alpha_context.Round.t;
}
| Partial_construction of {
predecessor_level : Alpha_context.Level.t;
predecessor_round : Alpha_context.Round.t;
grand_parent_round : Alpha_context.Round.t;
}
val apply_operation :
Alpha_context.context ->
Tezos_protocol_environment_014_PtKathma.Chain_id.t ->
apply_mode ->
Script_ir_translator.unparsing_mode ->
payload_producer:Alpha_context.public_key_hash ->
Validate_operation.stamp ->
Tezos_protocol_environment_014_PtKathma.Operation_hash.t ->
'a Alpha_context.operation ->
(Alpha_context.context * 'a Apply_results.operation_metadata)
Tezos_protocol_environment_014_PtKathma.Error_monad.tzresult
Tezos_protocol_environment_014_PtKathma.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).
The Validate_operation.stamp
argument enforces that an operation needs to be validated by Validate_operation
before it can be applied.
TODO: https://gitlab.com/tezos/tezos/-/issues/2603
Currently, Validate_operation.validate_operation
does nothing on non-manager operations. The "validation" of these operations is instead handled by apply_operation
, which may thus return an error if the operation is ill-formed. Once validate_operation
has been extended to every kind of operation, apply_operation
should never return an error.
See apply_manager_operation
for additional information on the application of manager operations.
type finalize_application_mode =
| Finalize_full_construction of {
level : Alpha_context.Raw_level.t;
predecessor_round : Alpha_context.Round.t;
}
| Finalize_application of Alpha_context.Fitness.t
val finalize_application :
Alpha_context.context ->
finalize_application_mode ->
Alpha_context.Block_header.contents ->
payload_producer:Alpha_context.public_key_hash ->
block_producer:Alpha_context.public_key_hash ->
Alpha_context.Liquidity_baking.Toggle_EMA.t ->
Apply_results.packed_successful_manager_operation_result list ->
round:Alpha_context.Round.t ->
predecessor:Tezos_protocol_environment_014_PtKathma.Block_hash.t ->
migration_balance_updates:Alpha_context.Receipt.balance_updates ->
(Alpha_context.context
* Alpha_context.Fitness.t
* Apply_results.block_metadata,
Tezos_protocol_environment_014_PtKathma.Error_monad.error
Tezos_protocol_environment_014_PtKathma.Error_monad.trace)
Tezos_protocol_environment_014_PtKathma.Pervasives.result
Tezos_protocol_environment_014_PtKathma.Lwt.t
val apply_contents_list :
Alpha_context.context ->
Tezos_protocol_environment_014_PtKathma.Chain_id.t ->
apply_mode ->
Script_ir_translator.unparsing_mode ->
payload_producer:Alpha_context.public_key_hash ->
Validate_operation.stamp ->
'kind Alpha_context.operation ->
'kind Alpha_context.contents_list ->
(Alpha_context.context * 'kind Apply_results.contents_result_list)
Tezos_protocol_environment_014_PtKathma.Error_monad.tzresult
Tezos_protocol_environment_014_PtKathma.Lwt.t
Similar to apply_operation
, but a few initial and final steps are skipped. This function is called in lib_plugin/RPC.ml
.
val apply_manager_operation :
Alpha_context.context ->
Script_ir_translator.unparsing_mode ->
payload_producer:Alpha_context.public_key_hash ->
Tezos_protocol_environment_014_PtKathma.Chain_id.t ->
mempool_mode:bool ->
Validate_operation.stamp ->
'a Alpha_context.Kind.manager Alpha_context.contents_list ->
(Alpha_context.context
* 'a Alpha_context.Kind.manager Apply_results.contents_result_list)
Tezos_protocol_environment_014_PtKathma.Error_monad.tzresult
Tezos_protocol_environment_014_PtKathma.Lwt.t
Update the context to reflect the application of a manager operation.
This function first updates 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. That's why apply_manager_operation
takes a Validate_operation.stamp
argument, so that it may only be called after having validated the operation by calling Validate_operation
. Indeed, this module is responsible for ensuring that the operation is solvable, i.e. that fees can be taken, i.e. that the first stage of apply_manager_operation
cannot fail. If this stage fails nevertheless, the function returns an error.
The second stage of this function 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 a contents_result_list
that contains the error. This means that the operation has no other effects than those described above during the first phase.
val value_of_key :
Alpha_context.context ->
Tezos_protocol_environment_014_PtKathma.Context.Cache.key ->
Tezos_protocol_environment_014_PtKathma.Context.Cache.value
Tezos_protocol_environment_014_PtKathma.Error_monad.tzresult
Tezos_protocol_environment_014_PtKathma.Lwt.t
value_of_key ctxt k
builds a value identified by key k
so that it can be put into the cache.
val are_endorsements_required :
Alpha_context.context ->
level:Alpha_context.Raw_level.t ->
bool Tezos_protocol_environment_014_PtKathma.Error_monad.tzresult
Tezos_protocol_environment_014_PtKathma.Lwt.t
Check if endorsements are required for a given level.
val check_minimum_endorsements :
endorsing_power:int ->
minimum:int ->
unit Tezos_protocol_environment_014_PtKathma.Error_monad.tzresult
Check if a block's endorsing power is at least the minim required.