pub struct Session<'r, 'l, S> { /* private fields */ }

Implementations§

source§

impl<'r, 'l, S: MoveResolver> Session<'r, 'l, S>

source

pub fn execute_function( &mut self, module: &ModuleId, function_name: &IdentStr, ty_args: Vec<TypeTag>, args: Vec<Vec<u8>>, gas_status: &mut GasStatus<'_> ) -> VMResult<Vec<Vec<u8>>>

Execute a Move function with the given arguments. This is mainly designed for an external environment to invoke system logic written in Move.

The caller MUST ensure

  • All types and modules referred to by the type arguments exist.

The Move VM MUST return an invariant violation if the caller fails to follow any of the rules above.

Currently if any other error occurs during execution, the Move VM will simply propagate that error back to the outer environment without handling/translating it. This behavior may be revised in the future.

In case an invariant violation occurs, the whole Session should be considered corrupted and one shall not proceed with effect generation.

source

pub fn execute_script_function( &mut self, module: &ModuleId, function_name: &IdentStr, ty_args: Vec<TypeTag>, args: Vec<Vec<u8>>, senders: Vec<AccountAddress>, gas_status: &mut GasStatus<'_> ) -> VMResult<()>

Execute a Move script function with the given arguments.

Unlike execute_function which is designed for system logic, execute_script_function is mainly designed to call a script function in an existing module. It similar to execute_script except that execution of the “script” begins with the specified function

The Move VM MUST return a user error (in other words, an error that’s not an invariant violation) if

  • The function does not exist.
  • The function does not have script visibility.
  • The signature is not valid for a script. Not all script-visible module functions can be invoked from this entry point. See bytecode_verifier::script_signature for the rules.
  • Type arguments refer to a non-existent type.
  • Arguments (senders included) fail to deserialize or fail to match the signature of the script function.

If any other error occurs during execution, the Move VM MUST propagate that error back to the caller. Besides, no user input should cause the Move VM to return an invariant violation.

In case an invariant violation occurs, the whole Session should be considered corrupted and one shall not proceed with effect generation.

source

pub fn execute_script( &mut self, script: Vec<u8>, ty_args: Vec<TypeTag>, args: Vec<Vec<u8>>, senders: Vec<AccountAddress>, gas_status: &mut GasStatus<'_> ) -> VMResult<()>

Execute a transaction script.

The Move VM MUST return a user error (in other words, an error that’s not an invariant violation) if

  • The script fails to deserialize or verify. Not all expressible signatures are valid. See bytecode_verifier::script_signature for the rules.
  • Type arguments refer to a non-existent type.
  • Arguments (senders included) fail to deserialize or fail to match the signature of the script function.

If any other error occurs during execution, the Move VM MUST propagate that error back to the caller. Besides, no user input should cause the Move VM to return an invariant violation.

In case an invariant violation occurs, the whole Session should be considered corrupted and one shall not proceed with effect generation.

source

pub fn publish_module( &mut self, module: Vec<u8>, sender: AccountAddress, gas_status: &mut GasStatus<'_> ) -> VMResult<()>

Publish the given module.

The Move VM MUST return a user error, i.e., an error that’s not an invariant violation, if

  • The module fails to deserialize or verify.
  • The sender address does not match that of the module.
  • (Republishing-only) the module to be updated is not backward compatible with the old module.
  • (Republishing-only) the module to be updated introduces cyclic dependencies.

The Move VM should not be able to produce other user errors. Besides, no user input should cause the Move VM to return an invariant violation.

In case an invariant violation occurs, the whole Session should be considered corrupted and one shall not proceed with effect generation.

source

pub fn publish_module_bundle( &mut self, modules: Vec<Vec<u8>>, sender: AccountAddress, gas_status: &mut GasStatus<'_> ) -> VMResult<()>

Publish a series of modules.

The Move VM MUST return a user error, i.e., an error that’s not an invariant violation, if any module fails to deserialize or verify (see the full list of failing conditions in the publish_module API). The publishing of the module series is an all-or-nothing action: either all modules are published to the data store or none is.

Similar to the publish_module API, the Move VM should not be able to produce other user errors. Besides, no user input should cause the Move VM to return an invariant violation.

In case an invariant violation occurs, the whole Session should be considered corrupted and one shall not proceed with effect generation.

source

pub fn num_mutated_accounts(&self, sender: &AccountAddress) -> u64

source

pub fn finish(self) -> VMResult<(ChangeSet, Vec<Event>)>

Finish up the session and produce the side effects.

This function should always succeed with no user errors returned, barring invariant violations.

This MUST NOT be called if there is a previous invocation that failed with an invariant violation.

source

pub fn get_type_layout(&self, type_tag: &TypeTag) -> VMResult<MoveTypeLayout>

Auto Trait Implementations§

§

impl<'r, 'l, S> !RefUnwindSafe for Session<'r, 'l, S>

§

impl<'r, 'l, S> !Send for Session<'r, 'l, S>

§

impl<'r, 'l, S> !Sync for Session<'r, 'l, S>

§

impl<'r, 'l, S> Unpin for Session<'r, 'l, S>

§

impl<'r, 'l, S> !UnwindSafe for Session<'r, 'l, S>

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.

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> 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