pub struct ExecutionContext<'vm, 'state, 'a> {
pub protocol_config: &'a ProtocolConfig,
pub metrics: Arc<LimitsMetrics>,
pub vm: &'vm MoveVM,
pub linkage_view: LinkageView<'state>,
pub native_extensions: NativeContextExtensions<'state>,
pub state_view: &'state dyn ExecutionState,
pub tx_context: Rc<RefCell<TxContext>>,
pub gas_charger: &'a mut GasCharger,
/* private fields */
}
Expand description
Maintains all runtime state specific to programmable transactions
Fields§
§protocol_config: &'a ProtocolConfig
The protocol config
metrics: Arc<LimitsMetrics>
Metrics for reporting exceeded limits
vm: &'vm MoveVM
The MoveVM
linkage_view: LinkageView<'state>
The LinkageView for this session
native_extensions: NativeContextExtensions<'state>
§state_view: &'state dyn ExecutionState
The global state, used for resolving packages
tx_context: Rc<RefCell<TxContext>>
A shared transaction context, contains transaction digest information and manages the creation of new object IDs
gas_charger: &'a mut GasCharger
The gas charger used for metering
Implementations§
Source§impl<'vm, 'state, 'a> ExecutionContext<'vm, 'state, 'a>
impl<'vm, 'state, 'a> ExecutionContext<'vm, 'state, 'a>
pub fn new(
protocol_config: &'a ProtocolConfig,
metrics: Arc<LimitsMetrics>,
vm: &'vm MoveVM,
state_view: &'state dyn ExecutionState,
tx_context: Rc<RefCell<TxContext>>,
gas_charger: &'a mut GasCharger,
inputs: Vec<CallArg>,
) -> Result<Self, ExecutionError>where
'a: 'state,
pub fn object_runtime(&self) -> Result<&ObjectRuntime<'_>, ExecutionError>
Sourcepub fn fresh_id(&mut self) -> Result<ObjectID, ExecutionError>
pub fn fresh_id(&mut self) -> Result<ObjectID, ExecutionError>
Create a new ID and update the state
Sourcepub fn delete_id(&mut self, object_id: ObjectID) -> Result<(), ExecutionError>
pub fn delete_id(&mut self, object_id: ObjectID) -> Result<(), ExecutionError>
Delete an ID and update the state
Sourcepub fn set_link_context(
&mut self,
package_id: ObjectID,
) -> Result<AccountAddress, ExecutionError>
pub fn set_link_context( &mut self, package_id: ObjectID, ) -> Result<AccountAddress, ExecutionError>
Set the link context for the session from the linkage information in the MovePackage found
at package_id
. Returns the runtime ID of the link context package on success.
Sourcepub fn load_type(&mut self, type_tag: &TypeTag) -> VMResult<Type>
pub fn load_type(&mut self, type_tag: &TypeTag) -> VMResult<Type>
Load a type using the context’s current session.
Sourcepub fn load_type_from_struct(
&mut self,
struct_tag: &StructTag,
) -> VMResult<Type>
pub fn load_type_from_struct( &mut self, struct_tag: &StructTag, ) -> VMResult<Type>
Load a type using the context’s current session.
pub fn get_type_abilities(&self, t: &Type) -> Result<AbilitySet, ExecutionError>
Sourcepub fn take_user_events(
&mut self,
module_id: &ModuleId,
function: FunctionDefinitionIndex,
last_offset: CodeOffset,
) -> Result<(), ExecutionError>
pub fn take_user_events( &mut self, module_id: &ModuleId, function: FunctionDefinitionIndex, last_offset: CodeOffset, ) -> Result<(), ExecutionError>
Takes the user events from the runtime and tags them with the Move module of the function that was invoked for the command
Sourcepub fn splat_args<Items: IntoIterator<Item = Argument>>(
&self,
start_idx: usize,
args: Items,
) -> Result<Vec<Arg>, ExecutionError>where
Items::IntoIter: ExactSizeIterator,
pub fn splat_args<Items: IntoIterator<Item = Argument>>(
&self,
start_idx: usize,
args: Items,
) -> Result<Vec<Arg>, ExecutionError>where
Items::IntoIter: ExactSizeIterator,
Takes an iterator of arguments and flattens a Result into a NestedResult if there is more than one result. However, it is currently gated to 1 result, so this function is in place for future changes. This is currently blocked by more invasive work needed to update argument idx in errors
pub fn one_arg( &self, command_arg_idx: usize, arg: Argument, ) -> Result<Arg, ExecutionError>
Sourcepub fn by_value_arg<V: TryFromValue>(
&mut self,
command_kind: CommandKind<'_>,
arg_idx: usize,
arg: Arg,
) -> Result<V, ExecutionError>
pub fn by_value_arg<V: TryFromValue>( &mut self, command_kind: CommandKind<'_>, arg_idx: usize, arg: Arg, ) -> Result<V, ExecutionError>
Get the argument value. Cloning the value if it is copyable, and setting its value to None if it is not (making it unavailable). Errors if out of bounds, if the argument is borrowed, if it is unavailable (already taken), or if it is an object that cannot be taken by value (shared or immutable)
Sourcepub fn borrow_arg_mut<V: TryFromValue>(
&mut self,
arg_idx: usize,
arg: Arg,
) -> Result<V, ExecutionError>
pub fn borrow_arg_mut<V: TryFromValue>( &mut self, arg_idx: usize, arg: Arg, ) -> Result<V, ExecutionError>
Mimic a mutable borrow by taking the argument value, setting its value to None, making it unavailable. The value will be marked as borrowed and must be returned with restore_arg Errors if out of bounds, if the argument is borrowed, if it is unavailable (already taken), or if it is an object that cannot be mutably borrowed (immutable)
Sourcepub fn borrow_arg<V: TryFromValue>(
&mut self,
arg_idx: usize,
arg: Arg,
type_: &Type,
) -> Result<V, ExecutionError>
pub fn borrow_arg<V: TryFromValue>( &mut self, arg_idx: usize, arg: Arg, type_: &Type, ) -> Result<V, ExecutionError>
Mimics an immutable borrow by cloning the argument value without setting its value to None Errors if out of bounds, if the argument is mutably borrowed, or if it is unavailable (already taken)
Sourcepub fn restore_arg<Mode: ExecutionMode>(
&mut self,
updates: &mut Mode::ArgumentUpdates,
arg: Arg,
value: Value,
) -> Result<(), ExecutionError>
pub fn restore_arg<Mode: ExecutionMode>( &mut self, updates: &mut Mode::ArgumentUpdates, arg: Arg, value: Value, ) -> Result<(), ExecutionError>
Restore an argument after being mutably borrowed
Sourcepub fn transfer_object(
&mut self,
obj: ObjectValue,
addr: SuiAddress,
) -> Result<(), ExecutionError>
pub fn transfer_object( &mut self, obj: ObjectValue, addr: SuiAddress, ) -> Result<(), ExecutionError>
Transfer the object to a new owner
Sourcepub fn new_package<'p>(
&self,
modules: &[CompiledModule],
dependencies: impl IntoIterator<Item = &'p MovePackage>,
) -> Result<MovePackage, ExecutionError>
pub fn new_package<'p>( &self, modules: &[CompiledModule], dependencies: impl IntoIterator<Item = &'p MovePackage>, ) -> Result<MovePackage, ExecutionError>
Create a new package
Sourcepub fn upgrade_package<'p>(
&self,
storage_id: ObjectID,
previous_package: &MovePackage,
new_modules: &[CompiledModule],
dependencies: impl IntoIterator<Item = &'p MovePackage>,
) -> Result<MovePackage, ExecutionError>
pub fn upgrade_package<'p>( &self, storage_id: ObjectID, previous_package: &MovePackage, new_modules: &[CompiledModule], dependencies: impl IntoIterator<Item = &'p MovePackage>, ) -> Result<MovePackage, ExecutionError>
Create a package upgrade from previous_package
with new_modules
and dependencies
Sourcepub fn write_package(&mut self, package: MovePackage)
pub fn write_package(&mut self, package: MovePackage)
Add a newly created package to write as an effect of the transaction
Sourcepub fn pop_package(&mut self) -> Option<MovePackage>
pub fn pop_package(&mut self) -> Option<MovePackage>
Return the last package pushed in write_package
.
This function should be used in block of codes that push a package, verify
it, run the init and in case of error will remove the package.
The package has to be pushed for the init to run correctly.
Sourcepub fn push_command_results(
&mut self,
results: Vec<Value>,
) -> Result<(), ExecutionError>
pub fn push_command_results( &mut self, results: Vec<Value>, ) -> Result<(), ExecutionError>
Finish a command: clearing the borrows and adding the results to the result vector
Sourcepub fn finish<Mode: ExecutionMode>(
self,
) -> Result<ExecutionResults, ExecutionError>
pub fn finish<Mode: ExecutionMode>( self, ) -> Result<ExecutionResults, ExecutionError>
Determine the object changes and collect all user events
Sourcepub fn convert_vm_error(&self, error: VMError) -> ExecutionError
pub fn convert_vm_error(&self, error: VMError) -> ExecutionError
Convert a VM Error to an execution one
Sourcepub fn convert_type_argument_error(
&self,
idx: usize,
error: VMError,
) -> ExecutionError
pub fn convert_type_argument_error( &self, idx: usize, error: VMError, ) -> ExecutionError
Special case errors for type arguments to Move functions
pub fn publish_module_bundle( &mut self, modules: Vec<Vec<u8>>, sender: AccountAddress, ) -> VMResult<()>
pub fn size_bound_raw(&self, bound: u64) -> SizeBound
pub fn size_bound_vector_elem(&self, bound: u64) -> SizeBound
Trait Implementations§
Source§impl TypeTagResolver for ExecutionContext<'_, '_, '_>
impl TypeTagResolver for ExecutionContext<'_, '_, '_>
fn get_type_tag(&self, type_: &Type) -> Result<TypeTag, ExecutionError>
Auto Trait Implementations§
impl<'vm, 'state, 'a> !Freeze for ExecutionContext<'vm, 'state, 'a>
impl<'vm, 'state, 'a> !RefUnwindSafe for ExecutionContext<'vm, 'state, 'a>
impl<'vm, 'state, 'a> !Send for ExecutionContext<'vm, 'state, 'a>
impl<'vm, 'state, 'a> !Sync for ExecutionContext<'vm, 'state, 'a>
impl<'vm, 'state, 'a> Unpin for ExecutionContext<'vm, 'state, 'a>
impl<'vm, 'state, 'a> !UnwindSafe for ExecutionContext<'vm, 'state, 'a>
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> 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>
§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
§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 tonic::Request
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered
].§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.