Sigil documentation
ReferenceRust referencesigil-execution

sigil-execution · metering

Source declarations, signatures and documentation for metering.

Source: sigil/node/sigil-execution/src/metering.rs. SHA-256: bc5b1011359964f14ee11f72be63a0635280ec30dfd6a631f25af34d65b6e014.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

metering::GasCosts

Gas costs for different ANVIL host function operations and WASM resources.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct GasCosts {
/// Cost per WASM instruction executed.

pub wasm_instruction: u64,
/// Cost per state read (`StateGet`).

pub state_read: u64,
/// Cost per state write (`StateSet`).

pub state_write: u64,
/// Cost per state deletion (`StateDelete`).

pub state_delete: u64,
/// Cost per cross-zone message (`SendMessage`).

pub cross_zone_message: u64,
/// Cost per DID resolution (`ResolveIdentity`).

pub identity_resolve: u64,
/// Cost per lineage verification (`VerifyLineage`).

pub lineage_verify: u64,
/// Cost per byte of log output (`Log`).

pub log_per_byte: u64,
/// Cost per 64KB memory page allocated.

pub memory_page: u64
}

Source line: 14.

metering::GasCosts::cost_for

Compute the gas cost for a specific ANVIL host function call.

pub fn cost_for(&self, op: &AnvilHostFunction) -> u64;

Source line: 53.

metering::FuelMeter

Fuel meter tracking cumulative gas consumption within a single execution.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct FuelMeter {
/// Maximum gas allowed for this execution.

pub gas_limit: u64,
/// Gas consumed so far.

pub gas_used: u64
}

Source line: 73.

metering::FuelMeter::new

Create a new fuel meter with the given gas limit.

pub fn new(gas_limit: u64) -> Self;

Source line: 82.

metering::FuelMeter::consume

Consume amount gas. Returns Err(ExecutionError::OutOfGas) if the limit would be exceeded.

pub fn consume(&mut self, amount: u64) -> Result<(), ExecutionError>;

Source line: 91.

metering::FuelMeter::remaining

Returns the remaining gas budget.

pub fn remaining(&self) -> u64;

Source line: 112.

metering::FuelMeter::is_exhausted

Returns true if the gas budget is fully consumed.

pub fn is_exhausted(&self) -> bool;

Source line: 117.

metering::FuelMeter::charge_operation

Charge gas for a specific ANVIL host function operation using the provided cost table.

pub fn charge_operation(
        &mut self,
        costs: &GasCosts,
        op: &AnvilHostFunction,
    ) -> Result<(), ExecutionError>;

Source line: 123.

On this page