Skip to content

Commit 8ec5ff5

Browse files
author
Timothy Zakian
committed
Revert "[3/n][object runtime type tags] Add type tags to object runtime update adapter to handle them (#22092)" and "[sui-adapter] Add basic package cache (#22099)"
This reverts commit b4ea7a4.
1 parent 7c3ad5f commit 8ec5ff5

File tree

20 files changed

+157
-380
lines changed

20 files changed

+157
-380
lines changed

crates/sui-adapter-transactional-tests/tests/init/create_object.move

Lines changed: 0 additions & 17 deletions
This file was deleted.

crates/sui-adapter-transactional-tests/tests/init/create_object.snap

Lines changed: 0 additions & 22 deletions
This file was deleted.

crates/sui-adapter-transactional-tests/tests/init/emit_event.move

Lines changed: 0 additions & 17 deletions
This file was deleted.

crates/sui-adapter-transactional-tests/tests/init/emit_event.snap

Lines changed: 0 additions & 15 deletions
This file was deleted.

crates/sui-open-rpc/spec/openrpc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,6 @@
13751375
"soft_bundle": false,
13761376
"throughput_aware_consensus_submission": false,
13771377
"txn_base_cost_as_multiplier": false,
1378-
"type_tags_in_object_runtime": false,
13791378
"uncompressed_g1_group_elements": false,
13801379
"upgraded_multisig_supported": false,
13811380
"validate_identifier_inputs": false,

crates/sui-protocol-config/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,6 @@ struct FeatureFlags {
694694
// Enable native function for party transfer
695695
#[serde(skip_serializing_if = "is_false")]
696696
enable_party_transfer: bool,
697-
698-
// Signifies the cut-over of using type tags instead of `Type`s in the object runtime.
699-
#[serde(skip_serializing_if = "is_false")]
700-
type_tags_in_object_runtime: bool,
701697
}
702698

703699
fn is_false(b: &bool) -> bool {
@@ -1982,10 +1978,6 @@ impl ProtocolConfig {
19821978
pub fn enable_party_transfer(&self) -> bool {
19831979
self.feature_flags.enable_party_transfer
19841980
}
1985-
1986-
pub fn type_tags_in_object_runtime(&self) -> bool {
1987-
self.feature_flags.type_tags_in_object_runtime
1988-
}
19891981
}
19901982

19911983
#[cfg(not(msim))]
@@ -3547,7 +3539,6 @@ impl ProtocolConfig {
35473539
// native function on mainnet.
35483540
cfg.feature_flags.enable_nitro_attestation_upgraded_parsing = true;
35493541
cfg.feature_flags.enable_nitro_attestation = true;
3550-
cfg.feature_flags.type_tags_in_object_runtime = true;
35513542
}
35523543
// Use this template when making changes:
35533544
//

crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Mainnet_version_83.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ feature_flags:
9090
enforce_checkpoint_timestamp_monotonicity: true
9191
max_ptb_value_size_v2: true
9292
resolve_type_input_ids_to_defining_id: true
93-
type_tags_in_object_runtime: true
9493
max_tx_size_bytes: 131072
9594
max_input_objects: 2048
9695
max_size_written_objects: 5000000

crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__Testnet_version_83.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ feature_flags:
9292
enforce_checkpoint_timestamp_monotonicity: true
9393
max_ptb_value_size_v2: true
9494
resolve_type_input_ids_to_defining_id: true
95-
type_tags_in_object_runtime: true
9695
max_tx_size_bytes: 131072
9796
max_input_objects: 2048
9897
max_size_written_objects: 5000000

crates/sui-protocol-config/src/snapshots/sui_protocol_config__test__version_83.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ feature_flags:
9797
enforce_checkpoint_timestamp_monotonicity: true
9898
max_ptb_value_size_v2: true
9999
resolve_type_input_ids_to_defining_id: true
100-
type_tags_in_object_runtime: true
101100
max_tx_size_bytes: 131072
102101
max_input_objects: 2048
103102
max_size_written_objects: 5000000

external-crates/move/crates/move-vm-runtime/src/native_functions.rs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ use move_core_types::{
2020
};
2121
use move_vm_config::runtime::VMRuntimeLimitsConfig;
2222
use move_vm_types::{
23-
data_store::DataStore, loaded_data::runtime_types::Type, natives::function::NativeResult,
24-
values::Value,
23+
loaded_data::runtime_types::Type, natives::function::NativeResult, values::Value,
2524
};
2625
use std::{
2726
cell::RefCell,
@@ -159,36 +158,6 @@ impl<'b> NativeContext<'_, 'b> {
159158
}
160159
}
161160

