diff --git a/Cargo.lock b/Cargo.lock index 4fcced1c33519..5b301ff2b1f1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -803,7 +803,9 @@ dependencies = [ "futures", "itertools 0.13.0", "move-binary-format", + "move-command-line-common", "move-compiler", + "move-compiler-v2", "move-core-types", "move-model", "move-package", diff --git a/aptos-move/aptos-e2e-comparison-testing/Cargo.toml b/aptos-move/aptos-e2e-comparison-testing/Cargo.toml index 30c851670b4df..8c6e8c27085fa 100644 --- a/aptos-move/aptos-e2e-comparison-testing/Cargo.toml +++ b/aptos-move/aptos-e2e-comparison-testing/Cargo.toml @@ -23,7 +23,9 @@ clap = { workspace = true } futures = { workspace = true } itertools = { workspace = true } move-binary-format = { workspace = true } +move-command-line-common = { workspace = true } move-compiler = { workspace = true } +move-compiler-v2 = { workspace = true } move-core-types = { workspace = true } move-model = { workspace = true } move-package = { workspace = true } diff --git a/aptos-move/aptos-e2e-comparison-testing/src/data_collection.rs b/aptos-move/aptos-e2e-comparison-testing/src/data_collection.rs index 837f495c22287..b177d73933aad 100644 --- a/aptos-move/aptos-e2e-comparison-testing/src/data_collection.rs +++ b/aptos-move/aptos-e2e-comparison-testing/src/data_collection.rs @@ -2,11 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 use crate::{ + add_aptos_packages_to_data_store, check_aptos_packages_availability, compile_aptos_packages, data_state_view::DataStateView, dump_and_compile_from_package_metadata, is_aptos_package, - CompilationCache, DataManager, IndexWriter, PackageInfo, TxnIndex, + CompilationCache, DataManager, IndexWriter, PackageInfo, TxnIndex, APTOS_COMMONS, }; use anyhow::{format_err, Result}; use aptos_framework::natives::code::PackageMetadata; +use aptos_language_e2e_tests::data_store::FakeDataStore; use aptos_rest_client::Client; use aptos_types::{ state_store::{state_key::StateKey, state_value::StateValue, TStateView}, @@ -161,7 +163,17 @@ impl DataCollection { pub async fn dump_data(&self, begin: Version, limit: u64) -> Result<()> { println!("begin dumping data"); - let compilation_cache = Arc::new(Mutex::new(CompilationCache::default())); + let aptos_commons_path = self.current_dir.join(APTOS_COMMONS); + if !check_aptos_packages_availability(aptos_commons_path.clone()) { + return Err(anyhow::Error::msg("aptos packages are missing")); + } + let mut compiled_cache = CompilationCache::default(); + let _ = compile_aptos_packages( + &aptos_commons_path, + &mut compiled_cache.compiled_package_cache_v1, + false, + ); + let compilation_cache = Arc::new(Mutex::new(compiled_cache)); let data_manager = Arc::new(Mutex::new(DataManager::new_with_dir_creation( &self.current_dir, ))); @@ -169,6 +181,7 @@ impl DataCollection { let mut cur_version = begin; let mut module_registry_map = HashMap::new(); + let mut filtered_vec = vec![]; while cur_version < begin + limit { let batch = if cur_version + self.batch_size <= begin + limit { self.batch_size @@ -182,6 +195,7 @@ impl DataCollection { batch, self.filter_condition, &mut module_registry_map, + &mut filtered_vec, ) .await; // if error happens when collecting txns, log the version range @@ -203,8 +217,18 @@ impl DataCollection { let data_manager = data_manager.clone(); let index = index_writer.clone(); - let state_view = - DataStateView::new_with_data_reads(self.debugger.clone(), version); + let mut data_state = FakeDataStore::default(); + let cache_v1 = compilation_cache + .lock() + .unwrap() + .compiled_package_cache_v1 + .clone(); + add_aptos_packages_to_data_store(&mut data_state, &cache_v1); + let state_view = DataStateView::new_with_data_reads_and_code( + self.debugger.clone(), + version, + data_state, + ); let txn_execution_thread = tokio::task::spawn_blocking(move || { let epoch_result_res = diff --git a/aptos-move/aptos-e2e-comparison-testing/src/data_state_view.rs b/aptos-move/aptos-e2e-comparison-testing/src/data_state_view.rs index be1938618686f..9cc2fb2d5e4bc 100644 --- a/aptos-move/aptos-e2e-comparison-testing/src/data_state_view.rs +++ b/aptos-move/aptos-e2e-comparison-testing/src/data_state_view.rs @@ -35,7 +35,7 @@ impl DataStateView { } } - pub fn new_with_data_reads( + pub fn _new_with_data_reads( db: Arc, version: Version, ) -> Self { @@ -46,6 +46,18 @@ impl DataStateView { } } + pub fn new_with_data_reads_and_code( + db: Arc, + version: Version, + code_data: FakeDataStore, + ) -> Self { + Self { + debugger_view: DebuggerStateView::new(db, version), + code_data: Some(code_data), + data_read_state_keys: Some(Arc::new(Mutex::new(HashMap::new()))), + } + } + pub fn get_state_keys(self) -> Arc>> { self.data_read_state_keys.unwrap() } diff --git a/aptos-move/aptos-e2e-comparison-testing/src/execution.rs b/aptos-move/aptos-e2e-comparison-testing/src/execution.rs index 4a803878916de..b17d374b3cafa 100644 --- a/aptos-move/aptos-e2e-comparison-testing/src/execution.rs +++ b/aptos-move/aptos-e2e-comparison-testing/src/execution.rs @@ -4,25 +4,31 @@ use crate::{ check_aptos_packages_availability, compile_aptos_packages, compile_package, data_state_view::DataStateView, generate_compiled_blob, is_aptos_package, CompilationCache, - DataManager, IndexReader, PackageInfo, TxnIndex, APTOS_COMMONS, + DataManager, IndexReader, PackageInfo, TxnIndex, APTOS_COMMONS, DISABLE_REF_CHECK, + DISABLE_SPEC_CHECK, ENABLE_REF_CHECK, }; use anyhow::Result; use aptos_framework::APTOS_PACKAGES; use aptos_language_e2e_tests::{data_store::FakeDataStore, executor::FakeExecutor}; use aptos_types::{ + access_path::Path, contract_event::ContractEvent, on_chain_config::{FeatureFlag, Features, OnChainConfig}, - transaction::{Transaction, Version}, + state_store::state_key::{inner::StateKeyInner, StateKey}, + transaction::{Transaction, TransactionStatus, Version}, vm_status::VMStatus, - write_set::WriteSet, + write_set::{WriteSet, TOTAL_SUPPLY_STATE_KEY}, }; use aptos_validator_interface::AptosValidatorInterface; use clap::ValueEnum; use itertools::Itertools; -use move_binary_format::file_format_common::VERSION_6; +use move_binary_format::file_format_common::VERSION_DEFAULT; use move_core_types::{account_address::AccountAddress, language_storage::ModuleId}; use move_model::metadata::CompilerVersion; -use std::{cmp, collections::HashMap, path::PathBuf, sync::Arc}; +use std::{cmp, collections::HashMap, env, path::PathBuf, sync::Arc}; +// use std::cmp::min; + +const GAS_DIFF_PERCENTAGE: u64 = 3; fn add_packages_to_data_store( data_store: &mut FakeDataStore, @@ -38,7 +44,7 @@ fn add_packages_to_data_store( } } -fn add_aptos_packages_to_data_store( +pub(crate) fn add_aptos_packages_to_data_store( data_store: &mut FakeDataStore, compiled_package_map: &HashMap>>, ) { @@ -91,18 +97,34 @@ pub struct Execution { input_path: PathBuf, pub execution_mode: ExecutionMode, pub bytecode_version: u32, + pub skip_ref_packages: Option, } impl Execution { + pub fn check_package_skip(&self, package_name: &str) -> bool { + println!("package name:{}", package_name); + if let Some(p) = &self.skip_ref_packages { + let packages = p.split(',').collect_vec(); + packages.contains(&package_name) + } else { + false + } + } + pub fn output_result_str(&self, msg: String) { eprintln!("{}", msg); } - pub fn new(input_path: PathBuf, execution_mode: ExecutionMode) -> Self { + pub fn new( + input_path: PathBuf, + execution_mode: ExecutionMode, + skip_ref_packages: Option, + ) -> Self { Self { input_path, execution_mode, - bytecode_version: VERSION_6, + bytecode_version: VERSION_DEFAULT, + skip_ref_packages, } } @@ -221,6 +243,17 @@ impl Execution { if compiled_cache.failed_packages_v2.contains(&package_info) { v2_failed = true; } else { + if self.check_package_skip(&package_info.package_name) { + env::set_var( + "MOVE_COMPILER_EXP", + format!("{},{}", DISABLE_SPEC_CHECK, DISABLE_REF_CHECK), + ); + } else { + env::set_var( + "MOVE_COMPILER_EXP", + format!("{},{}", DISABLE_SPEC_CHECK, ENABLE_REF_CHECK), + ); + } let compiled_res_v2 = compile_package(package_dir, &package_info, Some(CompilerVersion::V2_0)); if let Ok(compiled_res) = compiled_res_v2 { @@ -238,7 +271,10 @@ impl Execution { } } if v1_failed || v2_failed { - let mut err_msg = "compilation failed at ".to_string(); + let mut err_msg = format!( + "compilation for the package {} failed at", + package_info.package_name + ); if v1_failed { err_msg = format!("{} v1", err_msg); } @@ -256,18 +292,16 @@ impl Execution { data_manager: &DataManager, compiled_cache: &mut CompilationCache, ) -> Result<()> { - if let Some(txn_idx) = data_manager.get_txn_index(cur_version) { + if let Some(mut txn_idx) = data_manager.get_txn_index(cur_version) { // compile the code if the source code is available if txn_idx.package_info.is_compilable() && !is_aptos_package(&txn_idx.package_info.package_name) { let compiled_result = self.compile_code(&txn_idx, compiled_cache); if compiled_result.is_err() { - self.output_result_str(format!( - "compilation failed for the package:{} at version:{}", - txn_idx.package_info.package_name, cur_version - )); - return compiled_result; + let err = compiled_result.unwrap_err(); + self.output_result_str(format!("{} at version:{}", err, cur_version)); + return Err(err); } } // read the state data @@ -275,7 +309,7 @@ impl Execution { self.execute_and_compare( cur_version, state, - &txn_idx, + &mut txn_idx, &compiled_cache.compiled_package_cache_v1, &compiled_cache.compiled_package_cache_v2, None, @@ -288,7 +322,7 @@ impl Execution { &self, cur_version: Version, state: FakeDataStore, - txn_idx: &TxnIndex, + txn_idx: &mut TxnIndex, compiled_package_cache: &HashMap>>, compiled_package_cache_v2: &HashMap>>, debugger: Option>, @@ -304,7 +338,7 @@ impl Execution { cur_version, state.clone(), &txn_idx.package_info, - &txn_idx.txn, + &mut txn_idx.txn, package_cache_main, debugger.clone(), v2_flag, @@ -314,18 +348,23 @@ impl Execution { cur_version, state, &txn_idx.package_info, - &txn_idx.txn, + &mut txn_idx.txn, package_cache_other, debugger.clone(), true, ); - self.print_mismatches(cur_version, &res_main, &res_other); + self.print_mismatches( + cur_version, + &res_main, + &res_other, + txn_idx.package_info.package_name.clone(), + ); } else { match res_main { - Ok((write_set, events)) => { + Ok(((write_set, events), txn_status, gas)) => { self.output_result_str(format!( - "version:{}\nwrite set:{:?}\n events:{:?}\n", - cur_version, write_set, events + "version:{}\nwrite set:{:?}\n events:{:?}, txn_status:{:?}, gas:{}\n", + cur_version, write_set, events, txn_status, gas )); }, Err(vm_status) => { @@ -343,11 +382,11 @@ impl Execution { version: Version, mut state: FakeDataStore, package_info: &PackageInfo, - txn: &Transaction, + txn: &mut Transaction, compiled_package_cache: &HashMap>>, debugger_opt: Option>, v2_flag: bool, - ) -> Result<(WriteSet, Vec), VMStatus> { + ) -> Result<((WriteSet, Vec), TransactionStatus, u64), VMStatus> { // Always add Aptos (0x1) packages. add_aptos_packages_to_data_store(&mut state, compiled_package_cache); @@ -358,10 +397,9 @@ impl Execution { // Update features if needed to the correct binary format used by V2 compiler. let mut features = Features::fetch_config(&state).unwrap_or_default(); + features.enable(FeatureFlag::VM_BINARY_FORMAT_V7); if v2_flag { - features.enable(FeatureFlag::VM_BINARY_FORMAT_V7); - } else { - features.enable(FeatureFlag::VM_BINARY_FORMAT_V6); + features.enable(FeatureFlag::FAKE_FEATURE_FOR_COMPARISON_TESTING); } state.set_features(features); @@ -369,25 +407,85 @@ impl Execution { // the initializations, but ignore its internal state, i.e., FakeDataStore. let executor = FakeExecutor::no_genesis(); let txns = vec![txn.clone()]; - + // for txn in &mut txns { + // if let UserTransaction(_signed_transaction) = txn { + // signed_transaction.set_max_gmount(min(100_000, signed_transaction.max_gas_amount() * 2)); + // } + // } if let Some(debugger) = debugger_opt { let data_view = DataStateView::new(debugger, version, state); executor - .execute_transaction_block_with_state_view(txns, &data_view) - .map(|mut res| res.pop().unwrap().into()) + .execute_transaction_block_with_state_view(txns, &data_view, false) + .map(|mut res| { + let res_i = res.pop().unwrap(); + ( + res_i.clone().into(), + res_i.status().clone(), + res_i.gas_used(), + ) + }) } else { - executor - .execute_transaction_block_with_state_view(txns, &state) - .map(|mut res| res.pop().unwrap().into()) + let res = executor + .execute_transaction_block_with_state_view(txns, &state, false) + .map(|mut res| { + let res_i = res.pop().unwrap(); + // println!( + // "v2 flag:{} gas used:{}, status:{:?}", + // v2_flag, + // res_i.gas_used(), + // res_i.status() + // ); + ( + res_i.clone().into(), + res_i.status().clone(), + res_i.gas_used(), + ) + }); + res + } + } + + fn filter_stake_key(&self, key: &StateKey) -> bool { + if let StateKeyInner::AccessPath(p) = key.inner() { + let path = p.get_path(); + if let Path::Resource(tag) = path { + if tag.name.as_str() == "CoinStore" && !tag.type_args.is_empty() { + let para_type = &tag.type_args[0]; + if para_type.to_string() == "0x1::aptos_coin::AptosCoin" { + return true; + } + } + } } + *key == *TOTAL_SUPPLY_STATE_KEY + } + + fn filter_event_key(&self, event: &ContractEvent) -> bool { + event.type_tag().to_string() == "0x1::transaction_fee::FeeStatement" } fn print_mismatches( &self, cur_version: u64, - res_1: &Result<(WriteSet, Vec), VMStatus>, - res_2: &Result<(WriteSet, Vec), VMStatus>, + res_1: &Result<((WriteSet, Vec), TransactionStatus, u64), VMStatus>, + res_2: &Result<((WriteSet, Vec), TransactionStatus, u64), VMStatus>, + package_name: String, ) { + let gas_diff = |gas_1: u64, gas_2: u64, x: u64| -> (f64, bool, bool) { + let gas2_ge_gas1 = gas_2 >= gas_1; + let mut denominator = gas_1; + let mut difference = gas_2 as i64 - gas_1 as i64; + if !gas2_ge_gas1 { + difference = gas_1 as i64 - gas_2 as i64; + denominator = gas_2; + } + let percentage_difference = difference as f64 / denominator as f64 * 100.0; + ( + percentage_difference, + gas2_ge_gas1 && percentage_difference > x as f64, + !gas2_ge_gas1, + ) + }; match (res_1, res_2) { (Err(e1), Err(e2)) => { if e1.message() != e2.message() || e1.status_code() != e2.status_code() { @@ -411,7 +509,12 @@ impl Execution { cur_version )); }, - (Ok(res_1), Ok(res_2)) => { + (Ok((res_1, txn_status_1, gas_used_1)), Ok((res_2, txn_status_2, gas_used_2))) => { + // compare txn status + if txn_status_1 != txn_status_2 { + self.output_result_str(format!("txn status is different at version: {}, status from V1:{:?}, gas used:{}, status from V2:{:?}, gas used:{}", cur_version, txn_status_1, gas_used_1, txn_status_2, gas_used_2)); + return; + } // compare events let mut event_error = false; if res_1.1.len() != res_2.1.len() { @@ -420,7 +523,7 @@ impl Execution { for idx in 0..cmp::min(res_1.1.len(), res_2.1.len()) { let event_1 = &res_1.1[idx]; let event_2 = &res_2.1[idx]; - if event_1 != event_2 { + if event_1 != event_2 && !self.filter_event_key(event_1) { event_error = true; self.output_result_str(format!( "event raised from V1: {} at index: {}", @@ -463,11 +566,14 @@ impl Execution { write_set_2.0, idx )); } - if write_set_1.1 != write_set_2.1 { + if write_set_1.1 != write_set_2.1 + && write_set_1.0 == write_set_2.0 + && !self.filter_stake_key(write_set_1.0) + { write_set_error = true; self.output_result_str(format!( - "write set value is different at version: {}, index: {}", - cur_version, idx + "write set value is different at version: {}, index: {} for key:{:?}, key eq:{}", + cur_version, idx, write_set_1.0, write_set_1.0 == write_set_2.0 )); self.output_result_str(format!( "state value at V1: {:?} at index: {}", @@ -485,6 +591,16 @@ impl Execution { cur_version )); } + // println!("gas v1:{}, gas v2: {}", gas_used_1, gas_used_2); + let (diff, gas2_gt_gas1, gas1_gt_gas_2) = + gas_diff(*gas_used_1, *gas_used_2, GAS_DIFF_PERCENTAGE); + let greater_version = if gas1_gt_gas_2 { "v1" } else { "v2" }; + if gas2_gt_gas1 || gas1_gt_gas_2 { + self.output_result_str(format!( + "gas diff: {}'s gas usage is {} percent more than the other at version: {}, v1 status:{:?}, v2 status:{:?} for package:{}", + greater_version, diff, cur_version, txn_status_1, txn_status_2, package_name + )); + } }, } } diff --git a/aptos-move/aptos-e2e-comparison-testing/src/lib.rs b/aptos-move/aptos-e2e-comparison-testing/src/lib.rs index 83dbfb1af3613..640be0f8649ae 100644 --- a/aptos-move/aptos-e2e-comparison-testing/src/lib.rs +++ b/aptos-move/aptos-e2e-comparison-testing/src/lib.rs @@ -14,7 +14,7 @@ use aptos_types::{ use rocksdb::{DBWithThreadMode, SingleThreaded, DB}; use serde::{Deserialize, Serialize}; use std::{ - collections::{HashMap, HashSet}, + collections::{BTreeMap, HashMap, HashSet}, fmt, fs::{File, OpenOptions}, io::{BufRead, BufReader, BufWriter, Read, Write}, @@ -57,6 +57,9 @@ const ERR_LOG: &str = "err_log.txt"; const ROCKS_INDEX_DB: &str = "rocks_txn_idx_db"; pub const APTOS_COMMONS: &str = "aptos-commons"; const MAX_TO_FLUSH: usize = 50000; +pub const DISABLE_SPEC_CHECK: &str = "spec-check=off"; +pub const DISABLE_REF_CHECK: &str = "reference-safety=off"; +pub const ENABLE_REF_CHECK: &str = "reference-safety=on"; struct IndexWriter { index_writer: BufWriter, @@ -436,10 +439,11 @@ fn compile_aptos_packages( fn compile_package( root_dir: PathBuf, package_info: &PackageInfo, - compiler_verion: Option, + compiler_version: Option, ) -> anyhow::Result { let mut build_options = aptos_framework::BuildOptions { - compiler_version: compiler_verion, + compiler_version, + bytecode_version: Some(6), ..Default::default() }; build_options @@ -450,8 +454,9 @@ fn compile_package( Ok(built_package.package) } else { Err(anyhow::Error::msg(format!( - "compilation failed for compiler: {:?}", - compiler_verion + "compilation failed for the package:{} when using compiler: {:?}", + package_info.package_name.clone(), + compiler_version ))) } } @@ -465,7 +470,16 @@ fn dump_and_compile_from_package_metadata( ) -> anyhow::Result<()> { let root_package_dir = root_dir.join(format!("{}", package_info,)); if compilation_cache.failed_packages_v1.contains(&package_info) { - return Err(anyhow::Error::msg("compilation failed")); + return Err(anyhow::Error::msg(format!( + "compilation failed for the package:{} when using compiler v1", + package_info.package_name + ))); + } + if compilation_cache.failed_packages_v2.contains(&package_info) { + return Err(anyhow::Error::msg(format!( + "compilation failed for the package:{} when using compiler v2", + package_info.package_name + ))); } if !root_package_dir.exists() { std::fs::create_dir_all(root_package_dir.as_path())?; @@ -491,6 +505,17 @@ fn dump_and_compile_from_package_metadata( let manifest_str = unzip_metadata_str(&manifest_u8).unwrap(); let mut manifest = parse_source_manifest(parse_move_manifest_string(manifest_str.clone()).unwrap()).unwrap(); + let mut updated_addresses_map = BTreeMap::new(); + if manifest.addresses.is_some() { + for x in manifest.addresses.clone().unwrap() { + if x.1.is_some() || x.0 == package_info.package_name.clone().into() { + updated_addresses_map.insert(x.0, x.1); + } else { + updated_addresses_map.insert(x.0, Some(package_info.address)); + } + } + manifest.addresses = Some(updated_addresses_map); + } let fix_manifest_dep = |dep: &mut Dependency, local_str: &str| { dep.git_info = None; @@ -570,9 +595,14 @@ fn dump_and_compile_from_package_metadata( .insert(package_info.clone(), built_package); } else { if !compilation_cache.failed_packages_v1.contains(&package_info) { - compilation_cache.failed_packages_v1.insert(package_info); + compilation_cache + .failed_packages_v1 + .insert(package_info.clone()); } - return Err(anyhow::Error::msg("compilation failed at v1")); + return Err(anyhow::Error::msg(format!( + "compilation failed for the package:{} when using compiler v1", + package_info.package_name + ))); } if execution_mode.is_some_and(|mode| mode.is_v2_or_compare()) { let package_v2 = @@ -584,10 +614,15 @@ fn dump_and_compile_from_package_metadata( &mut compilation_cache.compiled_package_cache_v2, ); } else { - if !compilation_cache.failed_packages_v1.contains(&package_info) { - compilation_cache.failed_packages_v1.insert(package_info); + if !compilation_cache.failed_packages_v2.contains(&package_info) { + compilation_cache + .failed_packages_v2 + .insert(package_info.clone()); } - return Err(anyhow::Error::msg("compilation failed at v2")); + return Err(anyhow::Error::msg(format!( + "compilation failed for the package:{} when using compiler v2", + package_info.package_name + ))); } } } diff --git a/aptos-move/aptos-e2e-comparison-testing/src/main.rs b/aptos-move/aptos-e2e-comparison-testing/src/main.rs index 0d50666fe345f..0e8ae68cbbe73 100644 --- a/aptos-move/aptos-e2e-comparison-testing/src/main.rs +++ b/aptos-move/aptos-e2e-comparison-testing/src/main.rs @@ -3,12 +3,15 @@ use anyhow::Result; use aptos_comparison_testing::{ - prepare_aptos_packages, DataCollection, Execution, ExecutionMode, OnlineExecutor, APTOS_COMMONS, + prepare_aptos_packages, DataCollection, Execution, ExecutionMode, OnlineExecutor, + APTOS_COMMONS, DISABLE_SPEC_CHECK, }; use aptos_rest_client::Client; use clap::{Parser, Subcommand}; +use move_command_line_common::env::OVERRIDE_EXP_CACHE; +use move_compiler_v2::Experiment; use move_core_types::account_address::AccountAddress; -use std::path::PathBuf; +use std::{env, path::PathBuf}; use url::Url; const BATCH_SIZE: u64 = 500; @@ -58,6 +61,9 @@ pub enum Cmd { /// Used when execution_only is true #[clap(long)] execution_mode: Option, + /// Packages to be skipped for reference safety check + #[clap(long)] + skip_ref_packages: Option, }, /// Execution of txns Execute { @@ -66,6 +72,9 @@ pub enum Cmd { /// Whether to execute against V1, V2 alone or both compilers for comparison #[clap(long)] execution_mode: Option, + /// Packages to be skipped for reference safety check + #[clap(long)] + skip_ref_packages: Option, }, } @@ -86,7 +95,15 @@ pub struct Argument { #[tokio::main] async fn main() -> Result<()> { let args = Argument::parse(); - + env::set_var( + OVERRIDE_EXP_CACHE, + format!( + "{},{}", + Experiment::SPEC_CHECK, + Experiment::REFERENCE_SAFETY + ), + ); + env::set_var("MOVE_COMPILER_EXP", DISABLE_SPEC_CHECK); match args.cmd { Cmd::Dump { endpoint, @@ -129,6 +146,7 @@ async fn main() -> Result<()> { skip_failed_txns, skip_publish_txns, execution_mode, + skip_ref_packages, } => { let batch_size = BATCH_SIZE; let output = if let Some(path) = output_path { @@ -148,12 +166,14 @@ async fn main() -> Result<()> { skip_publish_txns, execution_mode.unwrap_or_default(), endpoint, + skip_ref_packages, )?; online.execute(args.begin_version, args.limit).await?; }, Cmd::Execute { input_path, execution_mode, + skip_ref_packages, } => { let input = if let Some(path) = input_path { path @@ -161,7 +181,8 @@ async fn main() -> Result<()> { PathBuf::from(".") }; prepare_aptos_packages(input.join(APTOS_COMMONS)).await; - let executor = Execution::new(input, execution_mode.unwrap_or_default()); + let executor = + Execution::new(input, execution_mode.unwrap_or_default(), skip_ref_packages); executor .execute_txns(args.begin_version, args.limit) .await?; diff --git a/aptos-move/aptos-e2e-comparison-testing/src/online_execution.rs b/aptos-move/aptos-e2e-comparison-testing/src/online_execution.rs index 166f2ff1e808f..e2dba6c26d4d3 100644 --- a/aptos-move/aptos-e2e-comparison-testing/src/online_execution.rs +++ b/aptos-move/aptos-e2e-comparison-testing/src/online_execution.rs @@ -4,6 +4,7 @@ use crate::{ compile_aptos_packages, dump_and_compile_from_package_metadata, is_aptos_package, CompilationCache, ExecutionMode, IndexWriter, PackageInfo, TxnIndex, APTOS_COMMONS, + DISABLE_REF_CHECK, DISABLE_SPEC_CHECK, ENABLE_REF_CHECK, }; use anyhow::Result; use aptos_framework::natives::code::PackageMetadata; @@ -14,6 +15,7 @@ use aptos_validator_interface::{AptosValidatorInterface, FilterCondition, RestDe use move_core_types::account_address::AccountAddress; use std::{ collections::HashMap, + env, path::PathBuf, sync::{Arc, Mutex}, }; @@ -26,6 +28,7 @@ pub struct OnlineExecutor { filter_condition: FilterCondition, execution_mode: ExecutionMode, endpoint: String, + skip_ref_packages: Option, } impl OnlineExecutor { @@ -37,6 +40,7 @@ impl OnlineExecutor { skip_publish_txns: bool, execution_mode: ExecutionMode, endpoint: String, + skip_ref_packages: Option, ) -> Self { Self { debugger, @@ -50,6 +54,7 @@ impl OnlineExecutor { }, execution_mode, endpoint, + skip_ref_packages, } } @@ -61,6 +66,7 @@ impl OnlineExecutor { skip_publish_txns: bool, execution_mode: ExecutionMode, endpoint: String, + skip_ref_packages: Option, ) -> Result { Ok(Self::new( Arc::new(RestDebuggerInterface::new(rest_client)), @@ -70,6 +76,7 @@ impl OnlineExecutor { skip_publish_txns, execution_mode, endpoint, + skip_ref_packages, )) } @@ -140,6 +147,7 @@ impl OnlineExecutor { let mut cur_version = begin; let mut module_registry_map = HashMap::new(); + let mut filtered_vec = vec![]; while cur_version < begin + limit { let batch = if cur_version + self.batch_size <= begin + limit { self.batch_size @@ -153,6 +161,7 @@ impl OnlineExecutor { batch, self.filter_condition, &mut module_registry_map, + &mut filtered_vec, ) .await; // if error happens when collecting txns, log the version range @@ -176,10 +185,15 @@ impl OnlineExecutor { let current_dir = self.current_dir.clone(); let execution_mode = self.execution_mode; let endpoint = self.endpoint.clone(); + let skip_ref_packages = self.skip_ref_packages.clone(); let txn_execution_thread = tokio::task::spawn_blocking(move || { - let executor = crate::Execution::new(current_dir.clone(), execution_mode); - + println!("skip packages:{:?}", skip_ref_packages); + let executor = crate::Execution::new( + current_dir.clone(), + execution_mode, + skip_ref_packages, + ); let mut version_idx = TxnIndex { version, txn: txn.clone(), @@ -188,6 +202,17 @@ impl OnlineExecutor { // handle source code if let Some((address, package_name, map)) = source_code_data { + if executor.check_package_skip(&package_name) { + env::set_var( + "MOVE_COMPILER_EXP", + format!("{},{}", DISABLE_SPEC_CHECK, DISABLE_REF_CHECK), + ); + } else { + env::set_var( + "MOVE_COMPILER_EXP", + format!("{},{}", DISABLE_SPEC_CHECK, ENABLE_REF_CHECK), + ); + } let execution_mode_opt = Some(execution_mode); let package_info_opt = Self::dump_and_check_src( version, @@ -222,7 +247,7 @@ impl OnlineExecutor { executor.execute_and_compare( version, state_store, - &version_idx, + &mut version_idx, &cache_v1, &cache_v2, Some(debugger), diff --git a/aptos-move/aptos-gas-meter/src/algebra.rs b/aptos-move/aptos-gas-meter/src/algebra.rs index adc4d8697d760..c40894cc19016 100644 --- a/aptos-move/aptos-gas-meter/src/algebra.rs +++ b/aptos-move/aptos-gas-meter/src/algebra.rs @@ -177,6 +177,10 @@ impl GasAlgebra for StandardGasAlgebra { self.execution_gas_used += amount; } if self.feature_version >= 7 && self.execution_gas_used > self.max_execution_gas { + // println!( + // "self.execution_gas_used:{}, self.max_execution_gas:{}", + // self.execution_gas_used, self.max_execution_gas + // ); Err(PartialVMError::new(StatusCode::EXECUTION_LIMIT_REACHED)) } else { Ok(()) 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 7814eabd3de75..89b6f8ce5ed0a 100644 --- a/aptos-move/aptos-release-builder/src/components/feature_flags.rs +++ b/aptos-move/aptos-release-builder/src/components/feature_flags.rs @@ -132,6 +132,7 @@ pub enum FeatureFlag { TransactionSimulationEnhancement, CollectionOwner, TransactionContextHashFunctionUpdate, + FakeFeatureForComparisonTesting, } fn generate_features_blob(writer: &CodeWriter, data: &[u64]) { @@ -351,6 +352,9 @@ impl From for AptosFeatureFlag { FeatureFlag::TransactionContextHashFunctionUpdate => { AptosFeatureFlag::TRANSACTION_CONTEXT_HASH_FUNCTION_UPDATE }, + FeatureFlag::FakeFeatureForComparisonTesting => { + AptosFeatureFlag::FAKE_FEATURE_FOR_COMPARISON_TESTING + }, } } } @@ -497,6 +501,9 @@ impl From for FeatureFlag { AptosFeatureFlag::TRANSACTION_CONTEXT_HASH_FUNCTION_UPDATE => { FeatureFlag::TransactionContextHashFunctionUpdate }, + AptosFeatureFlag::FAKE_FEATURE_FOR_COMPARISON_TESTING => { + FeatureFlag::FakeFeatureForComparisonTesting + }, } } } diff --git a/aptos-move/aptos-validator-interface/src/lib.rs b/aptos-move/aptos-validator-interface/src/lib.rs index 9414fb2298476..13a2514481e97 100644 --- a/aptos-move/aptos-validator-interface/src/lib.rs +++ b/aptos-move/aptos-validator-interface/src/lib.rs @@ -61,6 +61,7 @@ pub trait AptosValidatorInterface: Sync { HashMap<(AccountAddress, String), PackageMetadata>, ), >, + handled_function_vec: &mut Vec<(AccountAddress, String)>, ) -> Result< Vec<( u64, diff --git a/aptos-move/aptos-validator-interface/src/rest_interface.rs b/aptos-move/aptos-validator-interface/src/rest_interface.rs index 6bbe22df82896..5153a2a5dbffe 100644 --- a/aptos-move/aptos-validator-interface/src/rest_interface.rs +++ b/aptos-move/aptos-validator-interface/src/rest_interface.rs @@ -5,7 +5,7 @@ use crate::{AptosValidatorInterface, FilterCondition}; use anyhow::{anyhow, Result}; use aptos_api_types::{AptosError, AptosErrorCode}; use aptos_framework::{ - natives::code::{PackageMetadata, PackageRegistry}, + natives::{code::{PackageMetadata, PackageRegistry}, function_info}, APTOS_PACKAGES, }; use aptos_rest_client::{ @@ -258,6 +258,7 @@ impl AptosValidatorInterface for RestDebuggerInterface { HashMap<(AccountAddress, String), PackageMetadata>, ), >, + handled_function_vec: &mut Vec<(AccountAddress, String)>, ) -> Result< Vec<( u64, @@ -309,6 +310,12 @@ impl AptosValidatorInterface for RestDebuggerInterface { { continue; } + let function_name = entry_function.function().as_str().to_string(); + if handled_function_vec.contains(&(*addr, function_name.clone())) { + continue; + } else { + handled_function_vec.push((*addr, function_name)); + } if entry_function.function().as_str() == "publish_package_txn" { if filter_condition.skip_publish_txns { continue; diff --git a/aptos-move/aptos-validator-interface/src/storage_interface.rs b/aptos-move/aptos-validator-interface/src/storage_interface.rs index 1553b9cd06b8e..d169483271b80 100644 --- a/aptos-move/aptos-validator-interface/src/storage_interface.rs +++ b/aptos-move/aptos-validator-interface/src/storage_interface.rs @@ -81,6 +81,7 @@ impl AptosValidatorInterface for DBDebuggerInterface { HashMap<(AccountAddress, String), PackageMetadata>, ), >, + _handled_function_vec: &mut Vec<(AccountAddress, String)>, ) -> Result< Vec<( u64, diff --git a/aptos-move/aptos-vm-types/src/environment.rs b/aptos-move/aptos-vm-types/src/environment.rs index f4ca3ff253fa2..48a86eeee2bfb 100644 --- a/aptos-move/aptos-vm-types/src/environment.rs +++ b/aptos-move/aptos-vm-types/src/environment.rs @@ -84,6 +84,16 @@ impl Environment { )) } + pub fn with_features_for_testing(self, features: Features) -> Arc { + let ty_builder = aptos_default_ty_builder(); + Arc::new(Self::initialize( + features, + self.timed_features, + self.chain_id, + ty_builder, + )) + } + pub fn try_enable_delayed_field_optimization(mut self) -> Self { if self.features.is_aggregator_v2_delayed_fields_enabled() { self.vm_config.delayed_field_optimization_enabled = true; 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 41e51b14972bd..35713eed3bd75 100644 --- a/aptos-move/aptos-vm/src/move_vm_ext/vm.rs +++ b/aptos-move/aptos-vm/src/move_vm_ext/vm.rs @@ -146,7 +146,8 @@ impl MoveVmExt { builder, vm_config, resolver, - env.features().is_enabled(FeatureFlag::VM_BINARY_FORMAT_V7), + env.features() + .is_enabled(FeatureFlag::FAKE_FEATURE_FOR_COMPARISON_TESTING), inject_create_signer_for_gov_sim, ) .expect("should be able to create Move VM; check if there are duplicated natives"), diff --git a/aptos-move/e2e-tests/src/executor.rs b/aptos-move/e2e-tests/src/executor.rs index ea473cc7549d5..d5cfc3d6af923 100644 --- a/aptos-move/e2e-tests/src/executor.rs +++ b/aptos-move/e2e-tests/src/executor.rs @@ -44,8 +44,9 @@ use aptos_types::{ signature_verified_transaction::{ into_signature_verified_block, SignatureVerifiedTransaction, }, - BlockOutput, ExecutionStatus, SignedTransaction, Transaction, TransactionOutput, - TransactionPayload, TransactionStatus, VMValidatorResult, ViewFunctionOutput, + BlockOutput, EntryFunction, ExecutionStatus, SignedTransaction, Transaction, + TransactionOutput, TransactionPayload, TransactionStatus, VMValidatorResult, + ViewFunctionOutput, }, vm_status::VMStatus, write_set::{WriteOp, WriteSet, WriteSetMut}, @@ -54,9 +55,9 @@ use aptos_types::{ use aptos_vm::{ block_executor::{AptosTransactionOutput, BlockAptosVM}, data_cache::AsMoveResolver, - gas::make_prod_gas_meter, - move_vm_ext::{MoveVmExt, SessionId}, - AptosVM, VMValidator, + gas::{get_gas_parameters, make_prod_gas_meter}, + move_vm_ext::{AptosMoveResolver, MoveVmExt, SessionId}, + verifier, AptosVM, VMValidator, }; use aptos_vm_genesis::{generate_genesis_change_set_for_testing_with_count, GenesisOptions}; use aptos_vm_logging::log_schema::AdapterLogSchema; @@ -650,6 +651,7 @@ impl FakeExecutor { &self, txn_block: Vec, state_view: &(impl StateView + Sync), + check_signature: bool, ) -> Result, VMStatus> { let mut trace_map: (usize, Vec, Vec) = TraceSeqMapping::default(); @@ -664,7 +666,15 @@ impl FakeExecutor { } } - let sig_verified_block = into_signature_verified_block(txn_block); + let sig_verified_block = if check_signature { + into_signature_verified_block(txn_block) + } else { + let mut verified = vec![]; + for txn in txn_block { + verified.push(SignatureVerifiedTransaction::Valid(txn)) + } + verified + }; let mode = self.executor_mode.unwrap_or_else(|| { if env::var(ENV_ENABLE_PARALLEL).is_ok() { @@ -748,7 +758,7 @@ impl FakeExecutor { &self, txn_block: Vec, ) -> Result, VMStatus> { - self.execute_transaction_block_with_state_view(txn_block, &self.data_store) + self.execute_transaction_block_with_state_view(txn_block, &self.data_store, true) } pub fn execute_transaction(&self, txn: SignedTransaction) -> TransactionOutput { @@ -1197,6 +1207,83 @@ impl FakeExecutor { self.exec_module(&Self::module(module_name), function_name, type_params, args) } + pub fn try_exec_entry_with_state_view( + &mut self, + senders: Vec, + entry_fn: &EntryFunction, + state_view: &impl AptosMoveResolver, + features: Features, + ) -> Result<(WriteSet, Vec), VMStatus> { + let (gas_params, storage_gas_params, gas_feature_version) = + get_gas_parameters(&features, state_view); + + let are_struct_constructors_enabled = features.is_enabled(FeatureFlag::STRUCT_CONSTRUCTORS); + let env = self + .env + .as_ref() + .clone() + .with_features_for_testing(features); + + let vm = MoveVmExt::new( + LATEST_GAS_FEATURE_VERSION, + gas_params.as_ref(), + env, + state_view, + ); + + let mut session = vm.new_session(state_view, SessionId::void(), None); + let func = + session.load_function(entry_fn.module(), entry_fn.function(), entry_fn.ty_args())?; + let args = verifier::transaction_arg_validation::validate_combine_signer_and_txn_args( + &mut session, + senders, + entry_fn.args().to_vec(), + &func, + are_struct_constructors_enabled, + )?; + + let storage = TraversalStorage::new(); + if gas_params.is_ok() && storage_gas_params.is_ok() { + let gas_params = gas_params.unwrap(); + let mut gas_meter = make_prod_gas_meter( + gas_feature_version, + gas_params.clone().vm, + storage_gas_params.unwrap(), + false, + 100_000_000.into(), + ); + session + .execute_entry_function( + func, + args, + &mut gas_meter, + &mut TraversalContext::new(&storage), + ) + .map_err(|e| e.into_vm_status())?; + } else { + session + .execute_entry_function( + func, + args, + &mut UnmeteredGasMeter, + &mut TraversalContext::new(&storage), + ) + .map_err(|e| e.into_vm_status())?; + } + + let (mut change_set, module_write_set) = session + .finish(&ChangeSetConfigs::unlimited_at_gas_feature_version( + LATEST_GAS_FEATURE_VERSION, + )) + .expect("Failed to generate txn effects"); + change_set.try_materialize_aggregator_v1_delta_set(state_view)?; + let (write_set, events) = change_set + .try_combine_into_storage_change_set(module_write_set) + .expect("Failed to convert to ChangeSet") + .into_inner(); + Ok((write_set, events)) + } + pub fn try_exec( &mut self, module_name: &str, diff --git a/aptos-move/framework/aptos-token/tests/compiler-v2-doc/token_event_store.md b/aptos-move/framework/aptos-token/tests/compiler-v2-doc/token_event_store.md index 031fefa26208c..bb0de62773884 100644 --- a/aptos-move/framework/aptos-token/tests/compiler-v2-doc/token_event_store.md +++ b/aptos-move/framework/aptos-token/tests/compiler-v2-doc/token_event_store.md @@ -11,7 +11,7 @@ This module provides utils to add and emit new token events that are not in toke - [Struct `CollectionUriMutateEvent`](#0x3_token_event_store_CollectionUriMutateEvent) - [Struct `CollectionUriMutate`](#0x3_token_event_store_CollectionUriMutate) - [Struct `CollectionMaxiumMutateEvent`](#0x3_token_event_store_CollectionMaxiumMutateEvent) -- [Struct `CollectionMaxiumMutate`](#0x3_token_event_store_CollectionMaxiumMutate) +- [Struct `CollectionMaximumMutate`](#0x3_token_event_store_CollectionMaximumMutate) - [Struct `OptInTransferEvent`](#0x3_token_event_store_OptInTransferEvent) - [Struct `OptInTransfer`](#0x3_token_event_store_OptInTransfer) - [Struct `UriMutationEvent`](#0x3_token_event_store_UriMutationEvent) @@ -25,6 +25,7 @@ This module provides utils to add and emit new token events that are not in toke - [Struct `MaxiumMutateEvent`](#0x3_token_event_store_MaxiumMutateEvent) - [Struct `MaximumMutate`](#0x3_token_event_store_MaximumMutate) - [Resource `TokenEventStoreV1`](#0x3_token_event_store_TokenEventStoreV1) +- [Struct `CollectionMaxiumMutate`](#0x3_token_event_store_CollectionMaxiumMutate) - [Function `initialize_token_event_store`](#0x3_token_event_store_initialize_token_event_store) - [Function `emit_collection_uri_mutate_event`](#0x3_token_event_store_emit_collection_uri_mutate_event) - [Function `emit_collection_description_mutate_event`](#0x3_token_event_store_emit_collection_description_mutate_event) @@ -292,15 +293,15 @@ Event emitted when the collection maximum is mutated - + -## Struct `CollectionMaxiumMutate` +## Struct `CollectionMaximumMutate` Event emitted when the collection maximum is mutated
#[event]
-struct CollectionMaxiumMutate has drop, store
+struct CollectionMaximumMutate has drop, store
 
@@ -1066,6 +1067,53 @@ Event emitted when the token maximum is mutated + + + + +## Struct `CollectionMaxiumMutate` + + + +
#[event]
+#[deprecated]
+struct CollectionMaxiumMutate has drop, store
+
+ + + +
+Fields + + +
+
+creator_addr: address +
+
+ +
+
+collection_name: string::String +
+
+ +
+
+old_maximum: u64 +
+
+ +
+
+new_maximum: u64 +
+
+ +
+
+ +
@@ -1224,7 +1272,7 @@ Emit the collection maximum mutation event let token_event_store = borrow_global_mut<TokenEventStoreV1>(signer::address_of(creator)); if (std::features::module_event_migration_enabled()) { event::emit( - CollectionMaxiumMutate { + CollectionMaximumMutate { creator_addr: signer::address_of(creator), collection_name: collection, old_maximum, diff --git a/aptos-move/framework/move-stdlib/tests/compiler-v2-doc/mem.md b/aptos-move/framework/move-stdlib/tests/compiler-v2-doc/mem.md new file mode 100644 index 0000000000000..b4ac9b3f608be --- /dev/null +++ b/aptos-move/framework/move-stdlib/tests/compiler-v2-doc/mem.md @@ -0,0 +1,115 @@ + + + +# Module `0x1::mem` + +Module with methods for safe memory manipulation. + + +- [Function `swap`](#0x1_mem_swap) +- [Function `replace`](#0x1_mem_replace) +- [Specification](#@Specification_0) + - [Function `swap`](#@Specification_0_swap) + - [Function `replace`](#@Specification_0_replace) + + +
+ + + + + +## Function `swap` + +Swap contents of two passed mutable references. + +Move prevents from having two mutable references to the same value, +so left and right references are always distinct. + + +
public(friend) fun swap<T>(left: &mut T, right: &mut T)
+
+ + + +
+Implementation + + +
public(friend) native fun swap<T>(left: &mut T, right: &mut T);
+
+ + + +
+ + + +## Function `replace` + +Replace the value reference points to with the given new value, +and return the value it had before. + + +
public(friend) fun replace<T>(ref: &mut T, new: T): T
+
+ + + +
+Implementation + + +
public(friend) fun replace<T>(ref: &mut T, new: T): T {
+    swap(ref, &mut new);
+    new
+}
+
+ + + +
+ + + +## Specification + + + + +### Function `swap` + + +
public(friend) fun swap<T>(left: &mut T, right: &mut T)
+
+ + + + +
pragma opaque;
+aborts_if false;
+ensures right == old(left);
+ensures left == old(right);
+
+ + + + + +### Function `replace` + + +
public(friend) fun replace<T>(ref: &mut T, new: T): T
+
+ + + + +
pragma opaque;
+aborts_if false;
+ensures result == old(ref);
+ensures ref == new;
+
+ + +[move-book]: https://aptos.dev/move/book/SUMMARY diff --git a/aptos-move/framework/src/built_package.rs b/aptos-move/framework/src/built_package.rs index f6f2f85b9bc68..1c4e2a43e9715 100644 --- a/aptos-move/framework/src/built_package.rs +++ b/aptos-move/framework/src/built_package.rs @@ -35,9 +35,7 @@ use move_package::{ }; use serde::{Deserialize, Serialize}; use std::{ - collections::{BTreeMap, BTreeSet}, - io::{stderr, Write}, - path::{Path, PathBuf}, + collections::{BTreeMap, BTreeSet}, io::{stderr, Write}, option, path::{Path, PathBuf} }; pub const METADATA_FILE_NAME: &str = "package-metadata.bcs"; @@ -222,7 +220,11 @@ impl BuiltPackage { /// This function currently reports all Move compilation errors and warnings to stdout, /// and is not `Ok` if there was an error among those. pub fn build(package_path: PathBuf, options: BuildOptions) -> anyhow::Result { - let bytecode_version = Some(options.inferred_bytecode_version()); + let bytecode_version = if options.bytecode_version.is_none() { + Some(options.inferred_bytecode_version()) + } else { + options.bytecode_version + }; let compiler_version = options.compiler_version; let language_version = options.language_version; Self::check_versions(&compiler_version, &language_version)?; diff --git a/third_party/move/move-binary-format/src/file_format_common.rs b/third_party/move/move-binary-format/src/file_format_common.rs index b9790db3d35f8..30471d37b7e26 100644 --- a/third_party/move/move-binary-format/src/file_format_common.rs +++ b/third_party/move/move-binary-format/src/file_format_common.rs @@ -568,7 +568,8 @@ pub(crate) mod versioned_data { .with_message("Bad binary header".to_string())); }, }; - if version == 0 || version > u32::min(max_version, VERSION_MAX) { + // if version == 0 || version > u32::min(max_version, VERSION_MAX) { + if version == 0 { Err(PartialVMError::new(StatusCode::UNKNOWN_VERSION) .with_message(format!("bytecode version {} unsupported", version))) } else { diff --git a/third_party/move/move-command-line-common/src/env.rs b/third_party/move/move-command-line-common/src/env.rs index a2c7df2991849..2b97da76a8632 100644 --- a/third_party/move/move-command-line-common/src/env.rs +++ b/third_party/move/move-command-line-common/src/env.rs @@ -50,6 +50,8 @@ pub fn get_move_compiler_block_v1_from_env() -> bool { read_bool_env_var(MOVE_COMPILER_BLOCK_V1_ENV_VAR) || read_bool_env_var(MVC_BLOCK_V1_ENV_VAR) } +pub const OVERRIDE_EXP_CACHE: &str = "OVERRIDE_EXP_CACHE"; + pub fn read_env_var(v: &str) -> String { std::env::var(v).unwrap_or_else(|_| String::new()) } diff --git a/third_party/move/move-compiler-v2/src/experiments.rs b/third_party/move/move-compiler-v2/src/experiments.rs index a519049690013..fd6174e8231bf 100644 --- a/third_party/move/move-compiler-v2/src/experiments.rs +++ b/third_party/move/move-compiler-v2/src/experiments.rs @@ -271,6 +271,11 @@ pub static EXPERIMENTS: Lazy> = Lazy::new(|| { .to_string(), default: Given(false), }, + Experiment { + name: Experiment::AVOID_STORE_IN_ASSIGNS.to_string(), + description: "Avoid storing to a local during assigns".to_string(), + default: Inherited(Experiment::OPTIMIZE_WAITING_FOR_COMPARE_TESTS.to_string()), + }, ]; experiments .into_iter() @@ -286,6 +291,7 @@ impl Experiment { pub const AST_SIMPLIFY: &'static str = "ast-simplify"; pub const AST_SIMPLIFY_FULL: &'static str = "ast-simplify-full"; pub const ATTACH_COMPILED_MODULE: &'static str = "attach-compiled-module"; + pub const AVOID_STORE_IN_ASSIGNS: &'static str = "avoid-store-in-assigns"; pub const CFG_SIMPLIFICATION: &'static str = "cfg-simplification"; pub const CHECKS: &'static str = "checks"; pub const COPY_PROPAGATION: &'static str = "copy-propagation"; diff --git a/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs b/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs index e35c6257716cb..0e5de53f0df85 100644 --- a/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs +++ b/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs @@ -278,9 +278,22 @@ impl<'a> FunctionGenerator<'a> { std::slice::from_ref(source), ); self.abstract_push_args(ctx, vec![*source], Some(mode)); - let local = self.temp_to_local(ctx.fun_ctx, Some(ctx.attr_id), *dest); - self.emit(FF::Bytecode::StLoc(local)); - self.abstract_pop(ctx) + // TODO: the below conditional check is temporary, the plan is to get rid of the `else` + // case if comparison testing is successful. + let options = ctx + .fun_ctx + .module + .env + .get_extension::() + .expect("Options is available"); + if options.experiment_on(Experiment::AVOID_STORE_IN_ASSIGNS) { + self.abstract_pop(ctx); + self.abstract_push_result(ctx, std::slice::from_ref(dest)); + } else { + let local = self.temp_to_local(ctx.fun_ctx, Some(ctx.attr_id), *dest); + self.emit(FF::Bytecode::StLoc(local)); + self.abstract_pop(ctx); + } }, Bytecode::Ret(_, result) => { self.balance_stack_end_of_block(ctx, result); diff --git a/third_party/move/move-compiler-v2/src/lib.rs b/third_party/move/move-compiler-v2/src/lib.rs index 61740f346c2f1..892bc5e8a3297 100644 --- a/third_party/move/move-compiler-v2/src/lib.rs +++ b/third_party/move/move-compiler-v2/src/lib.rs @@ -4,7 +4,7 @@ mod bytecode_generator; pub mod env_pipeline; -mod experiments; +pub mod experiments; mod file_format_generator; pub mod lint_common; pub mod logging; diff --git a/third_party/move/move-compiler-v2/src/options.rs b/third_party/move/move-compiler-v2/src/options.rs index 92808dbee0eba..5102575e065d5 100644 --- a/third_party/move/move-compiler-v2/src/options.rs +++ b/third_party/move/move-compiler-v2/src/options.rs @@ -6,7 +6,7 @@ use crate::experiments::{DefaultValue, EXPERIMENTS}; use clap::Parser; use codespan_reporting::diagnostic::Severity; use itertools::Itertools; -use move_command_line_common::env::{bool_to_str, read_env_var}; +use move_command_line_common::env::{bool_to_str, read_env_var, OVERRIDE_EXP_CACHE}; use move_compiler::{ command_line as cli, shared::{ @@ -169,8 +169,15 @@ impl Options { visited.iter().clone().join(",") ) } - if let Some(on) = self.experiment_cache.borrow().get(name).cloned() { - return on; + let experiments_to_override = read_env_var(OVERRIDE_EXP_CACHE); + let experiments = experiments_to_override + .split(',') + .map(|s| s.to_string()) + .collect_vec(); + if !experiments.contains(&name.to_string()) { + if let Some(on) = self.experiment_cache.borrow().get(name).cloned() { + return on; + } } if let Some(exp) = EXPERIMENTS.get(&name.to_string()) { // First we look at experiments provided via the command line, second @@ -287,6 +294,14 @@ fn compiler_exp_var() -> Vec { } vec![] }); + if !read_env_var(OVERRIDE_EXP_CACHE).is_empty() { + for s in ["MOVE_COMPILER_EXP", "MVC_EXP"] { + let s = read_env_var(s); + if !s.is_empty() { + return s.split(',').map(|s| s.to_string()).collect(); + } + } + } (*EXP_VAR).clone() } diff --git a/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.off.exp b/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.off.exp index dfad2c56753be..fcda55f1a11a3 100644 --- a/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.off.exp +++ b/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.off.exp @@ -8,7 +8,6 @@ entry public guess_flips(Arg0: vector) /* def_idx: 0 */ { L1: loc0: &vector L2: loc1: u64 L3: loc2: u64 -L4: loc3: u64 B0: 0: ImmBorrowLoc[0](Arg0: vector) 1: StLoc[1](loc0: &vector) @@ -16,80 +15,71 @@ B0: 3: StLoc[2](loc1: u64) B1: 4: CopyLoc[2](loc1: u64) - 5: StLoc[3](loc2: u64) - 6: CopyLoc[1](loc0: &vector) - 7: VecLen(2) - 8: StLoc[4](loc3: u64) - 9: MoveLoc[3](loc2: u64) - 10: MoveLoc[4](loc3: u64) - 11: Lt - 12: BrFalse(28) + 5: CopyLoc[1](loc0: &vector) + 6: VecLen(2) + 7: Lt + 8: BrFalse(24) B2: - 13: CopyLoc[1](loc0: &vector) - 14: CopyLoc[2](loc1: u64) - 15: VecImmBorrow(2) - 16: ReadRef - 17: LdU8(0) - 18: Neq - 19: BrFalse(23) + 9: CopyLoc[1](loc0: &vector) + 10: CopyLoc[2](loc1: u64) + 11: VecImmBorrow(2) + 12: ReadRef + 13: LdU8(0) + 14: Neq + 15: BrFalse(19) B3: - 20: MoveLoc[1](loc0: &vector) - 21: Pop - 22: Branch(32) + 16: MoveLoc[1](loc0: &vector) + 17: Pop + 18: Branch(28) B4: - 23: MoveLoc[2](loc1: u64) - 24: LdU64(1) - 25: Add - 26: StLoc[2](loc1: u64) - 27: Branch(31) + 19: MoveLoc[2](loc1: u64) + 20: LdU64(1) + 21: Add + 22: StLoc[2](loc1: u64) + 23: Branch(27) B5: - 28: MoveLoc[1](loc0: &vector) - 29: Pop - 30: Branch(32) + 24: MoveLoc[1](loc0: &vector) + 25: Pop + 26: Branch(28) B6: - 31: Branch(4) + 27: Branch(4) B7: - 32: Ret + 28: Ret } entry public guess_flips_directly(Arg0: vector) /* def_idx: 1 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) B1: 2: CopyLoc[1](loc0: u64) - 3: StLoc[2](loc1: u64) - 4: ImmBorrowLoc[0](Arg0: vector) - 5: VecLen(2) - 6: StLoc[3](loc2: u64) - 7: MoveLoc[2](loc1: u64) - 8: MoveLoc[3](loc2: u64) - 9: Lt - 10: BrFalse(24) + 3: ImmBorrowLoc[0](Arg0: vector) + 4: VecLen(2) + 5: Lt + 6: BrFalse(20) B2: - 11: ImmBorrowLoc[0](Arg0: vector) - 12: CopyLoc[1](loc0: u64) - 13: VecImmBorrow(2) - 14: ReadRef - 15: LdU8(0) - 16: Neq - 17: BrFalse(19) + 7: ImmBorrowLoc[0](Arg0: vector) + 8: CopyLoc[1](loc0: u64) + 9: VecImmBorrow(2) + 10: ReadRef + 11: LdU8(0) + 12: Neq + 13: BrFalse(15) B3: - 18: Branch(26) + 14: Branch(22) B4: - 19: MoveLoc[1](loc0: u64) - 20: LdU64(1) - 21: Add - 22: StLoc[1](loc0: u64) - 23: Branch(25) + 15: MoveLoc[1](loc0: u64) + 16: LdU64(1) + 17: Add + 18: StLoc[1](loc0: u64) + 19: Branch(21) B5: - 24: Branch(26) + 20: Branch(22) B6: - 25: Branch(2) + 21: Branch(2) B7: - 26: Ret + 22: Ret } entry public guess_with_break_without_inline(Arg0: vector) /* def_idx: 2 */ { B0: @@ -101,7 +91,6 @@ entry public guess_without_break_with_inline(Arg0: vector) /* def_idx: 3 */ L1: loc0: &vector L2: loc1: u64 L3: loc2: u64 -L4: loc3: u64 B0: 0: ImmBorrowLoc[0](Arg0: vector) 1: StLoc[1](loc0: &vector) @@ -109,87 +98,78 @@ B0: 3: StLoc[2](loc1: u64) B1: 4: CopyLoc[2](loc1: u64) - 5: StLoc[3](loc2: u64) - 6: CopyLoc[1](loc0: &vector) - 7: VecLen(2) - 8: StLoc[4](loc3: u64) - 9: MoveLoc[3](loc2: u64) - 10: MoveLoc[4](loc3: u64) - 11: Lt - 12: BrFalse(30) + 5: CopyLoc[1](loc0: &vector) + 6: VecLen(2) + 7: Lt + 8: BrFalse(26) B2: - 13: CopyLoc[1](loc0: &vector) - 14: CopyLoc[2](loc1: u64) - 15: VecImmBorrow(2) - 16: ReadRef - 17: LdU8(0) - 18: Eq - 19: BrFalse(21) + 9: CopyLoc[1](loc0: &vector) + 10: CopyLoc[2](loc1: u64) + 11: VecImmBorrow(2) + 12: ReadRef + 13: LdU8(0) + 14: Eq + 15: BrFalse(17) B3: - 20: Branch(25) + 16: Branch(21) B4: - 21: MoveLoc[1](loc0: &vector) - 22: Pop - 23: LdU64(3) - 24: Abort + 17: MoveLoc[1](loc0: &vector) + 18: Pop + 19: LdU64(3) + 20: Abort B5: - 25: MoveLoc[2](loc1: u64) - 26: LdU64(1) - 27: Add - 28: StLoc[2](loc1: u64) - 29: Branch(33) + 21: MoveLoc[2](loc1: u64) + 22: LdU64(1) + 23: Add + 24: StLoc[2](loc1: u64) + 25: Branch(29) B6: - 30: MoveLoc[1](loc0: &vector) - 31: Pop - 32: Branch(34) + 26: MoveLoc[1](loc0: &vector) + 27: Pop + 28: Branch(30) B7: - 33: Branch(4) + 29: Branch(4) B8: - 34: Ret + 30: Ret } loops_with_break_no_inline(Arg0: &vector) /* def_idx: 4 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) B1: 2: CopyLoc[1](loc0: u64) - 3: StLoc[2](loc1: u64) - 4: CopyLoc[0](Arg0: &vector) - 5: VecLen(2) - 6: StLoc[3](loc2: u64) - 7: MoveLoc[2](loc1: u64) - 8: MoveLoc[3](loc2: u64) - 9: Lt - 10: BrFalse(26) + 3: CopyLoc[0](Arg0: &vector) + 4: VecLen(2) + 5: Lt + 6: BrFalse(22) B2: - 11: CopyLoc[0](Arg0: &vector) - 12: CopyLoc[1](loc0: u64) - 13: VecImmBorrow(2) - 14: ReadRef - 15: LdU8(0) - 16: Neq - 17: BrFalse(21) + 7: CopyLoc[0](Arg0: &vector) + 8: CopyLoc[1](loc0: u64) + 9: VecImmBorrow(2) + 10: ReadRef + 11: LdU8(0) + 12: Neq + 13: BrFalse(17) B3: - 18: MoveLoc[0](Arg0: &vector) - 19: Pop - 20: Branch(30) + 14: MoveLoc[0](Arg0: &vector) + 15: Pop + 16: Branch(26) B4: - 21: MoveLoc[1](loc0: u64) - 22: LdU64(1) - 23: Add - 24: StLoc[1](loc0: u64) - 25: Branch(29) + 17: MoveLoc[1](loc0: u64) + 18: LdU64(1) + 19: Add + 20: StLoc[1](loc0: u64) + 21: Branch(25) B5: - 26: MoveLoc[0](Arg0: &vector) - 27: Pop - 28: Branch(30) + 22: MoveLoc[0](Arg0: &vector) + 23: Pop + 24: Branch(26) B6: - 29: Branch(2) + 25: Branch(2) B7: - 30: Ret + 26: Ret } test_guess_directly() /* def_idx: 5 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.on.exp b/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.on.exp index f5fce68026abf..11a6f4028f8eb 100644 --- a/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.on.exp +++ b/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.on.exp @@ -234,7 +234,6 @@ entry public guess_flips(Arg0: vector) /* def_idx: 0 */ { L1: loc0: &vector L2: loc1: u64 L3: loc2: u64 -L4: loc3: u64 B0: 0: ImmBorrowLoc[0](Arg0: vector) 1: StLoc[1](loc0: &vector) @@ -242,75 +241,66 @@ B0: 3: StLoc[2](loc1: u64) B1: 4: CopyLoc[2](loc1: u64) - 5: StLoc[3](loc2: u64) - 6: CopyLoc[1](loc0: &vector) - 7: VecLen(2) - 8: StLoc[4](loc3: u64) - 9: MoveLoc[3](loc2: u64) - 10: MoveLoc[4](loc3: u64) - 11: Lt - 12: BrFalse(28) + 5: CopyLoc[1](loc0: &vector) + 6: VecLen(2) + 7: Lt + 8: BrFalse(24) B2: - 13: CopyLoc[1](loc0: &vector) - 14: CopyLoc[2](loc1: u64) - 15: VecImmBorrow(2) - 16: ReadRef - 17: LdU8(0) - 18: Neq - 19: BrFalse(23) + 9: CopyLoc[1](loc0: &vector) + 10: CopyLoc[2](loc1: u64) + 11: VecImmBorrow(2) + 12: ReadRef + 13: LdU8(0) + 14: Neq + 15: BrFalse(19) B3: - 20: MoveLoc[1](loc0: &vector) - 21: Pop + 16: MoveLoc[1](loc0: &vector) + 17: Pop B4: - 22: Ret + 18: Ret B5: - 23: MoveLoc[2](loc1: u64) - 24: LdU64(1) - 25: Add - 26: StLoc[2](loc1: u64) - 27: Branch(4) + 19: MoveLoc[2](loc1: u64) + 20: LdU64(1) + 21: Add + 22: StLoc[2](loc1: u64) + 23: Branch(4) B6: - 28: MoveLoc[1](loc0: &vector) - 29: Pop - 30: Branch(22) + 24: MoveLoc[1](loc0: &vector) + 25: Pop + 26: Branch(18) } entry public guess_flips_directly(Arg0: vector) /* def_idx: 1 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) B1: 2: CopyLoc[1](loc0: u64) - 3: StLoc[2](loc1: u64) - 4: ImmBorrowLoc[0](Arg0: vector) - 5: VecLen(2) - 6: StLoc[3](loc2: u64) - 7: MoveLoc[2](loc1: u64) - 8: MoveLoc[3](loc2: u64) - 9: Lt - 10: BrTrue(12) + 3: ImmBorrowLoc[0](Arg0: vector) + 4: VecLen(2) + 5: Lt + 6: BrTrue(8) B2: - 11: Branch(20) + 7: Branch(16) B3: - 12: ImmBorrowLoc[0](Arg0: vector) - 13: CopyLoc[1](loc0: u64) - 14: VecImmBorrow(2) - 15: ReadRef - 16: LdU8(0) - 17: Neq - 18: BrFalse(21) + 8: ImmBorrowLoc[0](Arg0: vector) + 9: CopyLoc[1](loc0: u64) + 10: VecImmBorrow(2) + 11: ReadRef + 12: LdU8(0) + 13: Neq + 14: BrFalse(17) B4: - 19: Branch(20) + 15: Branch(16) B5: - 20: Ret + 16: Ret B6: - 21: MoveLoc[1](loc0: u64) - 22: LdU64(1) - 23: Add - 24: StLoc[1](loc0: u64) - 25: Branch(2) + 17: MoveLoc[1](loc0: u64) + 18: LdU64(1) + 19: Add + 20: StLoc[1](loc0: u64) + 21: Branch(2) } entry public guess_with_break_without_inline(Arg0: vector) /* def_idx: 2 */ { B0: @@ -322,7 +312,6 @@ entry public guess_without_break_with_inline(Arg0: vector) /* def_idx: 3 */ L1: loc0: &vector L2: loc1: u64 L3: loc2: u64 -L4: loc3: u64 B0: 0: ImmBorrowLoc[0](Arg0: vector) 1: StLoc[1](loc0: &vector) @@ -330,78 +319,69 @@ B0: 3: StLoc[2](loc1: u64) B1: 4: CopyLoc[2](loc1: u64) - 5: StLoc[3](loc2: u64) - 6: CopyLoc[1](loc0: &vector) - 7: VecLen(2) - 8: StLoc[4](loc3: u64) - 9: MoveLoc[3](loc2: u64) - 10: MoveLoc[4](loc3: u64) - 11: Lt - 12: BrFalse(29) + 5: CopyLoc[1](loc0: &vector) + 6: VecLen(2) + 7: Lt + 8: BrFalse(25) B2: - 13: CopyLoc[1](loc0: &vector) - 14: CopyLoc[2](loc1: u64) - 15: VecImmBorrow(2) - 16: ReadRef - 17: LdU8(0) - 18: Eq - 19: BrFalse(25) + 9: CopyLoc[1](loc0: &vector) + 10: CopyLoc[2](loc1: u64) + 11: VecImmBorrow(2) + 12: ReadRef + 13: LdU8(0) + 14: Eq + 15: BrFalse(21) B3: - 20: MoveLoc[2](loc1: u64) - 21: LdU64(1) - 22: Add - 23: StLoc[2](loc1: u64) - 24: Branch(4) + 16: MoveLoc[2](loc1: u64) + 17: LdU64(1) + 18: Add + 19: StLoc[2](loc1: u64) + 20: Branch(4) B4: + 21: MoveLoc[1](loc0: &vector) + 22: Pop + 23: LdU64(3) + 24: Abort +B5: 25: MoveLoc[1](loc0: &vector) 26: Pop - 27: LdU64(3) - 28: Abort -B5: - 29: MoveLoc[1](loc0: &vector) - 30: Pop - 31: Ret + 27: Ret } loops_with_break_no_inline(Arg0: &vector) /* def_idx: 4 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) B1: 2: CopyLoc[1](loc0: u64) - 3: StLoc[2](loc1: u64) - 4: CopyLoc[0](Arg0: &vector) - 5: VecLen(2) - 6: StLoc[3](loc2: u64) - 7: MoveLoc[2](loc1: u64) - 8: MoveLoc[3](loc2: u64) - 9: Lt - 10: BrFalse(26) + 3: CopyLoc[0](Arg0: &vector) + 4: VecLen(2) + 5: Lt + 6: BrFalse(22) B2: - 11: CopyLoc[0](Arg0: &vector) - 12: CopyLoc[1](loc0: u64) - 13: VecImmBorrow(2) - 14: ReadRef - 15: LdU8(0) - 16: Neq - 17: BrFalse(21) + 7: CopyLoc[0](Arg0: &vector) + 8: CopyLoc[1](loc0: u64) + 9: VecImmBorrow(2) + 10: ReadRef + 11: LdU8(0) + 12: Neq + 13: BrFalse(17) B3: - 18: MoveLoc[0](Arg0: &vector) - 19: Pop + 14: MoveLoc[0](Arg0: &vector) + 15: Pop B4: - 20: Ret + 16: Ret B5: - 21: MoveLoc[1](loc0: u64) - 22: LdU64(1) - 23: Add - 24: StLoc[1](loc0: u64) - 25: Branch(2) + 17: MoveLoc[1](loc0: u64) + 18: LdU64(1) + 19: Add + 20: StLoc[1](loc0: u64) + 21: Branch(2) B6: - 26: MoveLoc[0](Arg0: &vector) - 27: Pop - 28: Branch(20) + 22: MoveLoc[0](Arg0: &vector) + 23: Pop + 24: Branch(16) } test_guess_directly() /* def_idx: 5 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.off.exp b/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.off.exp index 7894953e360c3..af6586a3f5112 100644 --- a/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.off.exp +++ b/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.off.exp @@ -10,55 +10,46 @@ use 0000000000000000000000000000000000000000000000000000000000000001::string; test(Arg0: vector): Ty0 /* def_idx: 0 */ { L1: loc0: String L2: loc1: String -L3: loc2: String B0: 0: Call foo(): String 1: StLoc[1](loc0: String) 2: CopyLoc[1](loc0: String) - 3: StLoc[2](loc1: String) - 4: LdConst[0](Vector(U8): [4, 98, 111, 111, 108]) - 5: Call string::utf8(vector): String - 6: StLoc[3](loc2: String) - 7: MoveLoc[2](loc1: String) - 8: MoveLoc[3](loc2: String) - 9: Eq - 10: BrFalse(15) + 3: LdConst[0](Vector(U8): [4, 98, 111, 111, 108]) + 4: Call string::utf8(vector): String + 5: Eq + 6: BrFalse(11) B1: - 11: MoveLoc[0](Arg0: vector) - 12: Call baz(vector): bool - 13: Call bar(bool): Ty0 - 14: Ret + 7: MoveLoc[0](Arg0: vector) + 8: Call baz(vector): bool + 9: Call bar(bool): Ty0 + 10: Ret B2: - 15: CopyLoc[1](loc0: String) - 16: StLoc[2](loc1: String) - 17: LdConst[1](Vector(U8): [2, 117, 56]) - 18: Call string::utf8(vector): String - 19: StLoc[3](loc2: String) - 20: MoveLoc[2](loc1: String) - 21: MoveLoc[3](loc2: String) - 22: Eq - 23: BrFalse(28) + 11: CopyLoc[1](loc0: String) + 12: LdConst[1](Vector(U8): [2, 117, 56]) + 13: Call string::utf8(vector): String + 14: Eq + 15: BrFalse(20) B3: - 24: MoveLoc[0](Arg0: vector) - 25: Call baz(vector): bool - 26: Call bar(bool): Ty0 - 27: Ret + 16: MoveLoc[0](Arg0: vector) + 17: Call baz(vector): bool + 18: Call bar(bool): Ty0 + 19: Ret B4: - 28: LdConst[2](Vector(U8): [3, 117, 54, 52]) - 29: Call string::utf8(vector): String - 30: StLoc[2](loc1: String) - 31: MoveLoc[1](loc0: String) - 32: MoveLoc[2](loc1: String) - 33: Eq - 34: BrFalse(39) + 20: LdConst[2](Vector(U8): [3, 117, 54, 52]) + 21: Call string::utf8(vector): String + 22: StLoc[2](loc1: String) + 23: MoveLoc[1](loc0: String) + 24: MoveLoc[2](loc1: String) + 25: Eq + 26: BrFalse(31) B5: - 35: MoveLoc[0](Arg0: vector) - 36: Call baz(vector): bool - 37: Call bar(bool): Ty0 - 38: Ret + 27: MoveLoc[0](Arg0: vector) + 28: Call baz(vector): bool + 29: Call bar(bool): Ty0 + 30: Ret B6: - 39: LdU64(0) - 40: Abort + 31: LdU64(0) + 32: Abort } bar(Arg0: bool): Ty0 /* def_idx: 1 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp b/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp index 5ad35eeb9ecae..23438ea680516 100644 --- a/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp +++ b/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp @@ -94,55 +94,46 @@ use 0000000000000000000000000000000000000000000000000000000000000001::string; test(Arg0: vector): Ty0 /* def_idx: 0 */ { L1: loc0: String L2: loc1: String -L3: loc2: String B0: 0: Call foo(): String 1: StLoc[1](loc0: String) 2: CopyLoc[1](loc0: String) - 3: StLoc[2](loc1: String) - 4: LdConst[0](Vector(U8): [4, 98, 111, 111, 108]) - 5: Call string::utf8(vector): String - 6: StLoc[3](loc2: String) - 7: MoveLoc[2](loc1: String) - 8: MoveLoc[3](loc2: String) - 9: Eq - 10: BrFalse(15) + 3: LdConst[0](Vector(U8): [4, 98, 111, 111, 108]) + 4: Call string::utf8(vector): String + 5: Eq + 6: BrFalse(11) B1: - 11: MoveLoc[0](Arg0: vector) - 12: Call baz(vector): bool - 13: Call bar(bool): Ty0 - 14: Ret + 7: MoveLoc[0](Arg0: vector) + 8: Call baz(vector): bool + 9: Call bar(bool): Ty0 + 10: Ret B2: - 15: CopyLoc[1](loc0: String) - 16: StLoc[2](loc1: String) - 17: LdConst[1](Vector(U8): [2, 117, 56]) - 18: Call string::utf8(vector): String - 19: StLoc[3](loc2: String) - 20: MoveLoc[2](loc1: String) - 21: MoveLoc[3](loc2: String) - 22: Eq - 23: BrFalse(28) + 11: CopyLoc[1](loc0: String) + 12: LdConst[1](Vector(U8): [2, 117, 56]) + 13: Call string::utf8(vector): String + 14: Eq + 15: BrFalse(20) B3: - 24: MoveLoc[0](Arg0: vector) - 25: Call baz(vector): bool - 26: Call bar(bool): Ty0 - 27: Ret + 16: MoveLoc[0](Arg0: vector) + 17: Call baz(vector): bool + 18: Call bar(bool): Ty0 + 19: Ret B4: - 28: LdConst[2](Vector(U8): [3, 117, 54, 52]) - 29: Call string::utf8(vector): String - 30: StLoc[2](loc1: String) - 31: MoveLoc[1](loc0: String) - 32: MoveLoc[2](loc1: String) - 33: Eq - 34: BrFalse(39) + 20: LdConst[2](Vector(U8): [3, 117, 54, 52]) + 21: Call string::utf8(vector): String + 22: StLoc[2](loc1: String) + 23: MoveLoc[1](loc0: String) + 24: MoveLoc[2](loc1: String) + 25: Eq + 26: BrFalse(31) B5: - 35: MoveLoc[0](Arg0: vector) - 36: Call baz(vector): bool - 37: Call bar(bool): Ty0 - 38: Ret + 27: MoveLoc[0](Arg0: vector) + 28: Call baz(vector): bool + 29: Call bar(bool): Ty0 + 30: Ret B6: - 39: LdU64(0) - 40: Abort + 31: LdU64(0) + 32: Abort } bar(Arg0: bool): Ty0 /* def_idx: 1 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_06.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_06.exp index f55c5a103ba6d..937040361d411 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_06.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_06.exp @@ -187,7 +187,6 @@ B0: public test(Arg0: &mut S, Arg1: S) /* def_idx: 3 */ { L2: loc0: u64 L3: loc1: u64 -L4: loc2: &mut S B0: 0: LdU64(0) 1: StLoc[2](loc0: u64) @@ -195,28 +194,24 @@ B1: 2: CopyLoc[2](loc0: u64) 3: LdU64(42) 4: Lt - 5: BrFalse(20) + 5: BrFalse(16) B2: 6: CopyLoc[0](Arg0: &mut S) - 7: StLoc[4](loc2: &mut S) - 8: MutBorrowLoc[1](Arg1: S) - 9: CopyLoc[2](loc0: u64) - 10: Call bar(&mut S, u64): u64 - 11: StLoc[3](loc1: u64) - 12: MoveLoc[4](loc2: &mut S) - 13: MoveLoc[3](loc1: u64) - 14: Call foo(&mut S, u64) - 15: MoveLoc[2](loc0: u64) - 16: LdU64(1) - 17: Add - 18: StLoc[2](loc0: u64) - 19: Branch(2) + 7: MutBorrowLoc[1](Arg1: S) + 8: CopyLoc[2](loc0: u64) + 9: Call bar(&mut S, u64): u64 + 10: Call foo(&mut S, u64) + 11: MoveLoc[2](loc0: u64) + 12: LdU64(1) + 13: Add + 14: StLoc[2](loc0: u64) + 15: Branch(2) B3: - 20: MoveLoc[0](Arg0: &mut S) - 21: Pop - 22: MoveLoc[1](Arg1: S) - 23: Call destroy(S) - 24: Ret + 16: MoveLoc[0](Arg0: &mut S) + 17: Pop + 18: MoveLoc[1](Arg1: S) + 19: Call destroy(S) + 20: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/move_stdlib_reduced.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/move_stdlib_reduced.exp new file mode 100644 index 0000000000000..2ebaeb0bea084 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/move_stdlib_reduced.exp @@ -0,0 +1,147 @@ +============ initial bytecode ================ + +[variant baseline] +fun m::bar($t0: &mut u64, $t1: u64) { + 0: write_ref($t0, $t1) + 1: return () +} + + +[variant baseline] +public fun m::foo($t0: &mut u64, $t1: u64) { + var $t2: bool + var $t3: u64 + var $t4: &mut u64 + var $t5: u64 + var $t6: u64 + var $t7: u64 + 0: label L0 + 1: $t3 := 0 + 2: $t2 := >($t1, $t3) + 3: if ($t2) goto 4 else goto 12 + 4: label L2 + 5: $t4 := infer($t0) + 6: $t5 := m::one() + 7: m::bar($t4, $t5) + 8: $t7 := 1 + 9: $t6 := -($t1, $t7) + 10: $t1 := infer($t6) + 11: goto 14 + 12: label L3 + 13: goto 16 + 14: label L4 + 15: goto 0 + 16: label L1 + 17: return () +} + + +[variant baseline] +fun m::one(): u64 { + var $t0: u64 + 0: $t0 := 1 + 1: return $t0 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::bar($t0: &mut u64, $t1: u64) { + # live vars: $t0, $t1 + 0: write_ref($t0, $t1) + # live vars: + 1: return () +} + + +[variant baseline] +public fun m::foo($t0: &mut u64, $t1: u64) { + var $t2: bool + var $t3: u64 + var $t4: &mut u64 + var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 [unused] + # live vars: $t0, $t1 + 0: label L0 + # live vars: $t0, $t1 + 1: $t3 := 0 + # live vars: $t0, $t1, $t3 + 2: $t2 := >($t1, $t3) + # live vars: $t0, $t1, $t2 + 3: if ($t2) goto 4 else goto 12 + # live vars: $t0, $t1 + 4: label L2 + # live vars: $t0, $t1 + 5: $t4 := copy($t0) + # live vars: $t0, $t1, $t4 + 6: $t3 := m::one() + # live vars: $t0, $t1, $t3, $t4 + 7: m::bar($t4, $t3) + # live vars: $t0, $t1 + 8: $t3 := 1 + # live vars: $t0, $t1, $t3 + 9: $t3 := -($t1, $t3) + # live vars: $t0, $t3 + 10: $t1 := move($t3) + # live vars: $t0, $t1 + 11: goto 0 + # live vars: $t0, $t1 + 12: label L3 + # live vars: $t0 + 13: drop($t0) + # live vars: + 14: return () +} + + +[variant baseline] +fun m::one(): u64 { + var $t0: u64 + # live vars: + 0: $t0 := 1 + # live vars: $t0 + 1: return $t0 +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +bar(Arg0: &mut u64, Arg1: u64) /* def_idx: 0 */ { +B0: + 0: MoveLoc[1](Arg1: u64) + 1: MoveLoc[0](Arg0: &mut u64) + 2: WriteRef + 3: Ret +} +public foo(Arg0: &mut u64, Arg1: u64) /* def_idx: 1 */ { +L2: loc0: u64 +B0: + 0: CopyLoc[1](Arg1: u64) + 1: LdU64(0) + 2: Gt + 3: BrFalse(12) +B1: + 4: CopyLoc[0](Arg0: &mut u64) + 5: Call one(): u64 + 6: Call bar(&mut u64, u64) + 7: MoveLoc[1](Arg1: u64) + 8: LdU64(1) + 9: Sub + 10: StLoc[1](Arg1: u64) + 11: Branch(0) +B2: + 12: MoveLoc[0](Arg0: &mut u64) + 13: Pop + 14: Ret +} +one(): u64 /* def_idx: 2 */ { +B0: + 0: LdU64(1) + 1: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/move_stdlib_reduced.move b/third_party/move/move-compiler-v2/tests/eager-pushes/move_stdlib_reduced.move new file mode 100644 index 0000000000000..262b41aa98b94 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/move_stdlib_reduced.move @@ -0,0 +1,17 @@ +// Test case to showcase https://github.com/aptos-labs/aptos-core/issues/15339 +module 0xc0ffee::m { + fun one(): u64 { + 1 + } + + fun bar(x: &mut u64, i: u64) { + *x = i; + } + + public fun foo(x: &mut u64, len: u64) { + while (len > 0) { + bar(x, one()); + len = len - 1; + }; + } +} diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/txn_reduced_01.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/txn_reduced_01.exp new file mode 100644 index 0000000000000..a36517680038a --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/txn_reduced_01.exp @@ -0,0 +1,176 @@ +============ initial bytecode ================ + +[variant baseline] +fun m::call_other($t0: &signer, $t1: address, $t2: u64) { + 0: return () +} + + +[variant baseline] +public fun m::test($t0: &signer, $t1: vector
, $t2: vector) { + var $t3: u64 + var $t4: &vector
+ var $t5: u64 + var $t6: bool + var $t7: &address + var $t8: &vector
+ var $t9: &u64 + var $t10: &vector + var $t11: address + var $t12: u64 + var $t13: u64 + var $t14: u64 + 0: $t4 := borrow_local($t1) + 1: $t3 := vector::length
($t4) + 2: $t5 := 0 + 3: label L0 + 4: $t6 := <($t5, $t3) + 5: if ($t6) goto 6 else goto 18 + 6: label L2 + 7: $t8 := borrow_local($t1) + 8: $t7 := vector::borrow
($t8, $t5) + 9: $t10 := borrow_local($t2) + 10: $t9 := vector::borrow($t10, $t5) + 11: $t11 := read_ref($t7) + 12: $t12 := read_ref($t9) + 13: m::call_other($t0, $t11, $t12) + 14: $t14 := 1 + 15: $t13 := +($t5, $t14) + 16: $t5 := infer($t13) + 17: goto 20 + 18: label L3 + 19: goto 22 + 20: label L4 + 21: goto 3 + 22: label L1 + 23: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::call_other($t0: &signer, $t1: address, $t2: u64) { + # live vars: $t0, $t1, $t2 + 0: drop($t0) + # live vars: + 1: return () +} + + +[variant baseline] +public fun m::test($t0: &signer, $t1: vector
, $t2: vector) { + var $t3: u64 + var $t4: &vector
+ var $t5: u64 + var $t6: bool + var $t7: &address + var $t8: &vector
[unused] + var $t9: &u64 + var $t10: &vector + var $t11: address + var $t12: u64 + var $t13: u64 [unused] + var $t14: u64 [unused] + # live vars: $t0, $t1, $t2 + 0: $t4 := borrow_local($t1) + # live vars: $t0, $t1, $t2, $t4 + 1: $t3 := vector::length
($t4) + # live vars: $t0, $t1, $t2, $t3 + 2: $t5 := 0 + # live vars: $t0, $t1, $t2, $t3, $t5 + 3: label L0 + # live vars: $t0, $t1, $t2, $t3, $t5 + 4: $t6 := <($t5, $t3) + # live vars: $t0, $t1, $t2, $t3, $t5, $t6 + 5: if ($t6) goto 6 else goto 18 + # live vars: $t0, $t1, $t2, $t3, $t5 + 6: label L2 + # live vars: $t0, $t1, $t2, $t3, $t5 + 7: $t4 := borrow_local($t1) + # live vars: $t0, $t1, $t2, $t3, $t4, $t5 + 8: $t7 := vector::borrow
($t4, $t5) + # live vars: $t0, $t1, $t2, $t3, $t5, $t7 + 9: $t10 := borrow_local($t2) + # live vars: $t0, $t1, $t2, $t3, $t5, $t7, $t10 + 10: $t9 := vector::borrow($t10, $t5) + # live vars: $t0, $t1, $t2, $t3, $t5, $t7, $t9 + 11: $t11 := read_ref($t7) + # live vars: $t0, $t1, $t2, $t3, $t5, $t9, $t11 + 12: $t12 := read_ref($t9) + # live vars: $t0, $t1, $t2, $t3, $t5, $t11, $t12 + 13: m::call_other($t0, $t11, $t12) + # live vars: $t0, $t1, $t2, $t3, $t5 + 14: $t12 := 1 + # live vars: $t0, $t1, $t2, $t3, $t5, $t12 + 15: $t12 := +($t5, $t12) + # live vars: $t0, $t1, $t2, $t3, $t12 + 16: $t5 := move($t12) + # live vars: $t0, $t1, $t2, $t3, $t5 + 17: goto 3 + # live vars: $t0, $t1, $t2, $t3, $t5 + 18: label L3 + # live vars: $t0 + 19: drop($t0) + # live vars: + 20: return () +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +call_other(Arg0: &signer, Arg1: address, Arg2: u64) /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: &signer) + 1: Pop + 2: Ret +} +public test(Arg0: &signer, Arg1: vector
, Arg2: vector) /* def_idx: 1 */ { +L3: loc0: u64 +L4: loc1: u64 +L5: loc2: &u64 +L6: loc3: &address +L7: loc4: u64 +L8: loc5: address +B0: + 0: ImmBorrowLoc[1](Arg1: vector
) + 1: VecLen(3) + 2: StLoc[3](loc0: u64) + 3: LdU64(0) + 4: StLoc[4](loc1: u64) +B1: + 5: CopyLoc[4](loc1: u64) + 6: CopyLoc[3](loc0: u64) + 7: Lt + 8: BrFalse(30) +B2: + 9: ImmBorrowLoc[1](Arg1: vector
) + 10: CopyLoc[4](loc1: u64) + 11: VecImmBorrow(3) + 12: ImmBorrowLoc[2](Arg2: vector) + 13: CopyLoc[4](loc1: u64) + 14: VecImmBorrow(4) + 15: StLoc[5](loc2: &u64) + 16: ReadRef + 17: MoveLoc[5](loc2: &u64) + 18: ReadRef + 19: StLoc[7](loc4: u64) + 20: StLoc[8](loc5: address) + 21: CopyLoc[0](Arg0: &signer) + 22: MoveLoc[8](loc5: address) + 23: MoveLoc[7](loc4: u64) + 24: Call call_other(&signer, address, u64) + 25: MoveLoc[4](loc1: u64) + 26: LdU64(1) + 27: Add + 28: StLoc[4](loc1: u64) + 29: Branch(5) +B3: + 30: MoveLoc[0](Arg0: &signer) + 31: Pop + 32: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/txn_reduced_01.move b/third_party/move/move-compiler-v2/tests/eager-pushes/txn_reduced_01.move new file mode 100644 index 0000000000000..362a29eea4abe --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/txn_reduced_01.move @@ -0,0 +1,16 @@ +module 0xc0ffee::m { + use std::vector; + + public fun test(from: &signer, to_vec: vector
, amount_vec: vector) { + let len = vector::length(&to_vec); + let i = 0; + while (i < len) { + let to = vector::borrow(&to_vec, i); + let amount = vector::borrow(&amount_vec, i); + call_other(from, *to, *amount); + i = i + 1; + } + } + + fun call_other(_from: &signer, _to: address, _amount: u64) {} +} diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.opt.exp index cf9cf708cd9e3..d04e138c63dba 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.opt.exp @@ -23,10 +23,9 @@ L3: loc1: bool L4: loc2: u64 L5: loc3: u64 L6: loc4: u64 -L7: loc5: bool -L8: loc6: u64 +L7: loc5: u64 +L8: loc6: bool L9: loc7: Option -L10: loc8: Option B0: 0: CopyLoc[0](Arg0: &mut S) 1: ImmBorrowField[0](S.entries: vector) @@ -55,7 +54,7 @@ B3: 21: ReadRef 22: CopyLoc[1](Arg1: vector) 23: Eq - 24: BrFalse(53) + 24: BrFalse(51) B4: 25: LdTrue 26: StLoc[3](loc1: bool) @@ -66,37 +65,35 @@ B5: 30: MoveLoc[2](loc0: &vector) 31: Pop 32: MoveLoc[3](loc1: bool) - 33: StLoc[7](loc5: bool) - 34: MoveLoc[4](loc2: u64) - 35: StLoc[8](loc6: u64) - 36: MoveLoc[7](loc5: bool) - 37: BrFalse(48) + 33: MoveLoc[4](loc2: u64) + 34: StLoc[7](loc5: u64) + 35: StLoc[8](loc6: bool) + 36: MoveLoc[8](loc6: bool) + 37: BrFalse(46) B6: 38: MoveLoc[0](Arg0: &mut S) 39: MutBorrowField[0](S.entries: vector) - 40: MoveLoc[8](loc6: u64) + 40: MoveLoc[7](loc5: u64) 41: Call vector::remove(&mut vector, u64): T 42: Call option::some(T): Option 43: StLoc[9](loc7: Option) B7: 44: MoveLoc[9](loc7: Option) - 45: StLoc[10](loc8: Option) - 46: MoveLoc[10](loc8: Option) - 47: Ret + 45: Ret B8: - 48: MoveLoc[0](Arg0: &mut S) - 49: Pop - 50: Call option::none(): Option - 51: StLoc[9](loc7: Option) - 52: Branch(44) + 46: MoveLoc[0](Arg0: &mut S) + 47: Pop + 48: Call option::none(): Option + 49: StLoc[9](loc7: Option) + 50: Branch(44) B9: - 53: LdU64(1) - 54: StLoc[8](loc6: u64) - 55: MoveLoc[5](loc3: u64) - 56: MoveLoc[8](loc6: u64) - 57: Add - 58: StLoc[5](loc3: u64) - 59: Branch(12) + 51: LdU64(1) + 52: StLoc[7](loc5: u64) + 53: MoveLoc[5](loc3: u64) + 54: MoveLoc[7](loc5: u64) + 55: Add + 56: StLoc[5](loc3: u64) + 57: Branch(12) } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/fields.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/fields.opt.exp index e5a00ea3e8bf8..bddcd323020fa 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/fields.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/fields.opt.exp @@ -28,7 +28,6 @@ B0: } write_local_direct(): S /* def_idx: 2 */ { L0: loc0: S -L1: loc1: S B0: 0: LdU64(0) 1: LdU64(0) @@ -48,7 +47,6 @@ L0: loc0: S L1: loc1: u64 L2: loc2: &mut S L3: loc3: &mut u64 -L4: loc4: S B0: 0: LdU64(0) 1: LdU64(0) @@ -75,7 +73,6 @@ B0: 5: Ret } write_val(Arg0: S): S /* def_idx: 5 */ { -L1: loc0: S B0: 0: LdU64(42) 1: MutBorrowLoc[0](Arg0: S) diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/vector.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/vector.opt.exp index 86fe0b29dd1f5..59b0000ee2d3c 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/vector.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/vector.opt.exp @@ -10,8 +10,7 @@ use 0000000000000000000000000000000000000000000000000000000000000001::vector as public remove(Arg0: &mut vector, Arg1: u64): Ty0 /* def_idx: 0 */ { L2: loc0: u64 L3: loc1: u64 -L4: loc2: &mut vector -L5: loc3: u64 +L4: loc2: u64 B0: 0: CopyLoc[0](Arg0: &mut vector) 1: FreezeRef @@ -35,27 +34,21 @@ B3: 16: CopyLoc[1](Arg1: u64) 17: CopyLoc[2](loc0: u64) 18: Lt - 19: BrFalse(35) + 19: BrFalse(29) B4: 20: CopyLoc[0](Arg0: &mut vector) - 21: StLoc[4](loc2: &mut vector) - 22: CopyLoc[1](Arg1: u64) - 23: StLoc[3](loc1: u64) - 24: MoveLoc[1](Arg1: u64) - 25: LdU64(1) - 26: Add - 27: StLoc[1](Arg1: u64) - 28: CopyLoc[1](Arg1: u64) - 29: StLoc[5](loc3: u64) - 30: MoveLoc[4](loc2: &mut vector) - 31: MoveLoc[3](loc1: u64) - 32: MoveLoc[5](loc3: u64) - 33: VecSwap(1) - 34: Branch(16) + 21: CopyLoc[1](Arg1: u64) + 22: MoveLoc[1](Arg1: u64) + 23: LdU64(1) + 24: Add + 25: StLoc[1](Arg1: u64) + 26: CopyLoc[1](Arg1: u64) + 27: VecSwap(1) + 28: Branch(16) B5: - 35: MoveLoc[0](Arg0: &mut vector) - 36: VecPopBack(1) - 37: Ret + 29: MoveLoc[0](Arg0: &mut vector) + 30: VecPopBack(1) + 31: Ret } create(): vector /* def_idx: 1 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.off.exp b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.off.exp index 6e0f61006aa5a..da91b1fbdbafc 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.off.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.off.exp @@ -18,7 +18,6 @@ B0: 1: Ret } public test(): u64 /* def_idx: 2 */ { -L0: loc0: u64 B0: 0: Call one(): u64 1: Call foo(u64): u64 diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.on.exp index 27772260db6d9..e30fa68798f35 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.on.exp @@ -58,7 +58,6 @@ B0: 1: Ret } public test(): u64 /* def_idx: 2 */ { -L0: loc0: u64 B0: 0: Call one(): u64 1: Call foo(u64): u64 diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.off.exp b/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.off.exp index e42136755a54d..9c907cf1b4e38 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.off.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.off.exp @@ -6,17 +6,12 @@ module c0ffee.m { foo(Arg0: u64): u64 * u64 /* def_idx: 0 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: StLoc[1](loc0: u64) - 2: MoveLoc[0](Arg0: u64) - 3: LdU64(1) - 4: Sub - 5: StLoc[0](Arg0: u64) - 6: MoveLoc[1](loc0: u64) - 7: MoveLoc[0](Arg0: u64) - 8: Ret + 1: MoveLoc[0](Arg0: u64) + 2: LdU64(1) + 3: Sub + 4: Ret } public test1(Arg0: u64) /* def_idx: 1 */ { L1: loc0: u64 diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.on.exp index 934f8720dab1c..4640def1c25d2 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.on.exp @@ -69,17 +69,12 @@ module c0ffee.m { foo(Arg0: u64): u64 * u64 /* def_idx: 0 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: StLoc[1](loc0: u64) - 2: MoveLoc[0](Arg0: u64) - 3: LdU64(1) - 4: Sub - 5: StLoc[0](Arg0: u64) - 6: MoveLoc[1](loc0: u64) - 7: MoveLoc[0](Arg0: u64) - 8: Ret + 1: MoveLoc[0](Arg0: u64) + 2: LdU64(1) + 3: Sub + 4: Ret } public test1(Arg0: u64) /* def_idx: 1 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.exp index eb59c1bd4fbf0..a58b76fe10539 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.exp @@ -160,18 +160,13 @@ B0: } public test(Arg0: u64): u64 /* def_idx: 1 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: StLoc[1](loc0: u64) - 2: MoveLoc[0](Arg0: u64) - 3: LdU64(1) - 4: Add - 5: StLoc[0](Arg0: u64) - 6: MoveLoc[1](loc0: u64) - 7: MoveLoc[0](Arg0: u64) - 8: Call add(u64, u64): u64 - 9: Ret + 1: MoveLoc[0](Arg0: u64) + 2: LdU64(1) + 3: Add + 4: Call add(u64, u64): u64 + 5: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.opt.exp index eb59c1bd4fbf0..a58b76fe10539 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.opt.exp @@ -160,18 +160,13 @@ B0: } public test(Arg0: u64): u64 /* def_idx: 1 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: StLoc[1](loc0: u64) - 2: MoveLoc[0](Arg0: u64) - 3: LdU64(1) - 4: Add - 5: StLoc[0](Arg0: u64) - 6: MoveLoc[1](loc0: u64) - 7: MoveLoc[0](Arg0: u64) - 8: Call add(u64, u64): u64 - 9: Ret + 1: MoveLoc[0](Arg0: u64) + 2: LdU64(1) + 3: Add + 4: Call add(u64, u64): u64 + 5: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/borrowed_var.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/borrowed_var.exp index 95104220eaeb7..3fa0178005ebe 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/borrowed_var.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/borrowed_var.exp @@ -139,7 +139,6 @@ module c0ffee.m { test() /* def_idx: 0 */ { L0: loc0: u64 L1: loc1: &u64 -L2: loc2: &u64 B0: 0: LdU64(5) 1: StLoc[0](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/borrowed_var.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/borrowed_var.opt.exp index 6b10a489c154c..8504db0796684 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/borrowed_var.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/borrowed_var.opt.exp @@ -151,7 +151,6 @@ test() /* def_idx: 0 */ { L0: loc0: u64 L1: loc1: &u64 L2: loc2: u64 -L3: loc3: &u64 B0: 0: LdU64(5) 1: StLoc[0](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_2.exp index 4011aa65aadae..0ca6e1586c9fd 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_2.exp @@ -107,7 +107,6 @@ module c0ffee.m { test(Arg0: bool, Arg1: u64, Arg2: u64): u64 /* def_idx: 0 */ { L3: loc0: u64 -L4: loc1: u64 B0: 0: MoveLoc[0](Arg0: bool) 1: BrFalse(6) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_2.opt.exp index 4011aa65aadae..0ca6e1586c9fd 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_2.opt.exp @@ -107,7 +107,6 @@ module c0ffee.m { test(Arg0: bool, Arg1: u64, Arg2: u64): u64 /* def_idx: 0 */ { L3: loc0: u64 -L4: loc1: u64 B0: 0: MoveLoc[0](Arg0: bool) 1: BrFalse(6) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_3.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_3.exp index 957082ac783f0..62a6a6a09d546 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_3.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_3.exp @@ -106,7 +106,6 @@ module c0ffee.m { test(Arg0: bool, Arg1: u64): u64 /* def_idx: 0 */ { L2: loc0: u64 -L3: loc1: u64 B0: 0: MoveLoc[0](Arg0: bool) 1: BrFalse(6) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_3.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_3.opt.exp index 957082ac783f0..62a6a6a09d546 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_3.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_3.opt.exp @@ -106,7 +106,6 @@ module c0ffee.m { test(Arg0: bool, Arg1: u64): u64 /* def_idx: 0 */ { L2: loc0: u64 -L3: loc1: u64 B0: 0: MoveLoc[0](Arg0: bool) 1: BrFalse(6) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_assigns_then_moves_then_assigns.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_assigns_then_moves_then_assigns.exp index 2732ee278296f..4ecbc23e87caf 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_assigns_then_moves_then_assigns.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_assigns_then_moves_then_assigns.exp @@ -229,8 +229,6 @@ script { main() /* def_idx: 0 */ { L0: loc0: u64 -L1: loc1: u64 -L2: loc2: u64 B0: 0: LdU64(5) 1: StLoc[0](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_assigns_then_moves_then_assigns.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_assigns_then_moves_then_assigns.opt.exp index 2732ee278296f..4ecbc23e87caf 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_assigns_then_moves_then_assigns.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_assigns_then_moves_then_assigns.opt.exp @@ -229,8 +229,6 @@ script { main() /* def_idx: 0 */ { L0: loc0: u64 -L1: loc1: u64 -L2: loc2: u64 B0: 0: LdU64(5) 1: StLoc[0](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.exp index 74ef544575ec3..aaa97c341d3f8 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.exp @@ -312,18 +312,14 @@ B0: 0: Ret } public test1(Arg0: u64) /* def_idx: 2 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: StLoc[1](loc0: u64) - 2: MoveLoc[0](Arg0: u64) + 1: MoveLoc[0](Arg0: u64) + 2: Call consume(u64) 3: Call consume(u64) - 4: MoveLoc[1](loc0: u64) - 5: Call consume(u64) - 6: Ret + 4: Ret } public test2(Arg0: u64) /* def_idx: 3 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: Call consume(u64) @@ -332,18 +328,14 @@ B0: 4: Ret } public test3(Arg0: W) /* def_idx: 4 */ { -L1: loc0: W B0: 0: CopyLoc[0](Arg0: W) - 1: StLoc[1](loc0: W) - 2: MoveLoc[0](Arg0: W) + 1: MoveLoc[0](Arg0: W) + 2: Call consume_(W) 3: Call consume_(W) - 4: MoveLoc[1](loc0: W) - 5: Call consume_(W) - 6: Ret + 4: Ret } public test4(Arg0: W) /* def_idx: 5 */ { -L1: loc0: W B0: 0: CopyLoc[0](Arg0: W) 1: Call consume_(W) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.opt.exp index 74ef544575ec3..aaa97c341d3f8 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.opt.exp @@ -312,18 +312,14 @@ B0: 0: Ret } public test1(Arg0: u64) /* def_idx: 2 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: StLoc[1](loc0: u64) - 2: MoveLoc[0](Arg0: u64) + 1: MoveLoc[0](Arg0: u64) + 2: Call consume(u64) 3: Call consume(u64) - 4: MoveLoc[1](loc0: u64) - 5: Call consume(u64) - 6: Ret + 4: Ret } public test2(Arg0: u64) /* def_idx: 3 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: Call consume(u64) @@ -332,18 +328,14 @@ B0: 4: Ret } public test3(Arg0: W) /* def_idx: 4 */ { -L1: loc0: W B0: 0: CopyLoc[0](Arg0: W) - 1: StLoc[1](loc0: W) - 2: MoveLoc[0](Arg0: W) + 1: MoveLoc[0](Arg0: W) + 2: Call consume_(W) 3: Call consume_(W) - 4: MoveLoc[1](loc0: W) - 5: Call consume_(W) - 6: Ret + 4: Ret } public test4(Arg0: W) /* def_idx: 5 */ { -L1: loc0: W B0: 0: CopyLoc[0](Arg0: W) 1: Call consume_(W) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.exp index 7ecc0e6a884b1..c15338be6f7e7 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.exp @@ -198,7 +198,6 @@ B0: 0: Ret } public test(Arg0: u32) /* def_idx: 2 */ { -L1: loc0: u32 B0: 0: CopyLoc[0](Arg0: u32) 1: Call consume(u32) @@ -207,7 +206,6 @@ B0: 4: Ret } public test_(Arg0: W) /* def_idx: 3 */ { -L1: loc0: W B0: 0: CopyLoc[0](Arg0: W) 1: Call consume_(W) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.opt.exp index 7ecc0e6a884b1..c15338be6f7e7 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.opt.exp @@ -198,7 +198,6 @@ B0: 0: Ret } public test(Arg0: u32) /* def_idx: 2 */ { -L1: loc0: u32 B0: 0: CopyLoc[0](Arg0: u32) 1: Call consume(u32) @@ -207,7 +206,6 @@ B0: 4: Ret } public test_(Arg0: W) /* def_idx: 3 */ { -L1: loc0: W B0: 0: CopyLoc[0](Arg0: W) 1: Call consume_(W) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.exp index f2b1a0c6caaf7..e801617e44e8f 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.exp @@ -220,7 +220,6 @@ B0: 0: Ret } public test(Arg0: u32) /* def_idx: 2 */ { -L1: loc0: u32 B0: 0: CopyLoc[0](Arg0: u32) 1: Call consume(u32) @@ -229,7 +228,6 @@ B0: 4: Ret } public test_struct(Arg0: W) /* def_idx: 3 */ { -L1: loc0: W B0: 0: CopyLoc[0](Arg0: W) 1: Call consume_(W) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.opt.exp index f2b1a0c6caaf7..e801617e44e8f 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.opt.exp @@ -220,7 +220,6 @@ B0: 0: Ret } public test(Arg0: u32) /* def_idx: 2 */ { -L1: loc0: u32 B0: 0: CopyLoc[0](Arg0: u32) 1: Call consume(u32) @@ -229,7 +228,6 @@ B0: 4: Ret } public test_struct(Arg0: W) /* def_idx: 3 */ { -L1: loc0: W B0: 0: CopyLoc[0](Arg0: W) 1: Call consume_(W) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_assignments.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_assignments.exp index 6a5b5d0f8d8ff..8dd3b318bd40c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_assignments.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_assignments.exp @@ -83,7 +83,6 @@ module c0ffee.m { cyclic(Arg0: u64): u64 /* def_idx: 0 */ { -L1: loc0: u64 B0: 0: MoveLoc[0](Arg0: u64) 1: Ret diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_assignments.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_assignments.opt.exp index 6a5b5d0f8d8ff..8dd3b318bd40c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_assignments.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_assignments.opt.exp @@ -83,7 +83,6 @@ module c0ffee.m { cyclic(Arg0: u64): u64 /* def_idx: 0 */ { -L1: loc0: u64 B0: 0: MoveLoc[0](Arg0: u64) 1: Ret diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.exp index 860e46ca74071..532b75388a4fb 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.exp @@ -276,15 +276,17 @@ B1: 2: CopyLoc[3](loc0: u64) 3: CopyLoc[0](Arg0: u64) 4: Lt - 5: BrFalse(11) + 5: BrFalse(13) B2: - 6: MoveLoc[3](loc0: u64) - 7: LdU64(1) - 8: Add - 9: StLoc[3](loc0: u64) - 10: Branch(2) + 6: MoveLoc[2](Arg2: u64) + 7: MoveLoc[3](loc0: u64) + 8: LdU64(1) + 9: Add + 10: StLoc[3](loc0: u64) + 11: StLoc[2](Arg2: u64) + 12: Branch(2) B3: - 11: Ret + 13: Ret } public test2(Arg0: u64, Arg1: u64) /* def_idx: 1 */ { L2: loc0: u64 diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.opt.exp index 860e46ca74071..532b75388a4fb 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.opt.exp @@ -276,15 +276,17 @@ B1: 2: CopyLoc[3](loc0: u64) 3: CopyLoc[0](Arg0: u64) 4: Lt - 5: BrFalse(11) + 5: BrFalse(13) B2: - 6: MoveLoc[3](loc0: u64) - 7: LdU64(1) - 8: Add - 9: StLoc[3](loc0: u64) - 10: Branch(2) + 6: MoveLoc[2](Arg2: u64) + 7: MoveLoc[3](loc0: u64) + 8: LdU64(1) + 9: Add + 10: StLoc[3](loc0: u64) + 11: StLoc[2](Arg2: u64) + 12: Branch(2) B3: - 11: Ret + 13: Ret } public test2(Arg0: u64, Arg1: u64) /* def_idx: 1 */ { L2: loc0: u64 diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/immut_refs_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/immut_refs_2.exp index 154ea1d90c925..180cc62af2a3b 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/immut_refs_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/immut_refs_2.exp @@ -122,7 +122,6 @@ module c0ffee.m { test(Arg0: u64): u64 /* def_idx: 0 */ { L1: loc0: &u64 -L2: loc1: u64 B0: 0: ImmBorrowLoc[0](Arg0: u64) 1: Pop diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/immut_refs_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/immut_refs_2.opt.exp index 154ea1d90c925..180cc62af2a3b 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/immut_refs_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/immut_refs_2.opt.exp @@ -122,7 +122,6 @@ module c0ffee.m { test(Arg0: u64): u64 /* def_idx: 0 */ { L1: loc0: &u64 -L2: loc1: u64 B0: 0: ImmBorrowLoc[0](Arg0: u64) 1: Pop diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.exp index 1fc069963391a..6d8197b4a1bcd 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.exp @@ -112,7 +112,6 @@ module c0ffee.m { test(): u64 /* def_idx: 0 */ { L0: loc0: u64 -L1: loc1: u64 B0: 0: LdU64(1) 1: LdU64(2) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.opt.exp index def8e4b7b85f5..6eb72ab89b2c0 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.opt.exp @@ -110,13 +110,14 @@ module c0ffee.m { test(): u64 /* def_idx: 0 */ { L0: loc0: u64 +L1: loc1: u64 B0: 0: LdU64(1) 1: LdU64(1) 2: Add - 3: StLoc[0](loc0: u64) + 3: StLoc[1](loc1: u64) 4: LdU64(2) - 5: MoveLoc[0](loc0: u64) + 5: MoveLoc[1](loc1: u64) 6: Add 7: Ret } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.exp index 3c4fe82378d7c..b8c4d57d833a0 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.exp @@ -189,11 +189,11 @@ B1: 7: BrFalse(15) B2: 8: CopyLoc[0](Arg0: u64) - 9: StLoc[1](loc0: u64) - 10: MoveLoc[2](loc1: u64) - 11: LdU64(1) - 12: Add - 13: StLoc[2](loc1: u64) + 9: MoveLoc[2](loc1: u64) + 10: LdU64(1) + 11: Add + 12: StLoc[2](loc1: u64) + 13: StLoc[1](loc0: u64) 14: Branch(4) B3: 15: MoveLoc[1](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.opt.exp index 3c4fe82378d7c..b8c4d57d833a0 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.opt.exp @@ -189,11 +189,11 @@ B1: 7: BrFalse(15) B2: 8: CopyLoc[0](Arg0: u64) - 9: StLoc[1](loc0: u64) - 10: MoveLoc[2](loc1: u64) - 11: LdU64(1) - 12: Add - 13: StLoc[2](loc1: u64) + 9: MoveLoc[2](loc1: u64) + 10: LdU64(1) + 11: Add + 12: StLoc[2](loc1: u64) + 13: StLoc[1](loc0: u64) 14: Branch(4) B3: 15: MoveLoc[1](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.exp index edcfd71c7b42c..3334689dfa167 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.exp @@ -179,24 +179,24 @@ L2: loc1: u64 L3: loc2: u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: StLoc[1](loc0: u64) - 2: LdU64(0) + 1: LdU64(0) + 2: StLoc[1](loc0: u64) 3: StLoc[2](loc1: u64) B1: - 4: CopyLoc[2](loc1: u64) + 4: CopyLoc[1](loc0: u64) 5: LdU64(10) 6: Lt 7: BrFalse(15) B2: 8: CopyLoc[0](Arg0: u64) - 9: StLoc[1](loc0: u64) - 10: MoveLoc[2](loc1: u64) - 11: LdU64(1) - 12: Add + 9: MoveLoc[1](loc0: u64) + 10: LdU64(1) + 11: Add + 12: StLoc[1](loc0: u64) 13: StLoc[2](loc1: u64) 14: Branch(4) B3: - 15: MoveLoc[1](loc0: u64) + 15: MoveLoc[2](loc1: u64) 16: Ret } } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.opt.exp index edcfd71c7b42c..3334689dfa167 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.opt.exp @@ -179,24 +179,24 @@ L2: loc1: u64 L3: loc2: u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: StLoc[1](loc0: u64) - 2: LdU64(0) + 1: LdU64(0) + 2: StLoc[1](loc0: u64) 3: StLoc[2](loc1: u64) B1: - 4: CopyLoc[2](loc1: u64) + 4: CopyLoc[1](loc0: u64) 5: LdU64(10) 6: Lt 7: BrFalse(15) B2: 8: CopyLoc[0](Arg0: u64) - 9: StLoc[1](loc0: u64) - 10: MoveLoc[2](loc1: u64) - 11: LdU64(1) - 12: Add + 9: MoveLoc[1](loc0: u64) + 10: LdU64(1) + 11: Add + 12: StLoc[1](loc0: u64) 13: StLoc[2](loc1: u64) 14: Branch(4) B3: - 15: MoveLoc[1](loc0: u64) + 15: MoveLoc[2](loc1: u64) 16: Ret } } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_1.exp index 8514f77eee3b5..f821096a76a3e 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_1.exp @@ -96,18 +96,15 @@ module c0ffee.m { test(Arg0: u64): u64 /* def_idx: 0 */ { -L1: loc0: u64 -L2: loc1: &mut u64 +L1: loc0: &mut u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: StLoc[1](loc0: u64) - 2: MutBorrowLoc[0](Arg0: u64) - 3: StLoc[2](loc1: &mut u64) - 4: LdU64(1) - 5: MoveLoc[2](loc1: &mut u64) - 6: WriteRef - 7: MoveLoc[1](loc0: u64) - 8: Ret + 1: MutBorrowLoc[0](Arg0: u64) + 2: StLoc[1](loc0: &mut u64) + 3: LdU64(1) + 4: MoveLoc[1](loc0: &mut u64) + 5: WriteRef + 6: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_1.opt.exp index 8514f77eee3b5..f821096a76a3e 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_1.opt.exp @@ -96,18 +96,15 @@ module c0ffee.m { test(Arg0: u64): u64 /* def_idx: 0 */ { -L1: loc0: u64 -L2: loc1: &mut u64 +L1: loc0: &mut u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: StLoc[1](loc0: u64) - 2: MutBorrowLoc[0](Arg0: u64) - 3: StLoc[2](loc1: &mut u64) - 4: LdU64(1) - 5: MoveLoc[2](loc1: &mut u64) - 6: WriteRef - 7: MoveLoc[1](loc0: u64) - 8: Ret + 1: MutBorrowLoc[0](Arg0: u64) + 2: StLoc[1](loc0: &mut u64) + 3: LdU64(1) + 4: MoveLoc[1](loc0: &mut u64) + 5: WriteRef + 6: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.exp index a6a7f2aabdfa2..86b5890cae6d7 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.exp @@ -129,13 +129,13 @@ B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) 2: CopyLoc[1](loc0: u64) - 3: StLoc[2](loc1: u64) - 4: MoveLoc[0](Arg0: u64) - 5: LdU64(1) - 6: Add - 7: Pop + 3: MoveLoc[0](Arg0: u64) + 4: LdU64(1) + 5: Add + 6: Pop + 7: StLoc[3](loc2: u64) 8: MoveLoc[1](loc0: u64) - 9: MoveLoc[2](loc1: u64) + 9: MoveLoc[3](loc2: u64) 10: Eq 11: Ret } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.opt.exp index a6a7f2aabdfa2..86b5890cae6d7 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.opt.exp @@ -129,13 +129,13 @@ B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) 2: CopyLoc[1](loc0: u64) - 3: StLoc[2](loc1: u64) - 4: MoveLoc[0](Arg0: u64) - 5: LdU64(1) - 6: Add - 7: Pop + 3: MoveLoc[0](Arg0: u64) + 4: LdU64(1) + 5: Add + 6: Pop + 7: StLoc[3](loc2: u64) 8: MoveLoc[1](loc0: u64) - 9: MoveLoc[2](loc1: u64) + 9: MoveLoc[3](loc2: u64) 10: Eq 11: Ret } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.exp index 37fb2e50db125..eb034ba9ffbaf 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.exp @@ -129,13 +129,13 @@ B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) 2: CopyLoc[1](loc0: u64) - 3: StLoc[2](loc1: u64) - 4: MoveLoc[0](Arg0: u64) - 5: LdU64(1) - 6: Add - 7: Pop + 3: MoveLoc[0](Arg0: u64) + 4: LdU64(1) + 5: Add + 6: Pop + 7: StLoc[3](loc2: u64) 8: MoveLoc[1](loc0: u64) - 9: MoveLoc[2](loc1: u64) + 9: MoveLoc[3](loc2: u64) 10: Eq 11: Ret } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.opt.exp index 37fb2e50db125..eb034ba9ffbaf 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.opt.exp @@ -129,13 +129,13 @@ B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) 2: CopyLoc[1](loc0: u64) - 3: StLoc[2](loc1: u64) - 4: MoveLoc[0](Arg0: u64) - 5: LdU64(1) - 6: Add - 7: Pop + 3: MoveLoc[0](Arg0: u64) + 4: LdU64(1) + 5: Add + 6: Pop + 7: StLoc[3](loc2: u64) 8: MoveLoc[1](loc0: u64) - 9: MoveLoc[2](loc1: u64) + 9: MoveLoc[3](loc2: u64) 10: Eq 11: Ret } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.exp index 0d49f3e8a14f9..822f245566624 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.exp @@ -113,20 +113,17 @@ module c0ffee.m { copy_kill(Arg0: u64): u64 /* def_idx: 0 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) 2: CopyLoc[1](loc0: u64) - 3: StLoc[2](loc1: u64) - 4: MoveLoc[0](Arg0: u64) - 5: LdU64(1) - 6: Add - 7: Pop - 8: MoveLoc[2](loc1: u64) - 9: MoveLoc[1](loc0: u64) - 10: Add - 11: Ret + 3: MoveLoc[0](Arg0: u64) + 4: LdU64(1) + 5: Add + 6: Pop + 7: MoveLoc[1](loc0: u64) + 8: Add + 9: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.opt.exp index 0d49f3e8a14f9..822f245566624 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.opt.exp @@ -113,20 +113,17 @@ module c0ffee.m { copy_kill(Arg0: u64): u64 /* def_idx: 0 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) 2: CopyLoc[1](loc0: u64) - 3: StLoc[2](loc1: u64) - 4: MoveLoc[0](Arg0: u64) - 5: LdU64(1) - 6: Add - 7: Pop - 8: MoveLoc[2](loc1: u64) - 9: MoveLoc[1](loc0: u64) - 10: Add - 11: Ret + 3: MoveLoc[0](Arg0: u64) + 4: LdU64(1) + 5: Add + 6: Pop + 7: MoveLoc[1](loc0: u64) + 8: Add + 9: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.exp index 64990776e2cdc..08533b6b6dd91 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.exp @@ -92,14 +92,12 @@ public test(Arg0: u64, Arg1: u64): u64 * u64 /* def_idx: 0 */ { L2: loc0: u64 B0: 0: MoveLoc[0](Arg0: u64) - 1: StLoc[2](loc0: u64) - 2: MoveLoc[1](Arg1: u64) - 3: StLoc[0](Arg0: u64) - 4: MoveLoc[2](loc0: u64) - 5: StLoc[1](Arg1: u64) - 6: MoveLoc[0](Arg0: u64) - 7: MoveLoc[1](Arg1: u64) - 8: Ret + 1: MoveLoc[1](Arg1: u64) + 2: StLoc[0](Arg0: u64) + 3: StLoc[1](Arg1: u64) + 4: MoveLoc[0](Arg0: u64) + 5: MoveLoc[1](Arg1: u64) + 6: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.opt.exp index 64990776e2cdc..08533b6b6dd91 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.opt.exp @@ -92,14 +92,12 @@ public test(Arg0: u64, Arg1: u64): u64 * u64 /* def_idx: 0 */ { L2: loc0: u64 B0: 0: MoveLoc[0](Arg0: u64) - 1: StLoc[2](loc0: u64) - 2: MoveLoc[1](Arg1: u64) - 3: StLoc[0](Arg0: u64) - 4: MoveLoc[2](loc0: u64) - 5: StLoc[1](Arg1: u64) - 6: MoveLoc[0](Arg0: u64) - 7: MoveLoc[1](Arg1: u64) - 8: Ret + 1: MoveLoc[1](Arg1: u64) + 2: StLoc[0](Arg0: u64) + 3: StLoc[1](Arg1: u64) + 4: MoveLoc[0](Arg0: u64) + 5: MoveLoc[1](Arg1: u64) + 6: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.exp index e0b25100114af..4b4283ceb66ac 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.exp @@ -201,23 +201,21 @@ B1: 2: CopyLoc[2](loc0: u64) 3: LdU64(0) 4: Gt - 5: BrFalse(17) + 5: BrFalse(15) B2: 6: MoveLoc[0](Arg0: u64) - 7: StLoc[3](loc1: u64) - 8: MoveLoc[1](Arg1: u64) - 9: StLoc[0](Arg0: u64) - 10: MoveLoc[3](loc1: u64) - 11: StLoc[1](Arg1: u64) - 12: MoveLoc[2](loc0: u64) - 13: LdU64(1) - 14: Sub - 15: StLoc[2](loc0: u64) - 16: Branch(2) + 7: MoveLoc[1](Arg1: u64) + 8: StLoc[0](Arg0: u64) + 9: MoveLoc[2](loc0: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[2](loc0: u64) + 13: StLoc[1](Arg1: u64) + 14: Branch(2) B3: - 17: MoveLoc[0](Arg0: u64) - 18: MoveLoc[1](Arg1: u64) - 19: Ret + 15: MoveLoc[0](Arg0: u64) + 16: MoveLoc[1](Arg1: u64) + 17: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.opt.exp index e0b25100114af..4b4283ceb66ac 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.opt.exp @@ -201,23 +201,21 @@ B1: 2: CopyLoc[2](loc0: u64) 3: LdU64(0) 4: Gt - 5: BrFalse(17) + 5: BrFalse(15) B2: 6: MoveLoc[0](Arg0: u64) - 7: StLoc[3](loc1: u64) - 8: MoveLoc[1](Arg1: u64) - 9: StLoc[0](Arg0: u64) - 10: MoveLoc[3](loc1: u64) - 11: StLoc[1](Arg1: u64) - 12: MoveLoc[2](loc0: u64) - 13: LdU64(1) - 14: Sub - 15: StLoc[2](loc0: u64) - 16: Branch(2) + 7: MoveLoc[1](Arg1: u64) + 8: StLoc[0](Arg0: u64) + 9: MoveLoc[2](loc0: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[2](loc0: u64) + 13: StLoc[1](Arg1: u64) + 14: Branch(2) B3: - 17: MoveLoc[0](Arg0: u64) - 18: MoveLoc[1](Arg1: u64) - 19: Ret + 15: MoveLoc[0](Arg0: u64) + 16: MoveLoc[1](Arg1: u64) + 17: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.optimize-no-simplify.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.optimize-no-simplify.exp index 9d1a8ab06c8cb..2161a50d2b658 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.optimize-no-simplify.exp +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.optimize-no-simplify.exp @@ -6,5 +6,5 @@ Error: Script execution failed with VMError: { sub_status: Some(14566554180833181696), location: script, indices: [], - offsets: [(FunctionDefinitionIndex(0), 31)], + offsets: [(FunctionDefinitionIndex(0), 27)], } diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.optimize.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.optimize.exp index 9d1a8ab06c8cb..2161a50d2b658 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.optimize.exp +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.optimize.exp @@ -6,5 +6,5 @@ Error: Script execution failed with VMError: { sub_status: Some(14566554180833181696), location: script, indices: [], - offsets: [(FunctionDefinitionIndex(0), 31)], + offsets: [(FunctionDefinitionIndex(0), 27)], } diff --git a/types/src/on_chain_config/aptos_features.rs b/types/src/on_chain_config/aptos_features.rs index 44584ba52ec03..84ac59da3916f 100644 --- a/types/src/on_chain_config/aptos_features.rs +++ b/types/src/on_chain_config/aptos_features.rs @@ -96,6 +96,7 @@ pub enum FeatureFlag { TRANSACTION_SIMULATION_ENHANCEMENT = 78, COLLECTION_OWNER = 79, TRANSACTION_CONTEXT_HASH_FUNCTION_UPDATE = 80, + FAKE_FEATURE_FOR_COMPARISON_TESTING = 1000, } impl FeatureFlag { diff --git a/types/src/transaction/mod.rs b/types/src/transaction/mod.rs index 02085985d088c..fceb8264a19b8 100644 --- a/types/src/transaction/mod.rs +++ b/types/src/transaction/mod.rs @@ -684,6 +684,10 @@ impl SignedTransaction { self.raw_txn.max_gas_amount } + pub fn set_max_gmount(&mut self, new_value: u64) { + self.raw_txn.max_gas_amount = new_value; + } + pub fn gas_unit_price(&self) -> u64 { self.raw_txn.gas_unit_price }