Struct move_vm_test_utils::gas_schedule::GasStatus
source · [−]pub struct GasStatus<'a> { /* 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.
Implementations
sourceimpl<'a> GasStatus<'a>
impl<'a> GasStatus<'a>
sourcepub fn new(cost_table: &'a CostTable, gas_left: Gas) -> Self
pub fn new(cost_table: &'a CostTable, gas_left: Gas) -> 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.
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)
Trait Implementations
sourceimpl<'b> GasMeter for GasStatus<'b>
impl<'b> GasMeter for GasStatus<'b>
sourcefn 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.
sourcefn charge_native_function(&mut self, amount: InternalGas) -> PartialVMResult<()>
fn charge_native_function(&mut self, amount: InternalGas) -> PartialVMResult<()>
Charge for executing a native function. The cost is calculated returned by the native function implementation. Should fail if not enough gas units are left. Read more
fn charge_call(
&mut self,
_module_id: &ModuleId,
_func_name: &str,
args: impl ExactSizeIterator<Item = impl ValueView>
) -> 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>
) -> PartialVMResult<()>
fn charge_ld_const(&mut self, size: NumBytes) -> 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_read_ref(&mut self, ref_val: impl ValueView) -> PartialVMResult<()>
fn charge_write_ref(&mut self, 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<()>
sourcefn charge_load_resource(
&mut self,
_loaded: Option<NumBytes>
) -> PartialVMResult<()>
fn charge_load_resource(
&mut self,
_loaded: Option<NumBytes>
) -> PartialVMResult<()>
Charges for loading a resource from storage. This is only called when the resource is not cached. Read more
fn charge_borrow_global(
&mut self,
is_mut: bool,
is_generic: bool,
_ty: impl TypeView,
is_success: bool
) -> PartialVMResult<()>
fn charge_exists(
&mut self,
is_generic: bool,
_ty: impl TypeView,
exists: bool
) -> PartialVMResult<()>
fn charge_move_from(
&mut self,
is_generic: bool,
_ty: impl TypeView,
val: Option<impl ValueView>
) -> PartialVMResult<()>
fn charge_move_to(
&mut self,
is_generic: bool,
_ty: impl TypeView,
val: impl ValueView,
is_success: bool
) -> 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
) -> PartialVMResult<()>
fn charge_vec_swap(&mut self, _ty: impl TypeView) -> PartialVMResult<()>
Auto Trait Implementations
impl<'a> RefUnwindSafe for GasStatus<'a>
impl<'a> Send for GasStatus<'a>
impl<'a> Sync for GasStatus<'a>
impl<'a> Unpin for GasStatus<'a>
impl<'a> UnwindSafe for GasStatus<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more