162-
// TODO: This is a bit hacky right now since we need to pass the store, however this is only
163-
// used in test scenarios so we have some special knowledge that makes this work. In the new VM
164-
// however this is _MUCH_ nicer as we don't need to pass the datastore as the VM's linkage
165-
// tables must have the type present.
166-
pub fn type_tag_to_fully_annotated_layout_for_test_scenario_only(
167-
&self,
168-
tag: &TypeTag,
169-
store: &impl DataStore,
170-
) -> PartialVMResult<A::MoveTypeLayout> {
171-
self.resolver
172-
.loader()
173-
.get_fully_annotated_type_layout(tag, store)
174-
.map_err(|e| e.to_partial())
175-
}
176-
177-
// TODO: This is a bit hacky right now since we need to pass the store, however this is only
178-
// used in test scenarios so we have some special knowledge that makes this work. In the new VM
179-
// however this is _MUCH_ nicer as we don't need to pass the datastore as the VM's linkage
180-
// tables must have the type present.
181-
pub fn type_tag_to_layout_for_test_scenario_only(
182-
&self,
183-
tag: &TypeTag,
184-
store: &impl DataStore,
185-
) -> PartialVMResult<R::MoveTypeLayout> {
186-
self.resolver
187-
.loader()
188-
.get_type_layout(tag, store)
189-
.map_err(|e| e.to_partial())
190-
}
191-
192161
pub fn type_to_abilities(&self, ty: &Type) -> PartialVMResult<AbilitySet> {
193162
self.resolver.loader().abilities(ty)
194163
}

sui-execution/latest/sui-adapter/src/programmable_transactions/context.rs

Lines changed: 31 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ mod checked {
1515
},
1616
gas_charger::GasCharger,
1717
gas_meter::SuiGasMeter,
18-
programmable_transactions::{
19-
data_store::{PackageStore, SuiDataStore},
20-
linkage_view::LinkageView,
21-
},
18+
programmable_transactions::{data_store::SuiDataStore, linkage_view::LinkageView},
2219
type_resolver::TypeTagResolver,
2320
};
2421
use move_binary_format::{
@@ -62,7 +59,7 @@ mod checked {
6259
metrics::LimitsMetrics,
6360
move_package::MovePackage,
6461
object::{Authenticator, Data, MoveObject, Object, ObjectInner, Owner},
65-
storage::DenyListResult,
62+
storage::{BackingPackageStore, DenyListResult, PackageObject},
6663
transaction::{Argument, CallArg, ObjectArg},
6764
};
6865
use tracing::instrument;
@@ -288,10 +285,10 @@ mod checked {
288285
.unwrap_or(*package_id));
289286
}
290287

291-
let move_package = get_package(&self.linkage_view, package_id)
288+
let package = package_for_linkage(&self.linkage_view, package_id)
292289
.map_err(|e| self.convert_vm_error(e))?;
293290

294-
self.linkage_view.set_linkage(&move_package)
291+
self.linkage_view.set_linkage(package.move_package())
295292
}
296293

