diff --git a/aptos-move/aptos-vm-environment/src/environment.rs b/aptos-move/aptos-vm-environment/src/environment.rs index 151dc19247ef9..fccfb240f1c8c 100644 --- a/aptos-move/aptos-vm-environment/src/environment.rs +++ b/aptos-move/aptos-vm-environment/src/environment.rs @@ -23,6 +23,7 @@ use aptos_vm_types::storage::StorageGasParameters; use move_vm_runtime::{config::VMConfig, RuntimeEnvironment, WithRuntimeEnvironment}; use sha3::{Digest, Sha3_256}; use std::sync::Arc; +use aptos_types::on_chain_config::FeatureFlag; /// A runtime environment which can be used for VM initialization and more. Contains features /// used by execution, gas parameters, VM configs and global caches. Note that it is the user's @@ -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::(&mut sha3_256, state_view).unwrap_or_default(); + if std::env::var("USE_LOADER_V2").is_ok() { + features.enable(FeatureFlag::ENABLE_LOADER_V2); + } else { + features.disable(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::(&mut sha3_256, state_view) diff --git a/aptos-move/aptos-vm/src/move_vm_ext/vm.rs b/aptos-move/aptos-vm/src/move_vm_ext/vm.rs index a5eb957339e5a..9eb51cc7a604d 100644 --- a/aptos-move/aptos-vm/src/move_vm_ext/vm.rs +++ b/aptos-move/aptos-vm/src/move_vm_ext/vm.rs @@ -18,6 +18,7 @@ use aptos_vm_environment::{ use aptos_vm_types::storage::change_set_configs::ChangeSetConfigs; use move_vm_runtime::{move_vm::MoveVM, RuntimeEnvironment, WithRuntimeEnvironment}; use std::ops::Deref; +use aptos_types::on_chain_config::FeatureFlag; /// Used by genesis to create runtime environment and VM ([GenesisMoveVM]), encapsulating all /// configs. @@ -30,7 +31,13 @@ pub struct GenesisRuntimeBuilder { impl GenesisRuntimeBuilder { /// Returns a builder, capable of creating VM and runtime environment to run genesis. pub fn new(chain_id: ChainId) -> Self { - let features = Features::default(); + let mut features = Features::default(); + if std::env::var("USE_LOADER_V2").is_ok() { + features.enable(FeatureFlag::ENABLE_LOADER_V2); + } else { + features.disable(FeatureFlag::ENABLE_LOADER_V2); + } + let timed_features = TimedFeaturesBuilder::enable_all().build(); let vm_config = diff --git a/crates/transaction-generator-lib/src/publishing/raw_module_data.rs b/crates/transaction-generator-lib/src/publishing/raw_module_data.rs index ba469c4cfcf58..bfcf74587c2c4 100644 --- a/crates/transaction-generator-lib/src/publishing/raw_module_data.rs +++ b/crates/transaction-generator-lib/src/publishing/raw_module_data.rs @@ -3864,10 +3864,10 @@ pub static MODULES_MODULE_LOADING_CHAIN_FRIENDS: Lazy>> = Lazy::new( pub static PACKAGE_SIMPLE_METADATA: Lazy> = Lazy::new(|| { vec![ 13, 71, 101, 110, 101, 114, 105, 99, 77, 111, 100, 117, 108, 101, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 64, 68, 48, 69, 53, 68, 55, 70, 65, 50, 66, 65, 54, - 68, 50, 65, 48, 57, 55, 55, 56, 51, 49, 51, 67, 57, 68, 69, 51, 56, 67, - 69, 69, 68, 49, 49, 49, 68, 65, 70, 49, 67, 66, 53, 53, 56, 54, 52, 65, - 67, 65, 52, 55, 56, 49, 53, 67, 65, 52, 53, 57, 66, 49, 66, 66, 132, 1, + 0, 0, 0, 0, 0, 64, 69, 53, 53, 57, 68, 57, 51, 68, 67, 55, 70, 65, + 56, 70, 70, 66, 70, 53, 70, 65, 57, 48, 49, 52, 57, 69, 49, 65, 56, 48, + 56, 55, 57, 67, 65, 52, 56, 50, 66, 67, 52, 67, 48, 50, 48, 51, 51, 50, + 53, 53, 52, 67, 50, 67, 48, 52, 49, 56, 67, 54, 56, 56, 53, 69, 132, 1, 31, 139, 8, 0, 0, 0, 0, 0, 2, 255, 77, 139, 59, 14, 194, 48, 16, 68, 251, 61, 133, 229, 30, 135, 11, 80, 208, 64, 197, 9, 162, 20, 43, 123, 64, 86, 156, 93, 203, 134, 80, 32, 238, 142, 45, 1, 138, 102, 154, 249, 188, 49, 179, 159, @@ -3887,6 +3887,16 @@ pub static PACKAGE_SIMPLE_METADATA: Lazy> = Lazy::new(|| { ] }); +#[rustfmt::skip] +pub static SCRIPT_SIMPLE: Lazy> = Lazy::new(|| { + vec![ + 161, 28, 235, 11, 7, 0, 0, 10, 2, 5, 0, 4, 6, 4, 34, 1, 6, 12, + 0, 5, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 1, 3, 11, 0, 1, 2, + ] +}); + #[rustfmt::skip] pub static MODULE_SIMPLE_SIMPLE: Lazy> = Lazy::new(|| { vec![ diff --git a/third_party/move/move-vm/runtime/src/config.rs b/third_party/move/move-vm/runtime/src/config.rs index 5eebeba504cbe..81584ce0f8178 100644 --- a/third_party/move/move-vm/runtime/src/config.rs +++ b/third_party/move/move-vm/runtime/src/config.rs @@ -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: false, + use_loader_v2: std::env::var("USE_LOADER_V2").is_ok(), } } } diff --git a/types/src/on_chain_config/aptos_features.rs b/types/src/on_chain_config/aptos_features.rs index d1297014ad21f..ff069bab6559d 100644 --- a/types/src/on_chain_config/aptos_features.rs +++ b/types/src/on_chain_config/aptos_features.rs @@ -196,6 +196,11 @@ impl Default for Features { for feature in FeatureFlag::default_features() { features.enable(feature); } + if std::env::var("USE_LOADER_V2").is_ok() { + features.enable(FeatureFlag::ENABLE_LOADER_V2); + } else { + features.disable(FeatureFlag::ENABLE_LOADER_V2); + } features } }