From ce4af1bab3381a2bdab56ced6c976448abb37cea Mon Sep 17 00:00:00 2001 From: George Mitenkov Date: Thu, 1 Aug 2024 08:00:20 +0100 Subject: [PATCH] [loader] Add feature flag to be able to switch to V2 implementation --- .../src/components/feature_flags.rs | 3 +++ types/src/on_chain_config/aptos_features.rs | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/aptos-move/aptos-release-builder/src/components/feature_flags.rs b/aptos-move/aptos-release-builder/src/components/feature_flags.rs index b0d7cc4c172f3..a9f42c0b2b54d 100644 --- a/aptos-move/aptos-release-builder/src/components/feature_flags.rs +++ b/aptos-move/aptos-release-builder/src/components/feature_flags.rs @@ -127,6 +127,7 @@ pub enum FeatureFlag { EnableEnumTypes, EnableResourceAccessControl, RejectUnstableBytecodeForScript, + UseLoaderV2, } fn generate_features_blob(writer: &CodeWriter, data: &[u64]) { @@ -336,6 +337,7 @@ impl From for AptosFeatureFlag { FeatureFlag::RejectUnstableBytecodeForScript => { AptosFeatureFlag::REJECT_UNSTABLE_BYTECODE_FOR_SCRIPT }, + FeatureFlag::UseLoaderV2 => AptosFeatureFlag::USE_LOADER_V2, } } } @@ -474,6 +476,7 @@ impl From for FeatureFlag { AptosFeatureFlag::REJECT_UNSTABLE_BYTECODE_FOR_SCRIPT => { FeatureFlag::RejectUnstableBytecodeForScript }, + AptosFeatureFlag::USE_LOADER_V2 => FeatureFlag::UseLoaderV2, } } } diff --git a/types/src/on_chain_config/aptos_features.rs b/types/src/on_chain_config/aptos_features.rs index 79d2045b551ce..f4c2287297d10 100644 --- a/types/src/on_chain_config/aptos_features.rs +++ b/types/src/on_chain_config/aptos_features.rs @@ -92,6 +92,7 @@ pub enum FeatureFlag { ENABLE_ENUM_TYPES = 74, ENABLE_RESOURCE_ACCESS_CONTROL = 75, REJECT_UNSTABLE_BYTECODE_FOR_SCRIPT = 76, + USE_LOADER_V2 = 77, } impl FeatureFlag { @@ -167,6 +168,8 @@ impl FeatureFlag { FeatureFlag::ENABLE_ENUM_TYPES, FeatureFlag::ENABLE_RESOURCE_ACCESS_CONTROL, FeatureFlag::REJECT_UNSTABLE_BYTECODE_FOR_SCRIPT, + // TODO(George): Enable this flag when ready. + // FeatureFlag::USE_LOADER_V2, ] } } @@ -304,6 +307,12 @@ impl Features { self.is_enabled(FeatureFlag::ABORT_IF_MULTISIG_PAYLOAD_MISMATCH) } + /// If enabled, MoveVM uses the V2 stateless loader API. The flag is used + /// to ensure we have both V1 and V2 operating at the same time. + pub fn use_loader_v2(&self) -> bool { + self.is_enabled(FeatureFlag::USE_LOADER_V2) + } + pub fn get_max_identifier_size(&self) -> u64 { if self.is_enabled(FeatureFlag::LIMIT_MAX_IDENTIFIER_LENGTH) { IDENTIFIER_SIZE_MAX