Skip to content

Commit

Permalink
Add env var for experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemitenkov committed Nov 13, 2024
1 parent b026774 commit 6241566
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions aptos-move/aptos-vm-environment/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use aptos_native_interface::SafeNativeBuilder;
use aptos_types::{
chain_id::ChainId,
on_chain_config::{
ConfigurationResource, Features, OnChainConfig, TimedFeatures, TimedFeaturesBuilder,
ConfigurationResource, FeatureFlag, Features, OnChainConfig, TimedFeatures,
TimedFeaturesBuilder,
},
state_store::StateView,
};
Expand Down Expand Up @@ -175,8 +176,13 @@ impl Environment {
) -> Self {
// We compute and store a hash of configs in order to distinguish different environments.
let mut sha3_256 = Sha3_256::new();
let features =
let mut features =
fetch_config_and_update_hash::<Features>(&mut sha3_256, state_view).unwrap_or_default();
if std::env::var("USE_LOADER_V1").is_ok() {
features.disable(FeatureFlag::ENABLE_LOADER_V2);
} else {
features.enable(FeatureFlag::ENABLE_LOADER_V2);
}

// If no chain ID is in storage, we assume we are in a testing environment.
let chain_id = fetch_config_and_update_hash::<ChainId>(&mut sha3_256, state_view)
Expand Down
2 changes: 1 addition & 1 deletion third_party/move/move-vm/runtime/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Default for VMConfig {
ty_builder: TypeBuilder::with_limits(128, 20),
disallow_dispatch_for_native: true,
use_compatibility_checker_v2: true,
use_loader_v2: true,
use_loader_v2: std::env::var("USE_LOADER_V1").is_err(),
}
}
}
5 changes: 5 additions & 0 deletions types/src/on_chain_config/aptos_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ impl Default for Features {
for feature in FeatureFlag::default_features() {
features.enable(feature);
}
if std::env::var("USE_LOADER_V1").is_ok() {
features.disable(FeatureFlag::ENABLE_LOADER_V2);
} else {
features.enable(FeatureFlag::ENABLE_LOADER_V2);
}
features
}
}
Expand Down

0 comments on commit 6241566

Please sign in to comment.