soroban_env_host::budget

Struct Budget

Source
pub struct Budget(/* private fields */);

Implementations§

Source§

impl Budget

Source

pub fn reset_models(&self) -> Result<(), HostError>

Source

pub fn get_wasm_mem_alloc(&self) -> Result<u64, HostError>

Source

pub fn reset_unlimited(&self) -> Result<(), HostError>

Source

pub fn reset_unlimited_cpu(&self) -> Result<(), HostError>

Source

pub fn reset_unlimited_mem(&self) -> Result<(), HostError>

Source

pub fn cpu_limit_exceeded(&self) -> Result<bool, HostError>

Source

pub fn mem_limit_exceeded(&self) -> Result<bool, HostError>

Source

pub fn reset_tracker(&self) -> Result<(), HostError>

Source

pub fn reset(&self) -> Result<(), HostError>

Source

pub fn reset_cpu_limit(&self, cpu: u64) -> Result<(), HostError>

Source

pub fn reset_limits(&self, cpu: u64, mem: u64) -> Result<(), HostError>

Source

pub fn reset_fuel_config(&self) -> Result<(), HostError>

Resets the FuelConfig we pass into Wasmi before running calibration. Wasmi instruction calibration requires running the same Wasmi insn a fixed number of times, record their actual cpu and mem consumption, then divide those numbers by the number of iterations, which is the fuel count. Fuel count is kept tracked on the Wasmi side, based on the FuelConfig of a specific fuel category. In order to get the correct, unscaled fuel count, we have to preset all the FuelConfig entries to 1.

Source

pub fn get_shadow_cpu_insns_consumed(&self) -> Result<u64, HostError>

Source

pub fn get_shadow_mem_bytes_consumed(&self) -> Result<u64, HostError>

Source

pub fn shadow_cpu_limit_exceeded(&self) -> Result<bool, HostError>

Source

pub fn shadow_mem_limit_exceeded(&self) -> Result<bool, HostError>

Source§

impl Budget

Source

pub fn try_from_configs( cpu_limit: u64, mem_limit: u64, cpu_cost_params: ContractCostParams, mem_cost_params: ContractCostParams, ) -> Result<Self, HostError>

Initializes the budget from network configuration settings.

Source

pub fn bulk_charge( &self, ty: ContractCostType, iterations: u64, input: Option<u64>, ) -> Result<(), HostError>

Performs a bulk charge to the budget under the specified [CostType]. The iterations is the batch size. The caller needs to ensure:

  1. the batched charges have identical costs (having the same [CostType] and input)
  2. The input passed in (Some/None) is consistent with the [CostModel] underneath the [CostType] (linear/constant).
Source

pub fn charge( &self, ty: ContractCostType, input: Option<u64>, ) -> Result<(), HostError>

Charges the budget under the specified [CostType]. The actual amount charged is determined by the underlying [CostModel] and may depend on the input. If the input is None, the model is assumed to be constant. Otherwise it is a linear model. The caller needs to ensure the input passed is consistent with the inherent model underneath.

Source

pub fn get_tracker( &self, ty: ContractCostType, ) -> Result<CostTracker, HostError>

Source

pub fn get_time(&self, ty: ContractCostType) -> Result<u64, HostError>

Source

pub fn track_time( &self, ty: ContractCostType, duration: u64, ) -> Result<(), HostError>

Source

pub fn get_cpu_insns_consumed(&self) -> Result<u64, HostError>

Source

pub fn get_mem_bytes_consumed(&self) -> Result<u64, HostError>

Source

pub fn get_cpu_insns_remaining(&self) -> Result<u64, HostError>

Source

pub fn get_mem_bytes_remaining(&self) -> Result<u64, HostError>

Source

pub fn reset_default(&self) -> Result<(), HostError>

Trait Implementations§

Source§

impl AsBudget for &Budget

Source§

impl AsBudget for Budget

Source§

impl Clone for Budget

Source§

fn clone(&self) -> Budget

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Compare<&[u8]> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &&[u8], b: &&[u8]) -> Result<Ordering, Self::Error>

Source§

impl<const N: usize> Compare<[u8; N]> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &[u8; N], b: &[u8; N]) -> Result<Ordering, Self::Error>

Source§

impl Compare<AccountId> for Budget

Source§

impl Compare<ContractDataDurability> for Budget

Source§

impl Compare<ContractExecutable> for Budget

Source§

impl Compare<CreateContractArgs> for Budget

Source§

impl Compare<CreateContractArgsV2> for Budget

Source§

impl Compare<Duration> for Budget

Source§

impl Compare<Hash> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &Hash, b: &Hash) -> Result<Ordering, Self::Error>

Source§

impl Compare<I256> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &I256, b: &I256) -> Result<Ordering, Self::Error>

Source§

impl Compare<Int128Parts> for Budget

Source§

impl Compare<Int256Parts> for Budget

Source§

impl Compare<LedgerKey> for Budget

Source§

