Module gas

Source
Expand description

Gas calculation utilities and constants. EVM gas calculation utilities.

Structs§

Gas
Represents the state of gas during execution.
InitialAndFloorGas
Init and floor gas from transaction
MemoryGas
Utility struct that speeds up calculation of memory expansion It contains the current memory length and its memory expansion cost.

Enums§

MemoryExtensionResult
Result of attempting to extend memory during execution.

Constants§

ACCESS_LIST_ADDRESS
Gas cost for accessing an address in the access list (EIP-2929).
ACCESS_LIST_STORAGE_KEY
Gas cost for accessing a storage key in the access list (EIP-2929).
BASE
Base gas cost for basic operations.
BLOCKHASH
Gas cost for BLOCKHASH instruction.
CALLVALUE
Additional gas cost when a call transfers value.
CALL_STIPEND
Gas stipend provided to the recipient of a CALL with value transfer.
CODEDEPOSIT
Gas cost per byte for code deposit during contract creation.
COLD_ACCOUNT_ACCESS_COST
Gas cost for accessing a cold account (EIP-2929).
COLD_SLOAD_COST
Gas cost for SLOAD when accessing a cold storage slot (EIP-2929).
CONDITION_JUMP_GAS
Gas cost for conditional jump instructions.
COPY
Gas cost per word for copy operations.
CREATE
Gas cost for CREATE instruction.
DATA_LOADN_GAS
Gas cost for DATALOADN instruction.
DATA_LOAD_GAS
Gas cost for DATALOAD instruction.
EOF_CREATE_GAS
Gas cost for EOF CREATE instruction.
EXP
Base gas cost for EXP instruction.
HIGH
Gas cost for high-cost operations.
INITCODE_WORD_COST
EIP-3860 : Limit and meter initcode
ISTANBUL_SLOAD_GAS
EIP-1884: Repricing for trie-size-dependent opcodes
JUMPDEST
Gas cost for JUMPDEST instruction.
KECCAK256
Base gas cost for KECCAK256 instruction.
KECCAK256WORD
Gas cost per word for KECCAK256 instruction.
LOG
Base gas cost for LOG instructions.
LOGDATA
Gas cost per byte of data in LOG instructions.
LOGTOPIC
Gas cost per topic in LOG instructions.
LOW
Gas cost for low-cost operations.
MEMORY
Gas cost per word for memory operations.
MID
Gas cost for medium-cost operations.
MIN_CALLEE_GAS
Minimum gas that must be provided to a callee.
NEWACCOUNT
Gas cost for creating a new account.
NON_ZERO_BYTE_DATA_COST
The cost of a non-zero byte in calldata.
NON_ZERO_BYTE_DATA_COST_ISTANBUL
The cost of a non-zero byte in calldata adjusted by EIP-2028.
NON_ZERO_BYTE_MULTIPLIER
The multiplier for a non zero byte in calldata.
NON_ZERO_BYTE_MULTIPLIER_ISTANBUL
The multiplier for a non zero byte in calldata adjusted by EIP-2028.
REFUND_SSTORE_CLEARS
Gas refund for SSTORE when clearing a storage slot (setting to zero).
RETF_GAS
Gas cost for RETF instruction.
SELFDESTRUCT
Gas cost for SELFDESTRUCT instruction.
SSTORE_RESET
Gas cost for SSTORE when modifying an existing non-zero storage slot.
SSTORE_SET
Gas cost for SSTORE when setting a storage slot from zero to non-zero.
STANDARD_TOKEN_COST
The standard cost of calldata token.
TOTAL_COST_FLOOR_PER_TOKEN
The cost floor per token as defined by EIP-2028.
VERYLOW
Gas cost for very low-cost operations.
WARM_SSTORE_RESET
Gas cost for SSTORE reset operation on a warm storage slot.
WARM_STORAGE_READ_COST
Gas cost for reading from a warm storage slot (EIP-2929).
ZERO
Gas cost for operations that consume zero gas.

Functions§

calc_tx_floor_cost
Calculate the transaction cost floor as specified in EIP-7623.
calculate_initial_tx_gas
Initial gas that is deducted for transaction to be included. Initial gas contains initial stipend gas, gas for access list and input data.
calculate_initial_tx_gas_for_tx
Initial gas that is deducted for transaction to be included. Initial gas contains initial stipend gas, gas for access list and input data.
call_cost
Calculate call gas cost for the call instruction.
copy_cost
Calculates the gas cost for copy operations based on data length.
copy_cost_verylow
*COPY opcodes cost calculation.
cost_per_word
Calculate the cost of buffer per word.
create2_cost
CREATE2 opcode cost calculation.
exp_cost
EXP opcode cost calculation.
extcodecopy_cost
EXTCODECOPY opcode cost calculation.
get_tokens_in_calldata
Retrieve the total number of tokens in calldata.
initcode_cost
EIP-3860: Limit and meter initcode
keccak256_cost
KECCAK256 opcode cost calculation.
log_cost
LOG opcode cost calculation.
memory_gas
Memory expansion cost calculation for a given number of words.
selfdestruct_cost
SELFDESTRUCT opcode cost calculation.
sload_cost
SLOAD opcode cost calculation.
sstore_cost
SSTORE opcode cost calculation.
sstore_refund
SSTORE opcode refund calculation.
warm_cold_cost
Berlin warm and cold storage access cost for account access.
warm_cold_cost_with_delegation
Berlin warm and cold storage access cost for account access.