ethereum.vm.gas

Ethereum Virtual Machine (EVM) Gas

Introduction

EVM gas constants and calculators.

Module Contents

Functions

subtract_gas

Subtracts amount from gas_left.

Attributes

GAS_VERY_LOW

GAS_STORAGE_SET

GAS_STORAGE_UPDATE

GAS_STORAGE_CLEAR_REFUND

Module Details

GAS_VERY_LOW

ethereum.vm.gas.GAS_VERY_LOW

GAS_STORAGE_SET

ethereum.vm.gas.GAS_STORAGE_SET

GAS_STORAGE_UPDATE

ethereum.vm.gas.GAS_STORAGE_UPDATE

GAS_STORAGE_CLEAR_REFUND

ethereum.vm.gas.GAS_STORAGE_CLEAR_REFUND

subtract_gas

ethereum.vm.gas.subtract_gas(gas_left: ethereum.base_types.U256, amount: ethereum.base_types.U256)ethereum.base_types.U256

Subtracts amount from gas_left.

Parameters
  • gas_left – The amount of gas left in the current frame.

  • amount – The amount of gas the current operation requires.

Raises

OutOfGasError – If gas_left is less than amount.

def subtract_gas(gas_left: U256, amount: U256) -> U256:
    if gas_left < amount:
        raise OutOfGasError

    return gas_left - amount