Skip to content

Commit

Permalink
comments: use --> enable for features
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemitenkov committed Aug 23, 2024
1 parent 7691132 commit 5818e78
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub enum FeatureFlag {
FederatedKeyless,
TransactionSimulationEnhancement,
CollectionOwner,
UseLoaderV2,
EnableLoaderV2,
}

fn generate_features_blob(writer: &CodeWriter, data: &[u64]) {
Expand Down Expand Up @@ -345,7 +345,7 @@ impl From<FeatureFlag> for AptosFeatureFlag {
AptosFeatureFlag::TRANSACTION_SIMULATION_ENHANCEMENT
},
FeatureFlag::CollectionOwner => AptosFeatureFlag::COLLECTION_OWNER,
FeatureFlag::UseLoaderV2 => AptosFeatureFlag::USE_LOADER_V2,
FeatureFlag::EnableLoaderV2 => AptosFeatureFlag::ENABLE_LOADER_V2,
}
}
}
Expand Down Expand Up @@ -489,7 +489,7 @@ impl From<AptosFeatureFlag> for FeatureFlag {
FeatureFlag::TransactionSimulationEnhancement
},
AptosFeatureFlag::COLLECTION_OWNER => FeatureFlag::CollectionOwner,
AptosFeatureFlag::USE_LOADER_V2 => FeatureFlag::UseLoaderV2,
AptosFeatureFlag::ENABLE_LOADER_V2 => FeatureFlag::EnableLoaderV2,
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ impl AptosVM {
entry_fn: &EntryFunction,
_txn_data: &TransactionMetadata,
) -> Result<(), VMStatus> {
if self.features().use_loader_v2() {
if self.features().is_loader_v2_enabled() {
let addr = entry_fn.module().address();
let name = entry_fn.module().name();
if !module_storage.check_module_exists(addr, name)? {
Expand Down Expand Up @@ -904,7 +904,7 @@ impl AptosVM {
module_storage,
session,
entry_fn,
self.features().use_loader_v2(),
self.features().is_loader_v2_enabled(),
)?
.is_some()
{
Expand Down Expand Up @@ -1574,7 +1574,7 @@ impl AptosVM {
continue;
}

let size_if_module_exists = if self.features().use_loader_v2() {
let size_if_module_exists = if self.features().is_loader_v2_enabled() {
if module_storage.check_module_exists(addr, name)? {
let size = module_storage.fetch_module_size_in_bytes(addr, name)?;
Some(size as u64)
Expand Down Expand Up @@ -1659,7 +1659,7 @@ impl AptosVM {
.is_enabled(FeatureFlag::TREAT_FRIEND_AS_PRIVATE);
let compat = Compatibility::new(check_struct_layout, check_friend_linking);

if self.features().use_loader_v2() {
if self.features().is_loader_v2_enabled() {
// Create a temporary storage. If this fails, it means publishing
// is not possible. We use a new VM here so that struct index map
// in the environment, and the type cache inside loader are not
Expand Down Expand Up @@ -1775,7 +1775,7 @@ impl AptosVM {
}
} else {
Ok::<_, VMError>(
if self.features().use_loader_v2() {
if self.features().is_loader_v2_enabled() {
Some((ModuleWriteSet::empty(), VMChangeSet::empty()))
} else {
None
Expand Down Expand Up @@ -3146,7 +3146,7 @@ pub(crate) fn fetch_module_metadata_for_struct_tag(
resolver: &impl AptosMoveResolver,
module_storage: &impl AptosModuleStorage,
) -> VMResult<Vec<Metadata>> {
if features.use_loader_v2() {
if features.is_loader_v2_enabled() {
module_storage.fetch_module_metadata(&struct_tag.address, &struct_tag.module)
} else {
Ok(resolver.get_module_metadata(&struct_tag.module_id()))
Expand Down
18 changes: 9 additions & 9 deletions aptos-move/aptos-vm/src/move_vm_ext/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub struct SessionExt<'r, 'l> {
inner: Session<'r, 'l>,
resolver: &'r dyn AptosMoveResolver,
is_storage_slot_metadata_enabled: bool,
use_loader_v2: bool,
is_loader_v2_enabled: bool,
}

impl<'r, 'l> SessionExt<'r, 'l> {
Expand Down Expand Up @@ -112,12 +112,12 @@ impl<'r, 'l> SessionExt<'r, 'l> {
move_vm.flush_loader_cache_if_invalidated();

let is_storage_slot_metadata_enabled = features.is_storage_slot_metadata_enabled();
let use_loader_v2 = features.use_loader_v2();
let is_loader_v2_enabled = features.is_loader_v2_enabled();
Self {
inner: move_vm.new_session_with_extensions(resolver, extensions),
resolver,
is_storage_slot_metadata_enabled,
use_loader_v2,
is_loader_v2_enabled,
}
}

Expand Down Expand Up @@ -168,7 +168,7 @@ impl<'r, 'l> SessionExt<'r, 'l> {
move_vm,
self.resolver,
module_storage,
self.use_loader_v2,
self.is_loader_v2_enabled,
change_set,
)
.map_err(|e| e.finish(Location::Undefined))?;
Expand All @@ -191,7 +191,7 @@ impl<'r, 'l> SessionExt<'r, 'l> {
let (change_set, module_write_set) = Self::convert_change_set(
&woc,
change_set,
self.use_loader_v2,
self.is_loader_v2_enabled,
resource_group_change_set,
events,
table_change_set,
Expand Down Expand Up @@ -285,7 +285,7 @@ impl<'r, 'l> SessionExt<'r, 'l> {
vm: &MoveVM,
resolver: &dyn AptosMoveResolver,
module_storage: &impl AptosModuleStorage,
use_loader_v2: bool,
is_loader_v2_enabled: bool,
change_set: ChangeSet,
) -> PartialVMResult<(ChangeSet, ResourceGroupChangeSet)> {
// The use of this implies that we could theoretically call unwrap with no consequences,
Expand Down Expand Up @@ -315,7 +315,7 @@ impl<'r, 'l> SessionExt<'r, 'l> {
let (modules, resources) = account_changeset.into_inner();

for (struct_tag, blob_op) in resources {
let resource_group_tag = if use_loader_v2 {
let resource_group_tag = if is_loader_v2_enabled {
module_storage
.fetch_module_metadata(&struct_tag.address, &struct_tag.module)
.ok()
Expand Down Expand Up @@ -388,7 +388,7 @@ impl<'r, 'l> SessionExt<'r, 'l> {
fn convert_change_set(
woc: &WriteOpConverter,
change_set: ChangeSet,
use_loader_v2: bool,
is_loader_v2_enabled: bool,
resource_group_change_set: ResourceGroupChangeSet,
events: Vec<(ContractEvent, Option<MoveTypeLayout>)>,
table_change_set: TableChangeSet,
Expand Down Expand Up @@ -492,7 +492,7 @@ impl<'r, 'l> SessionExt<'r, 'l> {
)?;

// Modules must not be published through the V1 flow if we are using V2.
if use_loader_v2 && !module_write_ops.is_empty() {
if is_loader_v2_enabled && !module_write_ops.is_empty() {
return Err(
PartialVMError::new(StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR)
.with_message("Non-empty V1 module write set in V2 flow".to_string()),
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-vm/src/move_vm_ext/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl MoveVmExt {
.features()
.is_enabled(FeatureFlag::DISALLOW_USER_NATIVES);

let vm = if env.features().use_loader_v2() {
let vm = if env.features().is_loader_v2_enabled() {
// TODO(loader_v2): For now re-create the VM every time. Later we can have a
// single VM created once.
MoveVM::new_with_config(
Expand Down
4 changes: 2 additions & 2 deletions aptos-move/framework/src/module_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ pub fn get_vm_metadata(
features: &Features,
module_id: &ModuleId,
) -> Option<Arc<RuntimeModuleMetadataV1>> {
if features.use_loader_v2() {
if features.is_loader_v2_enabled() {
let metadata = module_storage
.fetch_module_metadata(module_id.address(), module_id.name())
.ok()?;
Expand All @@ -252,7 +252,7 @@ pub fn get_vm_metadata_v0(
features: &Features,
module_id: &ModuleId,
) -> Option<Arc<RuntimeModuleMetadataV1>> {
if features.use_loader_v2() {
if features.is_loader_v2_enabled() {
let metadata = module_storage
.fetch_module_metadata(module_id.address(), module_id.name())
.ok()?;
Expand Down
8 changes: 4 additions & 4 deletions types/src/on_chain_config/aptos_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub enum FeatureFlag {
FEDERATED_KEYLESS = 77,
TRANSACTION_SIMULATION_ENHANCEMENT = 78,
COLLECTION_OWNER = 79,
USE_LOADER_V2 = 80,
ENABLE_LOADER_V2 = 80,
}

impl FeatureFlag {
Expand Down Expand Up @@ -200,7 +200,7 @@ impl Default for Features {
}

if use_loader_v2_based_on_env() {
features.enable(FeatureFlag::USE_LOADER_V2);
features.enable(FeatureFlag::ENABLE_LOADER_V2);
}

features
Expand Down Expand Up @@ -327,8 +327,8 @@ impl Features {
self.is_enabled(FeatureFlag::TRANSACTION_SIMULATION_ENHANCEMENT)
}

pub fn use_loader_v2(&self) -> bool {
self.is_enabled(FeatureFlag::USE_LOADER_V2)
pub fn is_loader_v2_enabled(&self) -> bool {
self.is_enabled(FeatureFlag::ENABLE_LOADER_V2)
}

pub fn get_max_identifier_size(&self) -> u64 {
Expand Down
2 changes: 1 addition & 1 deletion types/src/vm/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub fn aptos_prod_vm_config(
ty_builder,
disallow_dispatch_for_native: false,
use_compatibility_checker_v2,
use_loader_v2: features.use_loader_v2(),
use_loader_v2: features.is_loader_v2_enabled(),
}
}

Expand Down

0 comments on commit 5818e78

Please sign in to comment.