Trait fvm_wasm_instrument::gas_metering::Rules

source ·
pub trait Rules {
    // Required methods
    fn instruction_cost(
        &self,
        instruction: &Operator<'_>,
    ) -> Result<InstructionCost>;
    fn gas_charge_cost(&self) -> u64;
    fn linear_calc_cost(&self) -> u64;
}
Expand description

An interface that describes instruction costs.

Required Methods§

source

fn instruction_cost( &self, instruction: &Operator<'_>, ) -> Result<InstructionCost>

Returns the cost for the passed instruction.

Returning an error can be used as a way to indicate that an instruction is forbidden

source

fn gas_charge_cost(&self) -> u64

Returns cost for each call to the gas charging function

source

fn linear_calc_cost(&self) -> u64

Returns cost of calculating linear cost at runtime. Does not apply to instructions cost of which can be statically determined (linearly priced ops proceded by a const). Added to gas_charge_cost on dynamic charges

Implementors§