From b7e7d1900c2f8ab7abc8f57071cf51619ee0f94d Mon Sep 17 00:00:00 2001 From: George Mitenkov Date: Wed, 22 Jan 2025 12:17:53 +0000 Subject: [PATCH] [test] Remove conditionals due to enabled features --- .../aptos-vm-environment/src/prod_configs.rs | 6 ----- aptos-move/aptos-vm/src/aptos_vm.rs | 13 ++--------- .../framework/src/natives/function_info.rs | 5 +--- .../move/move-vm/runtime/src/config.rs | 4 ---- .../move/move-vm/runtime/src/interpreter.rs | 2 +- .../move/move-vm/runtime/src/runtime.rs | 23 ++++--------------- .../move-vm/runtime/src/storage/publishing.rs | 23 ++++--------------- 7 files changed, 14 insertions(+), 62 deletions(-) diff --git a/aptos-move/aptos-vm-environment/src/prod_configs.rs b/aptos-move/aptos-vm-environment/src/prod_configs.rs index 1319d768b0f35..b69cc2baaaafb 100644 --- a/aptos-move/aptos-vm-environment/src/prod_configs.rs +++ b/aptos-move/aptos-vm-environment/src/prod_configs.rs @@ -125,10 +125,6 @@ pub fn aptos_prod_vm_config( let deserializer_config = aptos_prod_deserializer_config(features); let verifier_config = aptos_prod_verifier_config(features); - // Compatibility checker v2 is enabled either by its own flag or if enum types are enabled. - let use_compatibility_checker_v2 = verifier_config.enable_enum_types - || features.is_enabled(FeatureFlag::USE_COMPATIBILITY_CHECKER_V2); - VMConfig { verifier_config, deserializer_config, @@ -142,8 +138,6 @@ pub fn aptos_prod_vm_config( // manually where applicable. delayed_field_optimization_enabled: false, ty_builder, - disallow_dispatch_for_native: features.is_enabled(FeatureFlag::DISALLOW_USER_NATIVES), - use_compatibility_checker_v2, use_loader_v2: features.is_loader_v2_enabled(), use_call_tree_and_instruction_cache: features .is_call_tree_and_instruction_vm_cache_enabled(), diff --git a/aptos-move/aptos-vm/src/aptos_vm.rs b/aptos-move/aptos-vm/src/aptos_vm.rs index 128790cc9a4b5..1a91ee53c59b9 100644 --- a/aptos-move/aptos-vm/src/aptos_vm.rs +++ b/aptos-move/aptos-vm/src/aptos_vm.rs @@ -893,11 +893,7 @@ impl AptosVM { )?; // Native entry function is forbidden. - if self - .features() - .is_enabled(FeatureFlag::DISALLOW_USER_NATIVES) - && function.is_native() - { + if function.is_native() { return Err( PartialVMError::new(StatusCode::USER_DEFINED_NATIVE_NOT_ALLOWED) .with_message( @@ -1775,12 +1771,7 @@ impl AptosVM { self.reject_unstable_bytecode(modules)?; } - if self - .features() - .is_enabled(FeatureFlag::DISALLOW_USER_NATIVES) - { - verifier::native_validation::validate_module_natives(modules)?; - } + verifier::native_validation::validate_module_natives(modules)?; for m in modules { if !expected_modules.remove(m.self_id().name().as_str()) { diff --git a/aptos-move/framework/src/natives/function_info.rs b/aptos-move/framework/src/natives/function_info.rs index e30061b6fb806..6257baca622a8 100644 --- a/aptos-move/framework/src/natives/function_info.rs +++ b/aptos-move/framework/src/natives/function_info.rs @@ -124,10 +124,7 @@ fn native_check_dispatch_type_compatibility_impl( && rhs.return_tys() == lhs.return_tys() && &lhs.param_tys()[0..lhs.param_count() - 1] == rhs.param_tys() && !rhs.is_friend_or_private() - && (!context - .get_feature_flags() - .is_enabled(aptos_types::on_chain_config::FeatureFlag::DISALLOW_USER_NATIVES) - || !rhs.is_native()) + && !rhs.is_native() && lhs_id != rhs_id )]) } diff --git a/third_party/move/move-vm/runtime/src/config.rs b/third_party/move/move-vm/runtime/src/config.rs index 0665034378286..a974c5723c6cc 100644 --- a/third_party/move/move-vm/runtime/src/config.rs +++ b/third_party/move/move-vm/runtime/src/config.rs @@ -24,8 +24,6 @@ pub struct VMConfig { pub type_byte_cost: u64, pub delayed_field_optimization_enabled: bool, pub ty_builder: TypeBuilder, - pub disallow_dispatch_for_native: bool, - pub use_compatibility_checker_v2: bool, pub use_loader_v2: bool, pub use_call_tree_and_instruction_cache: bool, } @@ -43,8 +41,6 @@ impl Default for VMConfig { type_byte_cost: 0, delayed_field_optimization_enabled: false, ty_builder: TypeBuilder::with_limits(128, 20), - disallow_dispatch_for_native: true, - use_compatibility_checker_v2: true, use_loader_v2: true, use_call_tree_and_instruction_cache: true, } diff --git a/third_party/move/move-vm/runtime/src/interpreter.rs b/third_party/move/move-vm/runtime/src/interpreter.rs index 013767303ea34..7d650d6edb390 100644 --- a/third_party/move/move-vm/runtime/src/interpreter.rs +++ b/third_party/move/move-vm/runtime/src/interpreter.rs @@ -847,7 +847,7 @@ impl InterpreterImpl { )); } - if resolver.vm_config().disallow_dispatch_for_native && target_func.is_native() { + if target_func.is_native() { return Err(PartialVMError::new(StatusCode::RUNTIME_DISPATCH_ERROR) .with_message("Invoking native function during dispatch".to_string())); } diff --git a/third_party/move/move-vm/runtime/src/runtime.rs b/third_party/move/move-vm/runtime/src/runtime.rs index d33a49edfd645..0168406f94add 100644 --- a/third_party/move/move-vm/runtime/src/runtime.rs +++ b/third_party/move/move-vm/runtime/src/runtime.rs @@ -19,7 +19,7 @@ use move_binary_format::{ compatibility::Compatibility, errors::{verification_error, Location, PartialVMError, PartialVMResult, VMResult}, file_format::LocalIndex, - normalized, CompiledModule, IndexKind, + CompiledModule, IndexKind, }; use move_core_types::{ account_address::AccountAddress, language_storage::TypeTag, value::MoveTypeLayout, @@ -143,23 +143,10 @@ impl VMRuntime { #[allow(deprecated)] if data_store.exists_module(&module_id)? && compat.need_check_compat() { - let old_module_ref = loader.load_module(&module_id, data_store, module_store)?; - let old_module = old_module_ref.as_ref().as_ref(); - if loader.vm_config().use_compatibility_checker_v2 { - compat - .check(old_module_ref.as_ref().as_ref(), module) - .map_err(|e| e.finish(Location::Undefined))? - } else { - #[allow(deprecated)] - let old_m = normalized::Module::new(old_module) - .map_err(|e| e.finish(Location::Undefined))?; - #[allow(deprecated)] - let new_m = normalized::Module::new(module) - .map_err(|e| e.finish(Location::Undefined))?; - compat - .legacy_check(&old_m, &new_m) - .map_err(|e| e.finish(Location::Undefined))? - } + let old_module = loader.load_module(&module_id, data_store, module_store)?; + compat + .check(&old_module, module) + .map_err(|e| e.finish(Location::Undefined))? } if !bundle_unverified.insert(module_id) { return Err(PartialVMError::new(StatusCode::DUPLICATE_MODULE_NAME) diff --git a/third_party/move/move-vm/runtime/src/storage/publishing.rs b/third_party/move/move-vm/runtime/src/storage/publishing.rs index b59001ba45897..25cce1a56551c 100644 --- a/third_party/move/move-vm/runtime/src/storage/publishing.rs +++ b/third_party/move/move-vm/runtime/src/storage/publishing.rs @@ -12,7 +12,7 @@ use move_binary_format::{ access::ModuleAccess, compatibility::Compatibility, errors::{verification_error, Location, PartialVMError, PartialVMResult, VMResult}, - normalized, CompiledModule, IndexKind, + CompiledModule, IndexKind, }; use move_core_types::{ account_address::AccountAddress, @@ -154,25 +154,12 @@ impl<'a, M: ModuleStorage> StagingModuleStorage<'a, M> { // All modules can be republished, as long as the new module is compatible // with the old module. if compatibility.need_check_compat() { - if let Some(old_module_ref) = + if let Some(old_module) = existing_module_storage.fetch_deserialized_module(addr, name)? { - let old_module = old_module_ref.as_ref(); - if runtime_environment.vm_config().use_compatibility_checker_v2 { - compatibility - .check(old_module, &compiled_module) - .map_err(|e| e.finish(Location::Undefined))?; - } else { - #[allow(deprecated)] - let old_m = normalized::Module::new(old_module) - .map_err(|e| e.finish(Location::Undefined))?; - #[allow(deprecated)] - let new_m = normalized::Module::new(&compiled_module) - .map_err(|e| e.finish(Location::Undefined))?; - compatibility - .legacy_check(&old_m, &new_m) - .map_err(|e| e.finish(Location::Undefined))?; - } + compatibility + .check(&old_module, &compiled_module) + .map_err(|e| e.finish(Location::Undefined))?; } }