@@ -5,67 +5,63 @@ pub use checked::*;
5
5
6
6
#[ sui_macros:: with_checked_arithmetic]
7
7
mod checked {
8
- use std:: {
9
- borrow:: Borrow ,
10
- cell:: RefCell ,
11
- collections:: { BTreeMap , BTreeSet , HashMap } ,
12
- rc:: Rc ,
13
- sync:: Arc ,
8
+ use crate :: {
9
+ adapter:: new_native_extensions,
10
+ error:: convert_vm_error,
11
+ execution_mode:: ExecutionMode ,
12
+ execution_value:: {
13
+ CommandKind , ExecutionState , InputObjectMetadata , InputValue , ObjectContents ,
14
+ ObjectValue , RawValueType , ResultValue , SizeBound , TryFromValue , UsageKind , Value ,
15
+ } ,
16
+ gas_charger:: GasCharger ,
17
+ gas_meter:: SuiGasMeter ,
18
+ programmable_transactions:: { data_store:: SuiDataStore , linkage_view:: LinkageView } ,
19
+ type_resolver:: TypeTagResolver ,
14
20
} ;
15
-
16
- use crate :: error:: convert_vm_error;
17
- use crate :: execution_mode:: ExecutionMode ;
18
- use crate :: execution_value:: { CommandKind , ObjectContents , TryFromValue , Value } ;
19
- use crate :: execution_value:: {
20
- ExecutionState , InputObjectMetadata , InputValue , ObjectValue , RawValueType , ResultValue ,
21
- UsageKind ,
22
- } ;
23
- use crate :: gas_charger:: GasCharger ;
24
- use crate :: gas_meter:: SuiGasMeter ;
25
- use crate :: programmable_transactions:: linkage_view:: LinkageView ;
26
- use crate :: type_resolver:: TypeTagResolver ;
27
- use crate :: { adapter:: new_native_extensions, execution_value:: SizeBound } ;
28
21
use move_binary_format:: {
29
22
CompiledModule ,
30
- errors:: { Location , PartialVMError , PartialVMResult , VMError , VMResult } ,
23
+ errors:: { Location , PartialVMError , VMError , VMResult } ,
31
24
file_format:: { AbilitySet , CodeOffset , FunctionDefinitionIndex , TypeParameterIndex } ,
32
25
} ;
33
- use move_core_types:: resolver:: ModuleResolver ;
34
- use move_core_types:: vm_status:: StatusCode ;
35
26
use move_core_types:: {
36
27
account_address:: AccountAddress ,
37
28
identifier:: IdentStr ,
38
29
language_storage:: { ModuleId , StructTag , TypeTag } ,
30
+ vm_status:: StatusCode ,
39
31
} ;
40
32
use move_trace_format:: format:: MoveTraceBuilder ;
41
- use move_vm_runtime:: native_extensions:: NativeContextExtensions ;
42
33
use move_vm_runtime:: {
43
34
move_vm:: MoveVM ,
35
+ native_extensions:: NativeContextExtensions ,
44
36
session:: { LoadedFunctionInstantiation , SerializedReturnValues } ,
45
37
} ;
46
- use move_vm_types:: data_store:: DataStore ;
47
38
use move_vm_types:: loaded_data:: runtime_types:: Type ;
48
39
use mysten_common:: debug_fatal;
40
+ use std:: {
41
+ borrow:: Borrow ,
42
+ cell:: RefCell ,
43
+ collections:: { BTreeMap , BTreeSet , HashMap } ,
44
+ rc:: Rc ,
45
+ sync:: Arc ,
46
+ } ;
49
47
use sui_move_natives:: object_runtime:: {
50
48
self , LoadedRuntimeObject , ObjectRuntime , RuntimeResults , get_all_uids, max_event_error,
51
49
} ;
52
50
use sui_protocol_config:: ProtocolConfig ;
53
- use sui_types:: storage:: { DenyListResult , PackageObject } ;
54
51
use sui_types:: {
55
52
balance:: Balance ,
56
53
base_types:: { MoveObjectType , ObjectID , SuiAddress , TxContext } ,
57
54
coin:: Coin ,
58
- error:: { ExecutionError , ExecutionErrorKind } ,
55
+ error:: { ExecutionError , ExecutionErrorKind , command_argument_error } ,
59
56
event:: Event ,
60
- execution:: ExecutionResultsV2 ,
57
+ execution:: { ExecutionResults , ExecutionResultsV2 } ,
58
+ execution_status:: CommandArgumentError ,
61
59
metrics:: LimitsMetrics ,
62
60
move_package:: MovePackage ,
63
- object:: { Data , MoveObject , Object , ObjectInner , Owner } ,
64
- storage:: BackingPackageStore ,
61
+ object:: { Authenticator , Data , MoveObject , Object , ObjectInner , Owner } ,
62
+ storage:: { BackingPackageStore , DenyListResult , PackageObject } ,
65
63
transaction:: { Argument , CallArg , ObjectArg } ,
66
64
} ;
67
- use sui_types:: { error:: command_argument_error, execution_status:: CommandArgumentError } ;
68
- use sui_types:: { execution:: ExecutionResults , object:: Authenticator } ;
69
65
use tracing:: instrument;
70
66
71
67
/// Maintains all runtime state specific to programmable transactions
@@ -1711,94 +1707,6 @@ mod checked {
1711
1707
}
1712
1708
}
1713
1709
1714
- // Implementation of the `DataStore` trait for the Move VM.
1715
- // When used during execution it may have a list of new packages that have
1716
- // just been published in the current context. Those are used for module/type
1717
- // resolution when executing module init.
1718
- // It may be created with an empty slice of packages either when no publish/upgrade
1719
- // are performed or when a type is requested not during execution.
1720
- pub ( crate ) struct SuiDataStore < ' state , ' a > {
1721
- linkage_view : & ' a LinkageView < ' state > ,
1722
- new_packages : & ' a [ MovePackage ] ,
1723
- }
1724
-
1725
- impl < ' state , ' a > SuiDataStore < ' state , ' a > {
1726
- pub ( crate ) fn new (
1727
- linkage_view : & ' a LinkageView < ' state > ,
1728
- new_packages : & ' a [ MovePackage ] ,
1729
- ) -> Self {
1730
- Self {
1731
- linkage_view,
1732
- new_packages,
1733
- }
1734
- }
1735
-
1736
- fn get_module ( & self , module_id : & ModuleId ) -> Option < & Vec < u8 > > {
1737
- for package in self . new_packages {
1738
- let module = package. get_module ( module_id) ;
1739
- if module. is_some ( ) {
1740
- return module;
1741
- }
1742
- }
1743
- None
1744
- }
1745
- }
1746
-
1747
- // TODO: `DataStore` will be reworked and this is likely to disappear.
1748
- // Leaving this comment around until then as testament to better days to come...
1749
- impl DataStore for SuiDataStore < ' _ , ' _ > {
1750
- fn link_context ( & self ) -> AccountAddress {
1751
- self . linkage_view . link_context ( )
1752
- }
1753
-
1754
- fn relocate ( & self , module_id : & ModuleId ) -> PartialVMResult < ModuleId > {
1755
- self . linkage_view . relocate ( module_id) . map_err ( |err| {
1756
- PartialVMError :: new ( StatusCode :: LINKER_ERROR )
1757
- . with_message ( format ! ( "Error relocating {module_id}: {err:?}" ) )
1758
- } )
1759
- }
1760
-
1761
- fn defining_module (
1762
- & self ,
1763
- runtime_id : & ModuleId ,
1764
- struct_ : & IdentStr ,
1765
- ) -> PartialVMResult < ModuleId > {
1766
- self . linkage_view
1767
- . defining_module ( runtime_id, struct_)
1768
- . map_err ( |err| {
1769
- PartialVMError :: new ( StatusCode :: LINKER_ERROR ) . with_message ( format ! (
1770
- "Error finding defining module for {runtime_id}::{struct_}: {err:?}"
1771
- ) )
1772
- } )
1773
- }
1774
-
1775
- fn load_module ( & self , module_id : & ModuleId ) -> VMResult < Vec < u8 > > {
1776
- if let Some ( bytes) = self . get_module ( module_id) {
1777
- return Ok ( bytes. clone ( ) ) ;
1778
- }
1779
- match self . linkage_view . get_module ( module_id) {
1780
- Ok ( Some ( bytes) ) => Ok ( bytes) ,
1781
- Ok ( None ) => Err ( PartialVMError :: new ( StatusCode :: LINKER_ERROR )
1782
- . with_message ( format ! ( "Cannot find {:?} in data cache" , module_id) )
1783
- . finish ( Location :: Undefined ) ) ,
1784
- Err ( err) => {
1785
- let msg = format ! ( "Unexpected storage error: {:?}" , err) ;
1786
- Err (
1787
- PartialVMError :: new ( StatusCode :: UNKNOWN_INVARIANT_VIOLATION_ERROR )
1788
- . with_message ( msg)
1789
- . finish ( Location :: Undefined ) ,
1790
- )
1791
- }
1792
- }
1793
- }
1794
-
1795
- fn publish_module ( & mut self , _module_id : & ModuleId , _blob : Vec < u8 > ) -> VMResult < ( ) > {
1796
- // we cannot panic here because during execution and publishing this is
1797
- // currently called from the publish flow in the Move runtime
1798
- Ok ( ( ) )
1799
- }
1800
- }
1801
-
1802
1710
enum EitherError {
1803
1711
CommandArgument ( CommandArgumentError ) ,
1804
1712
Execution ( ExecutionError ) ,
0 commit comments