impl Compare<LedgerKeyAccount> for Budget

Source§

impl Compare<LedgerKeyContractCode> for Budget

Source§

impl Compare<LedgerKeyContractData> for Budget

Source§

impl Compare<LedgerKeyTrustLine> for Budget

Source§

impl<K, V> Compare<MeteredOrdMap<K, V, Budget>> for Budget
where K: DeclaredSizeForMetering, V: DeclaredSizeForMetering, Budget: Compare<K, Error = HostError> + Compare<V, Error = HostError>,

Source§

type Error = HostError

Source§

fn compare( &self, a: &MeteredOrdMap<K, V, Budget>, b: &MeteredOrdMap<K, V, Budget>, ) -> Result<Ordering, Self::Error>

Source§

impl<Elt: MeteredClone> Compare<MeteredVector<Elt>> for Budget
where Budget: Compare<Elt, Error = HostError>,

Source§

type Error = HostError

Source§

fn compare( &self, a: &MeteredVector<Elt>, b: &MeteredVector<Elt>, ) -> Result<Ordering, Self::Error>

Source§

impl Compare<PublicKey> for Budget

Source§

impl Compare<ScAddress> for Budget

Source§

impl Compare<ScContractInstance> for Budget

Source§

impl Compare<ScError> for Budget

Source§

impl Compare<ScMap> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &ScMap, b: &ScMap) -> Result<Ordering, Self::Error>

Source§

impl Compare<ScMapEntry> for Budget

Source§

impl Compare<ScNonceKey> for Budget

Source§

impl Compare<ScVal> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &ScVal, b: &ScVal) -> Result<Ordering, Self::Error>

Source§

impl Compare<ScVec> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &ScVec, b: &ScVec) -> Result<Ordering, Self::Error>

Source§

impl Compare<SymbolStr> for Budget

Source§

impl Compare<TimePoint> for Budget

Source§

impl Compare<TrustLineAsset> for Budget

Source§

impl Compare<U256> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &U256, b: &U256) -> Result<Ordering, Self::Error>

Source§

impl Compare<UInt128Parts> for Budget

Source§

impl Compare<UInt256Parts> for Budget

Source§

impl Compare<Uint256> for Budget

Source§

impl Compare<bool> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &bool, b: &bool) -> Result<Ordering, Self::Error>

Source§

impl Compare<i128> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &i128, b: &i128) -> Result<Ordering, Self::Error>

Source§

impl Compare<i32> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &i32, b: &i32) -> Result<Ordering, Self::Error>

Source§

impl Compare<i64> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &i64, b: &i64) -> Result<Ordering, Self::Error>

Source§

impl Compare<u128> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &u128, b: &u128) -> Result<Ordering, Self::Error>

Source§

impl Compare<u32> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &u32, b: &u32) -> Result<Ordering, Self::Error>

Source§

impl Compare<u64> for Budget

Source§

type Error = HostError

Source§

fn compare(&self, a: &u64, b: &u64) -> Result<Ordering, Self::Error>

Source§

impl Debug for Budget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Budget

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Budget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Budget

§

impl !RefUnwindSafe for Budget

§

impl !Send for Budget

§

impl !Sync for Budget

§

impl Unpin for Budget

§

impl !UnwindSafe for Budget

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T, C> Compare<&T> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare(&self, a: &&T, b: &&T) -> Result<Ordering, <C as Compare<&T>>::Error>

Source§

impl<T, U, E, C> Compare<(T, U)> for C
where C: Compare<T, Error = E, Error = E> + Compare<U>,

Source§

type Error = E

Source§

fn compare( &self, a: &(T, U), b: &(T, U), ) -> Result<Ordering, <C as Compare<(T, U)>>::Error>

Source§

impl<T, U, V, E, C> Compare<(T, U, V)> for C
where C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,

Source§

impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
where C: Compare<T, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W>,

Source§

impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
where C: Compare<T, Error = E, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W> + Compare<X>,

Source§

impl<T, C> Compare<Box<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Box<T>, b: &Box<T>, ) -> Result<Ordering, <C as Compare<Box<T>>>::Error>

Source§

impl<T, C> Compare<Option<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Option<T>, b: &Option<T>, ) -> Result<Ordering, <C as Compare<Option<T>>>::Error>

Source§

impl<T, C> Compare<Rc<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Rc<T>, b: &Rc<T>, ) -> Result<Ordering, <C as Compare<Rc<T>>>::Error>

Source§

impl<T, C> Compare<Vec<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Vec<T>, b: &Vec<T>, ) -> Result<Ordering, <C as Compare<Vec<T>>>::Error>

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<E, T, U> TryIntoVal<E, T> for U
where E: Env, T: TryFromVal<E, U>,

Source§

type Error = <T as TryFromVal<E, U>>::Error

Source§

fn try_into_val(&self, env: &E) -> Result<T, <U as TryIntoVal<E, T>>::Error>

Source§

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

Source§

fn vzip(self) -> V