Expand description

This crate is the core of the gas metering system of the Aptos blockchain.

More specifically, it

  • Is home to the gas meter implementation
  • Defines the gas parameters and formulae for instructions
  • Defines the gas parameters for transactions
  • Sets the initial values for all gas parameters, including the instruction, transaction move-stdlib and aptos-framework ones.
  • Defines a bi-directional mapping between the (Rust) gas parameter structs and their corresponding representation on-chain.

The reason why we need two different representations is that they serve different purposes:

  • The Rust structs are used for quick (static) lookups by the gas meter and native functions when calculating gas costs.
  • The on-chain gas schedule needs to be extensible and unordered so we can upgrate it easily in the future.

Structs

The official gas meter used inside the Aptos VM. It maintains an internal gas counter, measured in internal gas units, and carries an environment consisting all the gas parameters, which it can lookup when performing gas calcuations.

Gas parameters for everything that is needed to run the Aptos blockchain, including instructions, transactions and native functions from various packages.

Gas parameters for all bytecode instructions.

Gas parameters for all native functions.

Transaction-level gas parameters.

Traits

A trait for converting from a map representation of the on-chain gas schedule.

A trait for defining an initial value to be used in the genesis.

A trait for converting to a list of entries of the on-chain gas schedule.