Skip to content

Commit

Permalink
[loader] Add feature flag to be able to switch to V2 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemitenkov committed Aug 1, 2024
1 parent a2208a6 commit a13c2f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ pub enum FeatureFlag {
EnableEnumTypes,
EnableResourceAccessControl,
RejectUnstableBytecodeForScript,
UseLoaderV2,
}

fn generate_features_blob(writer: &CodeWriter, data: &[u64]) {
Expand Down Expand Up @@ -336,6 +337,7 @@ impl From<FeatureFlag> for AptosFeatureFlag {
FeatureFlag::RejectUnstableBytecodeForScript => {
AptosFeatureFlag::REJECT_UNSTABLE_BYTECODE_FOR_SCRIPT
},
FeatureFlag::UseLoaderV2 => AptosFeatureFlag::USE_LOADER_V2,
}
}
}
Expand Down Expand Up @@ -474,6 +476,7 @@ impl From<AptosFeatureFlag> for FeatureFlag {
AptosFeatureFlag::REJECT_UNSTABLE_BYTECODE_FOR_SCRIPT => {
FeatureFlag::RejectUnstableBytecodeForScript
},
AptosFeatureFlag::USE_LOADER_V2 => FeatureFlag::UseLoaderV2,
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions types/src/on_chain_config/aptos_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
]
}
}
Expand Down Expand Up @@ -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)
}

Check warning on line 314 in types/src/on_chain_config/aptos_features.rs

View check run for this annotation

Codecov / codecov/patch

types/src/on_chain_config/aptos_features.rs#L312-L314

Added lines #L312 - L314 were not covered by tests

pub fn get_max_identifier_size(&self) -> u64 {
if self.is_enabled(FeatureFlag::LIMIT_MAX_IDENTIFIER_LENGTH) {
IDENTIFIER_SIZE_MAX
Expand Down

0 comments on commit a13c2f0

Please sign in to comment.