pub struct GasCounter { /* private fields */ }
Expand description

Gas counter (a part of VMlogic)

Implementations§

source§

impl GasCounter

source

pub fn new( ext_costs_config: ExtCostsConfig, max_gas_burnt: Gas, opcode_cost: u32, prepaid_gas: Gas, is_view: bool ) -> Self

source

pub fn burn_gas(&mut self, gas_burnt: Gas) -> Result<(), VMLogicError>

Simpler version of deduct_gas() for when no promises are involved.

Return an error if there are arithmetic overflows.

source

pub fn process_gas_limit( &mut self, new_burnt_gas: Gas, new_used_gas: Gas ) -> HostError

source

pub fn pay_wasm_gas(&mut self, opcodes: u32) -> Result<(), VMLogicError>

source

pub fn gas_counter_raw_ptr(&mut self) -> *mut FastGasCounter

Very special function to get the gas counter pointer for generated machine code. Please do not use, unless fully understand Rust aliasing and other consequences. Can be used to emit inlined code like pay_wasm_gas(), i.e. mov base, gas_counter_raw_ptr mov rax, [base + 0] ; current burnt gas mov rcx, [base + 16] ; opcode cost imul rcx, block_ops_count ; block cost add rax, rcx ; new burnt gas jo emit_integer_overflow cmp rax, [base + 8] ; unsigned compare with burnt limit mov [base + 0], rax ja emit_gas_exceeded

source

pub fn pay_per(&mut self, cost: ExtCosts, num: u64) -> Result<(), VMLogicError>

A helper function to pay a multiple of a cost.

source

pub fn pay_base(&mut self, cost: ExtCosts) -> Result<(), VMLogicError>

A helper function to pay base cost gas.

source

pub fn pay_action_accumulated( &mut self, burn_gas: Gas, use_gas: Gas, action: ActionCosts ) -> Result<(), VMLogicError>

A helper function to pay base cost gas fee for batching an action.

Args:
  • burn_gas: amount of gas to burn;
  • use_gas: amount of gas to reserve;
  • action: what kind of action is charged for;
source

pub fn add_trie_fees( &mut self, count: &TrieNodesCount ) -> Result<(), VMLogicError>

source

pub fn prepay_gas(&mut self, use_gas: Gas) -> Result<(), VMLogicError>

source

pub fn burnt_gas(&self) -> Gas

source

pub fn used_gas(&self) -> Gas

Amount of gas used through promises and amount burned.

source

pub fn unused_gas(&self) -> Gas

Remaining gas based on the amount of prepaid gas not yet used.

source

pub fn profile_data(&self) -> ProfileDataV3

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more