Legend:
Library
Module
Module type
Parameter
Class
Class type
This module implements the gas subsystem of the context.
Gas reflects the computational cost of each operation to limit the cost of operations and, by extension, the cost of blocks.
There are two gas quotas: one for operation and one for block. For this reason, we maintain two gas levels -- one for operations and another one for blocks -- that correspond to the remaining amounts of gas, initialized with the quota limits and decreased each time gas is consumed.
val check_limit_is_valid :
context->'aArith.t->(unit,
Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.errorTezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace)Stdlib.result
check_limit_is_valid ctxt limit checks that the given gas limit is well-formed, i.e., it does not exceed the hard gas limit per operation as defined in ctxt and it is positive.
remaining_operation_gas ctxt returns the current gas level in the context ctxt for the current operation. If gas is Unaccounted, an arbitrary value will be returned.
reset_block_gas ctxt returns a context where the remaining gas in the block is reset to the constant hard_gas_limit_per_block, i.e., as if no operations have been included in the block.
/!\ Do not call this function unless you want to validate operations on their own (like in the mempool).
consumed since until is the operation gas level difference between context since and context until. This function returns Arith.zero if any of the two contexts allows for an unlimited gas consumption. This function also returns Arith.zero if since has less gas than until.
val pp_cost : Stdlib.Format.formatter ->cost-> unit
val consume :
context->cost->(context,
Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.errorTezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace)Stdlib.result
consume ctxt cost subtracts cost to the current operation gas level in ctxt. This operation may fail with Operation_quota_exceeded if the operation gas level would go below zero.
val consume_limit_in_block :
context->'aArith.t->(context,
Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.errorTezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace)Stdlib.result
consume_limit_in_block ctxt limit consumes limit in the current block gas level of the context. This operation may fail with error Block_quota_exceeded if not enough gas remains in the block. This operation may also fail with Gas_limit_too_high if limit is greater than the allowed limit for operation gas level.