297294
/// Load a type using the context's current session.
@@ -344,12 +341,7 @@ mod checked {
344341
}
345342
let new_events = events
346343
.into_iter()
347-
.map(|(tag, value)| {
348-
let ty = unwrap_type_tag_load(
349-
self.protocol_config,
350-
self.load_type_from_struct(&tag)
351-
.map_err(|e| self.convert_vm_error(e)),
352-
)?;
344+
.map(|(ty, tag, value)| {
353345
let layout = self
354346
.vm
355347
.get_runtime()
@@ -712,7 +704,7 @@ mod checked {
712704
let Self {
713705
protocol_config,
714706
vm,
715-
mut linkage_view,
707+
linkage_view,
716708
mut native_extensions,
717709
tx_context,
718710
gas_charger,
@@ -847,6 +839,12 @@ mod checked {
847839
loaded_runtime_objects.extend(loaded_child_objects);
848840

849841
let mut written_objects = BTreeMap::new();
842+
for package in new_packages {
843+
let package_obj = Object::new_from_package(package, tx_digest);
844+
let id = package_obj.id();
845+
created_object_ids.insert(id);
846+
written_objects.insert(id, package_obj);
847+
}
850848
for (id, additional_write) in additional_writes {
851849
let AdditionalWrite {
852850
recipient,
@@ -874,24 +872,7 @@ mod checked {
874872
}
875873
}
876874

877-
for (id, (recipient, tag, value)) in writes {
878-
let ty = unwrap_type_tag_load(
879-
protocol_config,
880-
load_type_from_struct(
881-
vm,
882-
&mut linkage_view,
883-
&new_packages,
884-
&StructTag::from(tag.clone()),
885-
)
886-
.map_err(|e| {
887-
convert_vm_error(
888-
e,
889-
vm,
890-
&linkage_view,
891-
protocol_config.resolve_abort_locations_to_package_id(),
892-
)
893-
}),
894-
)?;
875+
for (id, (recipient, ty, value)) in writes {
895876
let abilities = vm.get_runtime().get_type_abilities(&ty).map_err(|e| {
896877
convert_vm_error(
897878
e,
@@ -929,13 +910,6 @@ mod checked {
929910
written_objects.insert(id, object);
930911
}
931912

932-
for package in new_packages {
933-
let package_obj = Object::new_from_package(package, tx_digest);
934-
let id = package_obj.id();
935-
created_object_ids.insert(id);
936-
written_objects.insert(id, package_obj);
937-
}
938-
939913
// Before finishing, ensure that any shared object taken by value by the transaction is either:
940914
// 1. Mutated (and still has a shared ownership); or
941915
// 2. Deleted.
@@ -1049,6 +1023,7 @@ mod checked {
10491023

10501024
/// Special case errors for type arguments to Move functions
10511025
pub fn convert_type_argument_error(&self, idx: usize, error: VMError) -> ExecutionError {
1026+
use move_core_types::vm_status::StatusCode;
10521027
use sui_types::execution_status::TypeArgumentError;
10531028
match error.major_status() {
10541029
StatusCode::NUMBER_OF_TYPE_ARGUMENTS_MISMATCH => {
@@ -1309,17 +1284,22 @@ mod checked {
13091284

13101285
/// Fetch the package at `package_id` with a view to using it as a link context. Produces an error
13111286
/// if the object at that ID does not exist, or is not a package.
1312-
fn get_package(
1313-
package_store: &dyn PackageStore,
1287+
fn package_for_linkage(
1288+
linkage_view: &LinkageView,
13141289
package_id: ObjectID,
1315-
) -> VMResult<Rc<MovePackage>> {
1316-
match package_store.get_package(&package_id) {
1290+
) -> VMResult<PackageObject> {
1291+
use move_binary_format::errors::PartialVMError;
1292+
use move_core_types::vm_status::StatusCode;
1293+
1294+
match linkage_view.get_package_object(&package_id) {
13171295
Ok(Some(package)) => Ok(package),
13181296
Ok(None) => Err(PartialVMError::new(StatusCode::LINKER_ERROR)
13191297
.with_message(format!("Cannot find link context {package_id} in store"))
13201298
.finish(Location::Undefined)),
13211299
Err(err) => Err(PartialVMError::new(StatusCode::LINKER_ERROR)
1322-
.with_message(format!("Error loading {package_id} from store: {err}"))
1300+
.with_message(format!(
1301+
"Error loading link context {package_id} from store: {err}"
1302+
))
13231303
.finish(Location::Undefined)),
13241304
}
13251305
}
@@ -1343,27 +1323,22 @@ mod checked {
13431323

13441324
// Load the package that the struct is defined in, in storage
13451325
let defining_id = ObjectID::from_address(*address);
1346-
1347-
let data_store = SuiDataStore::new(linkage_view, new_packages);
1348-
let move_package = get_package(&data_store, defining_id)?;
1349-
1350-
// Save the link context as we need to set it while loading the struct and we don't want to
1351-
// clobber it.
1352-
let saved_linkage = linkage_view.steal_linkage();
1326+
let package = package_for_linkage(linkage_view, defining_id)?;
13531327

13541328
// Set the defining package as the link context while loading the
13551329
// struct
13561330
let original_address = linkage_view
1357-
.set_linkage(&move_package)
1358-
.expect("Linkage context was just stolen. Therefore must be empty");
1331+
.set_linkage(package.move_package())
1332+
.map_err(|e| {
1333+
PartialVMError::new(StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR)
1334+
.with_message(e.to_string())
1335+
.finish(Location::Undefined)
1336+
})?;
13591337

13601338
let runtime_id = ModuleId::new(original_address, module.clone());
13611339
let data_store = SuiDataStore::new(linkage_view, new_packages);
13621340
let res = vm.get_runtime().load_type(&runtime_id, name, &data_store);
13631341
linkage_view.reset_linkage();
1364-
linkage_view
1365-
.restore_linkage(saved_linkage)
1366-
.expect("Linkage context was just reset. Therefore must be empty");
13671342
let (idx, struct_type) = res?;
13681343

13691344
// Recursively load type parameters, if necessary
@@ -1732,17 +1707,6 @@ mod checked {
17321707
}
17331708
}
17341709

1735-
fn unwrap_type_tag_load(
1736-
protocol_config: &ProtocolConfig,
1737-
ty: Result<Type, ExecutionError>,
1738-
) -> Result<Type, ExecutionError> {
1739-
if ty.is_err() && !protocol_config.type_tags_in_object_runtime() {
1740-
panic!("Failed to load a type tag from the object runtime -- this shouldn't happen")
1741-
} else {
1742-
ty
1743-
}
1744-
}
1745-
17461710
enum EitherError {
17471711
CommandArgument(CommandArgumentError),
17481712
Execution(ExecutionError),

0 commit comments

Comments
 (0)