pub struct Runtime<'a, R> { /* private fields */ }
Expand description
Represents the runtime properties of a WASM execution.
Implementations§
Source§impl<'a, R> Runtime<'a, R>
impl<'a, R> Runtime<'a, R>
Sourcepub fn call_package_version_with_stack(
&mut self,
contract_package_hash: PackageHash,
protocol_version_major: Option<ProtocolVersionMajor>,
version: Option<EntityVersion>,
entry_point_name: String,
args: RuntimeArgs,
stack: RuntimeStack,
) -> Result<CLValue, ExecError>
pub fn call_package_version_with_stack( &mut self, contract_package_hash: PackageHash, protocol_version_major: Option<ProtocolVersionMajor>, version: Option<EntityVersion>, entry_point_name: String, args: RuntimeArgs, stack: RuntimeStack, ) -> Result<CLValue, ExecError>
Call a version within a package by pushing a stack element onto the frame.
Sourcepub fn call_contract(
&mut self,
contract_hash: AddressableEntityHash,
entry_point_name: &str,
args: RuntimeArgs,
) -> Result<CLValue, ExecError>
pub fn call_contract( &mut self, contract_hash: AddressableEntityHash, entry_point_name: &str, args: RuntimeArgs, ) -> Result<CLValue, ExecError>
Calls contract living under a key
, with supplied args
.
Sourcepub fn call_versioned_contract(
&mut self,
contract_package_hash: PackageHash,
contract_version: Option<EntityVersion>,
entry_point_name: String,
args: RuntimeArgs,
) -> Result<CLValue, ExecError>
pub fn call_versioned_contract( &mut self, contract_package_hash: PackageHash, contract_version: Option<EntityVersion>, entry_point_name: String, args: RuntimeArgs, ) -> Result<CLValue, ExecError>
Calls version
of the contract living at key
, invoking method
with
supplied args
. This function also checks the args conform with the
types given in the contract header.
Sourcepub fn call_package_version(
&mut self,
contract_package_hash: PackageHash,
protocol_version_major: Option<ProtocolVersionMajor>,
version: Option<EntityVersion>,
entry_point_name: String,
args: RuntimeArgs,
) -> Result<CLValue, ExecError>
pub fn call_package_version( &mut self, contract_package_hash: PackageHash, protocol_version_major: Option<ProtocolVersionMajor>, version: Option<EntityVersion>, entry_point_name: String, args: RuntimeArgs, ) -> Result<CLValue, ExecError>
Calls version
of the contract living at key
, invoking method
with
supplied args
. This function also checks the args conform with the
types given in the contract header.
Sourcepub fn take_host_buffer(&mut self) -> Option<CLValue>
pub fn take_host_buffer(&mut self) -> Option<CLValue>
If host_buffer set, clears the host_buffer and returns value, else None
Trait Implementations§
Source§impl<R> AccountProvider for Runtime<'_, R>
impl<R> AccountProvider for Runtime<'_, R>
Source§fn set_main_purse(&mut self, purse: URef)
fn set_main_purse(&mut self, purse: URef)
Set main purse.
Source§impl<R> Auction for Runtime<'_, R>
impl<R> Auction for Runtime<'_, R>
Source§fn get_era_validators(
&mut self,
) -> Result<BTreeMap<EraId, BTreeMap<PublicKey, U512>>, Error>
fn get_era_validators( &mut self, ) -> Result<BTreeMap<EraId, BTreeMap<PublicKey, U512>>, Error>
Source§fn read_seigniorage_recipients(
&mut self,
) -> Result<BTreeMap<PublicKey, SeigniorageRecipientV2>, Error>
fn read_seigniorage_recipients( &mut self, ) -> Result<BTreeMap<PublicKey, SeigniorageRecipientV2>, Error>
Source§fn add_bid(
&mut self,
public_key: PublicKey,
delegation_rate: u8,
amount: U512,
minimum_delegation_amount: u64,
maximum_delegation_amount: u64,
minimum_bid_amount: u64,
max_delegators_per_validator: u32,
reserved_slots: u32,
) -> Result<U512, ApiError>
fn add_bid( &mut self, public_key: PublicKey, delegation_rate: u8, amount: U512, minimum_delegation_amount: u64, maximum_delegation_amount: u64, minimum_bid_amount: u64, max_delegators_per_validator: u32, reserved_slots: u32, ) -> Result<U512, ApiError>
Key::Bid
section of the global state and
creates (or tops off) a bid purse. Post genesis, any new call on this entry point causes a
non-founding validator in the system to exist. Read moreSource§fn withdraw_bid(
&mut self,
public_key: PublicKey,
amount: U512,
minimum_bid_amount: u64,
) -> Result<U512, Error>
fn withdraw_bid( &mut self, public_key: PublicKey, amount: U512, minimum_bid_amount: u64, ) -> Result<U512, Error>
Source§fn delegate(
&mut self,
delegator_kind: DelegatorKind,
validator_public_key: PublicKey,
amount: U512,
max_delegators_per_validator: u32,
) -> Result<U512, ApiError>
fn delegate( &mut self, delegator_kind: DelegatorKind, validator_public_key: PublicKey, amount: U512, max_delegators_per_validator: u32, ) -> Result<U512, ApiError>
Source§fn undelegate(
&mut self,
delegator_kind: DelegatorKind,
validator_public_key: PublicKey,
amount: U512,
) -> Result<U512, Error>
fn undelegate( &mut self, delegator_kind: DelegatorKind, validator_public_key: PublicKey, amount: U512, ) -> Result<U512, Error>
Source§fn redelegate(
&mut self,
delegator_kind: DelegatorKind,
validator_public_key: PublicKey,
amount: U512,
new_validator: PublicKey,
) -> Result<U512, Error>
fn redelegate( &mut self, delegator_kind: DelegatorKind, validator_public_key: PublicKey, amount: U512, new_validator: PublicKey, ) -> Result<U512, Error>
Source§fn add_reservations(
&mut self,
reservations: Vec<Reservation>,
) -> Result<(), Error>
fn add_reservations( &mut self, reservations: Vec<Reservation>, ) -> Result<(), Error>
Source§fn cancel_reservations(
&mut self,
validator: PublicKey,
delegators: Vec<DelegatorKind>,
max_delegators_per_validator: u32,
) -> Result<(), Error>
fn cancel_reservations( &mut self, validator: PublicKey, delegators: Vec<DelegatorKind>, max_delegators_per_validator: u32, ) -> Result<(), Error>
Source§fn slash(&mut self, validator_public_keys: Vec<PublicKey>) -> Result<(), Error>
fn slash(&mut self, validator_public_keys: Vec<PublicKey>) -> Result<(), Error>
Source§fn run_auction(
&mut self,
era_end_timestamp_millis: u64,
evicted_validators: Vec<PublicKey>,
max_delegators_per_validator: u32,
include_credits: bool,
credit_cap: Ratio<U512>,
minimum_bid_amount: u64,
) -> Result<(), ApiError>
fn run_auction( &mut self, era_end_timestamp_millis: u64, evicted_validators: Vec<PublicKey>, max_delegators_per_validator: u32, include_credits: bool, credit_cap: Ratio<U512>, minimum_bid_amount: u64, ) -> Result<(), ApiError>
Source§fn distribute(
&mut self,
rewards: BTreeMap<PublicKey, Vec<U512>>,
) -> Result<(), Error>
fn distribute( &mut self, rewards: BTreeMap<PublicKey, Vec<U512>>, ) -> Result<(), Error>
reward_factors
returned by the consensus component.Source§fn activate_bid(
&mut self,
validator: PublicKey,
minimum_bid: u64,
) -> Result<(), Error>
fn activate_bid( &mut self, validator: PublicKey, minimum_bid: u64, ) -> Result<(), Error>
Source§impl<R> Externals for Runtime<'_, R>
impl<R> Externals for Runtime<'_, R>
Source§fn invoke_index(
&mut self,
index: usize,
args: RuntimeArgs<'_>,
) -> Result<Option<RuntimeValue>, Trap>
fn invoke_index( &mut self, index: usize, args: RuntimeArgs<'_>, ) -> Result<Option<RuntimeValue>, Trap>
index
.Source§impl<R> HandlePayment for Runtime<'_, R>
impl<R> HandlePayment for Runtime<'_, R>
Source§fn calculate_overpayment_and_fee(
&mut self,
limit: U512,
gas_price: u8,
cost: U512,
consumed: U512,
source_purse: URef,
refund_ratio: Ratio<U512>,
) -> Result<(U512, U512), Error>
fn calculate_overpayment_and_fee( &mut self, limit: U512, gas_price: u8, cost: U512, consumed: U512, source_purse: URef, refund_ratio: Ratio<U512>, ) -> Result<(U512, U512), Error>
Source§impl<R> Mint for Runtime<'_, R>
impl<R> Mint for Runtime<'_, R>
Source§fn mint(&mut self, initial_balance: U512) -> Result<URef, Error>
fn mint(&mut self, initial_balance: U512) -> Result<URef, Error>
initial_balance
balance. Returns new purse on success, otherwise
an error.Source§fn reduce_total_supply(&mut self, amount: U512) -> Result<(), Error>
fn reduce_total_supply(&mut self, amount: U512) -> Result<(), Error>
amount
. Returns unit on success, otherwise
an error.Source§fn balance(&mut self, purse: URef) -> Result<Option<U512>, Error>
fn balance(&mut self, purse: URef) -> Result<Option<U512>, Error>
purse
.Source§impl<R> MintProvider for Runtime<'_, R>
impl<R> MintProvider for Runtime<'_, R>
Source§fn mint_transfer_direct(
&mut self,
to: Option<AccountHash>,
source: URef,
target: URef,
amount: U512,
id: Option<u64>,
) -> Result<Result<(), Error>, Error>
fn mint_transfer_direct( &mut self, to: Option<AccountHash>, source: URef, target: URef, amount: U512, id: Option<u64>, ) -> Result<Result<(), Error>, Error>
Allows optimized auction and mint interaction. Intended to be used only by system contracts to manage staked purses. NOTE: Never expose this through FFI.
Source§fn unbond(
&mut self,
unbond_kind: &UnbondKind,
unbond_era: &UnbondEra,
) -> Result<(), Error>
fn unbond( &mut self, unbond_kind: &UnbondKind, unbond_era: &UnbondEra, ) -> Result<(), Error>
Source§fn mint_into_existing_purse(
&mut self,
amount: U512,
existing_purse: URef,
) -> Result<(), Error>
fn mint_into_existing_purse( &mut self, amount: U512, existing_purse: URef, ) -> Result<(), Error>
amount
new token into existing_purse
.
Returns unit on success, otherwise an error.Source§fn available_balance(&mut self, purse: URef) -> Result<Option<U512>, Error>
fn available_balance(&mut self, purse: URef) -> Result<Option<U512>, Error>
Source§impl<R> MintProvider for Runtime<'_, R>
impl<R> MintProvider for Runtime<'_, R>
Source§fn transfer_purse_to_account(
&mut self,
source: URef,
target: AccountHash,
amount: U512,
) -> Result<TransferredTo, Error>
fn transfer_purse_to_account( &mut self, source: URef, target: AccountHash, amount: U512, ) -> Result<TransferredTo, Error>
amount
from source
purse to a target
account.
Note: the source should always be a system purse of some kind,
such as the payment purse or an accumulator purse.
The target should be the recipient of a refund or a rewardSource§fn transfer_purse_to_purse(
&mut self,
source: URef,
target: URef,
amount: U512,
) -> Result<(), Error>
fn transfer_purse_to_purse( &mut self, source: URef, target: URef, amount: U512, ) -> Result<(), Error>
amount
from source
purse to a target
purse.
Note: the source should always be a system purse of some kind,
such as the payment purse or an accumulator purse.
The target should be the recipient of a refund or a rewardSource§impl<R> RuntimeProvider for Runtime<'_, R>
impl<R> RuntimeProvider for Runtime<'_, R>
Source§fn get_caller(&self) -> AccountHash
fn get_caller(&self) -> AccountHash
Source§fn is_allowed_session_caller(&self, account_hash: &AccountHash) -> bool
fn is_allowed_session_caller(&self, account_hash: &AccountHash) -> bool
Source§fn is_valid_uref(&self, uref: URef) -> bool
fn is_valid_uref(&self, uref: URef) -> bool
Source§fn get_keys(&mut self, key_tag: &KeyTag) -> Result<BTreeSet<Key>, Error>
fn get_keys(&mut self, key_tag: &KeyTag) -> Result<BTreeSet<Key>, Error>
Source§fn get_keys_by_prefix(&mut self, prefix: &[u8]) -> Result<Vec<Key>, Error>
fn get_keys_by_prefix(&mut self, prefix: &[u8]) -> Result<Vec<Key>, Error>
Source§fn delegator_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
fn delegator_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
Source§fn reservation_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
fn reservation_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
Source§fn used_reservation_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
fn used_reservation_count(&mut self, bid_addr: &BidAddr) -> Result<usize, Error>
Source§fn vesting_schedule_period_millis(&self) -> u64
fn vesting_schedule_period_millis(&self) -> u64
Source§fn allow_auction_bids(&self) -> bool
fn allow_auction_bids(&self) -> bool
Source§fn should_compute_rewards(&self) -> bool
fn should_compute_rewards(&self) -> bool
Source§impl<R> RuntimeProvider for Runtime<'_, R>
impl<R> RuntimeProvider for Runtime<'_, R>
Source§fn get_caller(&self) -> AccountHash
fn get_caller(&self) -> AccountHash
Source§fn refund_handling(&self) -> RefundHandling
fn refund_handling(&self) -> RefundHandling
Source§fn fee_handling(&self) -> FeeHandling
fn fee_handling(&self) -> FeeHandling
Source§fn administrative_accounts(&self) -> BTreeSet<AccountHash>
fn administrative_accounts(&self) -> BTreeSet<AccountHash>
Source§impl<R> RuntimeProvider for Runtime<'_, R>
impl<R> RuntimeProvider for Runtime<'_, R>
Source§fn is_valid_uref(&self, uref: &URef) -> bool
fn is_valid_uref(&self, uref: &URef) -> bool
Validate URef against context access rights.
Source§fn get_caller(&self) -> AccountHash
fn get_caller(&self) -> AccountHash
Source§fn get_immediate_caller(&self) -> Option<Caller>
fn get_immediate_caller(&self) -> Option<Caller>
Source§fn is_called_from_standard_payment(&self) -> bool
fn is_called_from_standard_payment(&self) -> bool
Source§fn get_system_entity_registry(
&self,
) -> Result<SystemHashRegistry, ProviderError>
fn get_system_entity_registry( &self, ) -> Result<SystemHashRegistry, ProviderError>
Source§fn runtime_footprint_by_account_hash(
&mut self,
account_hash: AccountHash,
) -> Result<Option<RuntimeFootprint>, ProviderError>
fn runtime_footprint_by_account_hash( &mut self, account_hash: AccountHash, ) -> Result<Option<RuntimeFootprint>, ProviderError>
Source§fn get_key(&self, name: &str) -> Option<Key>
fn get_key(&self, name: &str) -> Option<Key>
Key
under a name
.Source§fn get_approved_spending_limit(&self) -> U512
fn get_approved_spending_limit(&self) -> U512
Source§fn sub_approved_spending_limit(&mut self, transferred: U512)
fn sub_approved_spending_limit(&mut self, transferred: U512)
amount
of tokens has been transferred.Source§fn get_main_purse(&self) -> Option<URef>
fn get_main_purse(&self) -> Option<URef>
Source§fn is_administrator(&self, account_hash: &AccountHash) -> bool
fn is_administrator(&self, account_hash: &AccountHash) -> bool
true
if the account hash belongs to an administrator account, otherwise false
.Source§fn allow_unrestricted_transfers(&self) -> bool
fn allow_unrestricted_transfers(&self) -> bool
Source§impl<R> StorageProvider for Runtime<'_, R>
impl<R> StorageProvider for Runtime<'_, R>
Source§fn read<T: FromBytes + CLTyped>(
&mut self,
uref: URef,
) -> Result<Option<T>, Error>
fn read<T: FromBytes + CLTyped>( &mut self, uref: URef, ) -> Result<Option<T>, Error>
URef
.Source§fn write<T: ToBytes + CLTyped>(
&mut self,
uref: URef,
value: T,
) -> Result<(), Error>
fn write<T: ToBytes + CLTyped>( &mut self, uref: URef, value: T, ) -> Result<(), Error>
Source§fn read_bid(&mut self, key: &Key) -> Result<Option<BidKind>, Error>
fn read_bid(&mut self, key: &Key) -> Result<Option<BidKind>, Error>
casper_types::system::auction::Bid
at account hash derived from given public keySource§fn write_bid(&mut self, key: Key, bid_kind: BidKind) -> Result<(), Error>
fn write_bid(&mut self, key: Key, bid_kind: BidKind) -> Result<(), Error>
BidKind
at given key.Source§fn read_unbond(&mut self, bid_addr: BidAddr) -> Result<Option<Unbond>, Error>
fn read_unbond(&mut self, bid_addr: BidAddr) -> Result<Option<Unbond>, Error>
Unbond
s at bid address.Source§impl<R> StorageProvider for Runtime<'_, R>
impl<R> StorageProvider for Runtime<'_, R>
Source§impl<R> StorageProvider for Runtime<'_, R>
impl<R> StorageProvider for Runtime<'_, R>
Source§fn read<T: CLTyped + FromBytes>(
&mut self,
uref: URef,
) -> Result<Option<T>, Error>
fn read<T: CLTyped + FromBytes>( &mut self, uref: URef, ) -> Result<Option<T>, Error>
URef
.Source§impl<R> SystemProvider for Runtime<'_, R>
impl<R> SystemProvider for Runtime<'_, R>
Auto Trait Implementations§
impl<'a, R> Freeze for Runtime<'a, R>
impl<'a, R> !RefUnwindSafe for Runtime<'a, R>
impl<'a, R> !Send for Runtime<'a, R>
impl<'a, R> !Sync for Runtime<'a, R>
impl<'a, R> Unpin for Runtime<'a, R>
impl<'a, R> !UnwindSafe for Runtime<'a, R>
Blanket Implementations§
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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