Struct iota_types::gas_model::tables::GasStatus
source · pub struct GasStatus {
pub gas_model_version: u64,
/* private fields */
}
Expand description
The Move VM implementation of state for gas metering.
Initialize with a CostTable
and the gas provided to the transaction.
Provide all the proper guarantees about gas metering in the Move VM.
Every client must use an instance of this type to interact with the Move VM.
Fields§
§gas_model_version: u64
Implementations§
source§impl GasStatus
impl GasStatus
sourcepub fn new(
cost_table: CostTable,
budget: u64,
gas_price: u64,
gas_model_version: u64,
) -> Self
pub fn new( cost_table: CostTable, budget: u64, gas_price: u64, gas_model_version: u64, ) -> Self
Initialize the gas state with metering enabled.
Charge for every operation and fail when there is no more gas to pay for operations. This is the instantiation that must be used when executing a user script.
sourcepub fn new_unmetered() -> Self
pub fn new_unmetered() -> Self
Initialize the gas state with metering disabled.
It should be used by clients in very specific cases and when executing system code that does not have to charge the user.
pub fn push_stack(&mut self, pushes: u64) -> PartialVMResult<()>
pub fn pop_stack(&mut self, pops: u64)
pub fn increase_instruction_count(&mut self, amount: u64) -> PartialVMResult<()>
pub fn increase_stack_size(&mut self, size_amount: u64) -> PartialVMResult<()>
pub fn decrease_stack_size(&mut self, size_amount: u64)
sourcepub fn charge(
&mut self,
num_instructions: u64,
pushes: u64,
pops: u64,
incr_size: u64,
_decr_size: u64,
) -> PartialVMResult<()>
pub fn charge( &mut self, num_instructions: u64, pushes: u64, pops: u64, incr_size: u64, _decr_size: u64, ) -> PartialVMResult<()>
Given: pushes + pops + increase + decrease in size for an instruction charge for the execution of the instruction.
sourcepub fn cost_table(&self) -> &CostTable
pub fn cost_table(&self) -> &CostTable
Return the CostTable
behind this GasStatus
.
sourcepub fn remaining_gas(&self) -> Gas
pub fn remaining_gas(&self) -> Gas
Return the gas left.
sourcepub fn deduct_gas(&mut self, amount: InternalGas) -> PartialVMResult<()>
pub fn deduct_gas(&mut self, amount: InternalGas) -> PartialVMResult<()>
Charge a given amount of gas and fail if not enough gas units are left.
pub fn set_metering(&mut self, enabled: bool)
pub fn gas_used_pre_gas_price(&self) -> u64
pub fn charge_bytes( &mut self, size: usize, cost_per_byte: u64, ) -> PartialVMResult<()>
pub fn gas_price(&self) -> u64
pub fn stack_height_high_water_mark(&self) -> u64
pub fn stack_size_high_water_mark(&self) -> u64
pub fn instructions_executed(&self) -> u64
Trait Implementations§
source§impl GasMeter for GasStatus
impl GasMeter for GasStatus
source§fn charge_simple_instr(
&mut self,
instr: SimpleInstruction,
) -> PartialVMResult<()>
fn charge_simple_instr( &mut self, instr: SimpleInstruction, ) -> PartialVMResult<()>
Charge an instruction and fail if not enough gas units are left.
fn charge_pop(&mut self, popped_val: impl ValueView) -> PartialVMResult<()>
fn charge_native_function( &mut self, amount: InternalGas, ret_vals: Option<impl ExactSizeIterator<Item = impl ValueView>>, ) -> PartialVMResult<()>
fn charge_native_function_before_execution( &mut self, _ty_args: impl ExactSizeIterator<Item = impl TypeView>, args: impl ExactSizeIterator<Item = impl ValueView>, ) -> PartialVMResult<()>
fn charge_call( &mut self, _module_id: &ModuleId, _func_name: &str, args: impl ExactSizeIterator<Item = impl ValueView>, _num_locals: NumArgs, ) -> PartialVMResult<()>
fn charge_call_generic( &mut self, _module_id: &ModuleId, _func_name: &str, _ty_args: impl ExactSizeIterator<Item = impl TypeView>, args: impl ExactSizeIterator<Item = impl ValueView>, _num_locals: NumArgs, ) -> PartialVMResult<()>
fn charge_ld_const(&mut self, size: NumBytes) -> PartialVMResult<()>
fn charge_ld_const_after_deserialization( &mut self, _val: impl ValueView, ) -> PartialVMResult<()>
fn charge_copy_loc(&mut self, val: impl ValueView) -> PartialVMResult<()>
fn charge_move_loc(&mut self, val: impl ValueView) -> PartialVMResult<()>
fn charge_store_loc(&mut self, val: impl ValueView) -> PartialVMResult<()>
fn charge_pack( &mut self, _is_generic: bool, args: impl ExactSizeIterator<Item = impl ValueView>, ) -> PartialVMResult<()>
fn charge_unpack( &mut self, _is_generic: bool, args: impl ExactSizeIterator<Item = impl ValueView>, ) -> PartialVMResult<()>
fn charge_variant_switch(&mut self, val: impl ValueView) -> PartialVMResult<()>
fn charge_read_ref(&mut self, ref_val: impl ValueView) -> PartialVMResult<()>
fn charge_write_ref( &mut self, new_val: impl ValueView, old_val: impl ValueView, ) -> PartialVMResult<()>
fn charge_eq( &mut self, lhs: impl ValueView, rhs: impl ValueView, ) -> PartialVMResult<()>
fn charge_neq( &mut self, lhs: impl ValueView, rhs: impl ValueView, ) -> PartialVMResult<()>
fn charge_vec_pack<'a>( &mut self, _ty: impl TypeView + 'a, args: impl ExactSizeIterator<Item = impl ValueView>, ) -> PartialVMResult<()>
fn charge_vec_len(&mut self, _ty: impl TypeView) -> PartialVMResult<()>
fn charge_vec_borrow( &mut self, _is_mut: bool, _ty: impl TypeView, _is_success: bool, ) -> PartialVMResult<()>
fn charge_vec_push_back( &mut self, _ty: impl TypeView, _val: impl ValueView, ) -> PartialVMResult<()>
fn charge_vec_pop_back( &mut self, _ty: impl TypeView, _val: Option<impl ValueView>, ) -> PartialVMResult<()>
fn charge_vec_unpack( &mut self, _ty: impl TypeView, expect_num_elements: NumArgs, _elems: impl ExactSizeIterator<Item = impl ValueView>, ) -> PartialVMResult<()>
fn charge_vec_swap(&mut self, _ty: impl TypeView) -> PartialVMResult<()>
fn charge_drop_frame( &mut self, _locals: impl Iterator<Item = impl ValueView>, ) -> PartialVMResult<()>
source§fn remaining_gas(&self) -> InternalGas
fn remaining_gas(&self) -> InternalGas
fn get_profiler_mut(&mut self) -> Option<&mut GasProfiler>
fn set_profiler(&mut self, profiler: GasProfiler)
Auto Trait Implementations§
impl Freeze for GasStatus
impl RefUnwindSafe for GasStatus
impl Send for GasStatus
impl Sync for GasStatus
impl Unpin for GasStatus
impl UnwindSafe for GasStatus
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self
to type T
. The semantics of numeric casting with the as
operator are followed, so <T as As>::as_::<U>
can be used in the same way as T as U
for numeric conversions. Read more§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> ConvertTo<T> for Twhere
T: Send,
impl<T> ConvertTo<T> for Twhere
T: Send,
fn convert(self) -> Result<T, Error>
fn convert_unchecked(self) -> T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a Request
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.