package tezos-protocol-011-PtHangz2

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

Internal representation of the gas limit available to the node baking a new block. It should be proportional to the time and energy required to perform a computation.

This protects the bakers from performing exceedingly costly computations while baking and also allows them to select cheaper-to-compute operations to include in their blocks, as their reward for baking a block is not directly related to the resources consumed by the machine performing the operation.

It can be Unaccounted (unlimited) or Limited to some fixed-point value (see Fixed_point_repr for the details). The value is represented with 3 decimal places of precision.

All computations on gas are performed in saturation arithmetic (see Saturation_repr) bounded between 0 and 2 ^ 62 - 1

type t =
  1. | Unaccounted
  2. | Limited of {
    1. remaining : Arith.fp;
    }

Represents a gas cost of an operation. The gas model is constructed such that the cost of each operation is roughly proportional to the time required to perform the operation. If the gas cost of an operation exceeds the available limit, such an operation is rejected. This is especially meant to protect bakers against DoS attacks.

val raw_consume : Arith.fp -> cost -> Arith.fp option

Subtracts the cost from the current limit. Returns None if the limit would fall below 0.

val free : cost

The cost of free operation is 0.

val atomic_step_cost : _ Saturation_repr.t -> cost

atomic_step_cost x corresponds to x milliunit of gas.

val step_cost : _ Saturation_repr.t -> cost

step_cost x corresponds to x units of gas.

val alloc_cost : _ Saturation_repr.t -> cost

Cost of allocating qwords of storage.

alloc_cost n estimates the cost of allocating n qwords of storage.

val alloc_bytes_cost : int -> cost

Cost of allocating bytes in the storage.

alloc_bytes_cost b estimates the cost of allocating b bytes of storage.

val alloc_mbytes_cost : int -> cost

Cost of allocating bytes in the storage.

alloc_mbytes_cost b estimates the cost of allocating b bytes of storage and the cost of a header to describe these bytes.

val read_bytes_cost : int -> cost

Cost of reading the storage.

read_bytes_const n estimates the cost of reading n bytes of storage.

val write_bytes_cost : int -> cost

Cost of writing to storage.

write_bytes_const n estimates the cost of writing n bytes to the storage.

val (*@) : _ Saturation_repr.t -> cost -> cost

Multiply a cost by a factor. Both arguments are saturated arithmetic values, so no negative numbers are involved.

val (+@) : cost -> cost -> cost

Add two costs together.

OCaml

Innovation. Community. Security.