diff --git a/aptos-move/aptos-e2e-comparison-testing/src/execution.rs b/aptos-move/aptos-e2e-comparison-testing/src/execution.rs index 4a803878916de..dcdaae42872b2 100644 --- a/aptos-move/aptos-e2e-comparison-testing/src/execution.rs +++ b/aptos-move/aptos-e2e-comparison-testing/src/execution.rs @@ -221,8 +221,11 @@ impl Execution { if compiled_cache.failed_packages_v2.contains(&package_info) { v2_failed = true; } else { - let compiled_res_v2 = - compile_package(package_dir, &package_info, Some(CompilerVersion::V2_0)); + let compiled_res_v2 = compile_package( + package_dir, + &package_info, + Some(CompilerVersion::latest_stable()), + ); if let Ok(compiled_res) = compiled_res_v2 { generate_compiled_blob( &package_info, diff --git a/aptos-move/aptos-e2e-comparison-testing/src/lib.rs b/aptos-move/aptos-e2e-comparison-testing/src/lib.rs index 83dbfb1af3613..ecea1b0793ba1 100644 --- a/aptos-move/aptos-e2e-comparison-testing/src/lib.rs +++ b/aptos-move/aptos-e2e-comparison-testing/src/lib.rs @@ -410,7 +410,7 @@ fn compile_aptos_packages( for package in APTOS_PACKAGES { let root_package_dir = aptos_commons_path.join(get_aptos_dir(package).unwrap()); let compiler_version = if v2_flag { - Some(CompilerVersion::V2_0) + Some(CompilerVersion::latest_stable()) } else { Some(CompilerVersion::V1) }; @@ -575,8 +575,11 @@ fn dump_and_compile_from_package_metadata( return Err(anyhow::Error::msg("compilation failed at v1")); } if execution_mode.is_some_and(|mode| mode.is_v2_or_compare()) { - let package_v2 = - compile_package(root_package_dir, &package_info, Some(CompilerVersion::V2_0)); + let package_v2 = compile_package( + root_package_dir, + &package_info, + Some(CompilerVersion::latest_stable()), + ); if let Ok(built_package) = package_v2 { generate_compiled_blob( &package_info, diff --git a/aptos-move/e2e-move-tests/src/lib.rs b/aptos-move/e2e-move-tests/src/lib.rs index 7d1f6343ceb2d..1b2bc1bc6a5fe 100644 --- a/aptos-move/e2e-move-tests/src/lib.rs +++ b/aptos-move/e2e-move-tests/src/lib.rs @@ -47,7 +47,7 @@ pub(crate) fn build_package( ) -> anyhow::Result { let mut options = options; if get_move_compiler_v2_from_env() { - options.compiler_version = Some(CompilerVersion::V2_0); + options.compiler_version = Some(CompilerVersion::latest_stable()); } BuiltPackage::build(package_path.to_owned(), options) } diff --git a/aptos-move/framework/src/built_package.rs b/aptos-move/framework/src/built_package.rs index 77c5bf7cd813d..1a7d5edfb3d9f 100644 --- a/aptos-move/framework/src/built_package.rs +++ b/aptos-move/framework/src/built_package.rs @@ -22,7 +22,10 @@ use move_compiler::compiled_unit::{CompiledUnit, NamedCompiledModule}; use move_compiler_v2::{external_checks::ExternalChecks, options::Options, Experiment}; use move_core_types::{language_storage::ModuleId, metadata::Metadata}; use move_model::{ - metadata::{CompilerVersion, LanguageVersion}, + metadata::{ + CompilerVersion, LanguageVersion, LATEST_STABLE_COMPILER_VERSION, + LATEST_STABLE_LANGUAGE_VERSION, + }, model::GlobalEnv, }; use move_package::{ @@ -88,10 +91,10 @@ pub struct BuildOptions { #[clap(long, default_value_if("move_2", "true", "7"))] pub bytecode_version: Option, #[clap(long, value_parser = clap::value_parser!(CompilerVersion), - default_value_if("move_2", "true", "2.0"))] + default_value_if("move_2", "true", LATEST_STABLE_COMPILER_VERSION))] pub compiler_version: Option, #[clap(long, value_parser = clap::value_parser!(LanguageVersion), - default_value_if("move_2", "true", "2.1"))] + default_value_if("move_2", "true", LATEST_STABLE_LANGUAGE_VERSION))] pub language_version: Option, #[clap(long)] pub skip_attribute_checks: bool, diff --git a/aptos-move/framework/tests/move_unit_test.rs b/aptos-move/framework/tests/move_unit_test.rs index d69c1d9697bb6..a84f0fea1332e 100644 --- a/aptos-move/framework/tests/move_unit_test.rs +++ b/aptos-move/framework/tests/move_unit_test.rs @@ -48,7 +48,7 @@ fn run_tests_for_pkg(path_to_pkg: impl Into) { } if get_move_compiler_v2_from_env() { // Run test against v2 when MOVE_COMPILER_V2 is set - compiler_config.compiler_version = Some(CompilerVersion::V2_0); + compiler_config.compiler_version = Some(CompilerVersion::latest_stable()); build_config.compiler_config = compiler_config; ok = run_move_unit_tests( &pkg_path, diff --git a/crates/aptos/src/common/types.rs b/crates/aptos/src/common/types.rs index 64a55c21cc90c..c218846e10e6e 100644 --- a/crates/aptos/src/common/types.rs +++ b/crates/aptos/src/common/types.rs @@ -53,7 +53,10 @@ use hex::FromHexError; use move_core_types::{ account_address::AccountAddress, language_storage::TypeTag, vm_status::VMStatus, }; -use move_model::metadata::{CompilerVersion, LanguageVersion}; +use move_model::metadata::{ + CompilerVersion, LanguageVersion, LATEST_STABLE_COMPILER_VERSION, + LATEST_STABLE_LANGUAGE_VERSION, +}; use move_package::source_package::std_lib::StdVersion; use serde::{Deserialize, Serialize}; #[cfg(unix)] @@ -1165,24 +1168,23 @@ pub struct MovePackageDir { /// ...or --compiler COMPILER_VERSION /// Specify the version of the compiler. - /// Defaults to `1`, or `2` if `--move-2` is selected. + /// Defaults to `1`, unless `--move-2` is selected. #[clap(long, value_parser = clap::value_parser!(CompilerVersion), alias = "compiler", - default_value_if("move_2", "true", "2.0"), + default_value_if("move_2", "true", LATEST_STABLE_COMPILER_VERSION), verbatim_doc_comment)] pub compiler_version: Option, /// ...or --language LANGUAGE_VERSION /// Specify the language version to be supported. - /// Currently, defaults to `1`, unless `--move-2` is selected. + /// Defaults to `1`, unless `--move-2` is selected. #[clap(long, value_parser = clap::value_parser!(LanguageVersion), alias = "language", - default_value_if("move_2", "true", "2.1"), + default_value_if("move_2", "true", LATEST_STABLE_LANGUAGE_VERSION), verbatim_doc_comment)] pub language_version: Option, - /// Select bytecode, language version, and compiler to support Move 2: - /// Same as `--bytecode-version=7 --language-version=2.1 --compiler-version=2.0` + /// Select bytecode, language, and compiler versions to support the latest Move 2. #[clap(long, verbatim_doc_comment)] pub move_2: bool, } diff --git a/crates/aptos/src/governance/mod.rs b/crates/aptos/src/governance/mod.rs index 175ca8ccc247f..48ed43d422d8b 100644 --- a/crates/aptos/src/governance/mod.rs +++ b/crates/aptos/src/governance/mod.rs @@ -43,7 +43,10 @@ use move_core_types::{ ident_str, language_storage::ModuleId, parser::parse_type_tag, transaction_argument::TransactionArgument, }; -use move_model::metadata::{CompilerVersion, LanguageVersion}; +use move_model::metadata::{ + CompilerVersion, LanguageVersion, LATEST_STABLE_COMPILER_VERSION, + LATEST_STABLE_LANGUAGE_VERSION, +}; use reqwest::Url; use serde::{Deserialize, Serialize}; use std::{ @@ -913,11 +916,11 @@ pub struct CompileScriptFunction { pub bytecode_version: Option, #[clap(long, value_parser = clap::value_parser!(CompilerVersion), - default_value_if("move_2", "true", "2.0"))] + default_value_if("move_2", "true", LATEST_STABLE_COMPILER_VERSION))] pub compiler_version: Option, #[clap(long, value_parser = clap::value_parser!(LanguageVersion), - default_value_if("move_2", "true", "2.0"))] + default_value_if("move_2", "true", LATEST_STABLE_LANGUAGE_VERSION))] pub language_version: Option, /// Select bytecode, language, compiler for Move 2 diff --git a/crates/aptos/src/move_tool/lint.rs b/crates/aptos/src/move_tool/lint.rs index 915379c3792cb..0b320098d65bf 100644 --- a/crates/aptos/src/move_tool/lint.rs +++ b/crates/aptos/src/move_tool/lint.rs @@ -10,7 +10,7 @@ use async_trait::async_trait; use clap::Parser; use move_compiler_v2::Experiment; use move_linter::MoveLintChecks; -use move_model::metadata::{CompilerVersion, LanguageVersion}; +use move_model::metadata::{CompilerVersion, LanguageVersion, LATEST_STABLE_LANGUAGE_VERSION}; use move_package::source_package::std_lib::StdVersion; use std::{collections::BTreeMap, path::PathBuf}; @@ -30,10 +30,10 @@ pub struct LintPackage { /// ...or --language LANGUAGE_VERSION /// Specify the language version to be supported. - /// Currently, defaults to `2.0`. + /// Defaults to the latest stable language version. #[clap(long, value_parser = clap::value_parser!(LanguageVersion), alias = "language", - default_value = "2.0", + default_value = LATEST_STABLE_LANGUAGE_VERSION, verbatim_doc_comment)] pub language_version: Option, diff --git a/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs b/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs index 483020e61a99e..ab7c9b862dbd0 100644 --- a/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs +++ b/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs @@ -122,7 +122,9 @@ impl ModuleGenerator { ) -> (FF::CompiledModule, SourceMap, Option) { let options = module_env.env.get_extension::().expect("options"); let language_version = options.language_version.unwrap_or_default(); - let compiler_version = options.compiler_version.unwrap_or(CompilerVersion::V2_0); + let compiler_version = options + .compiler_version + .unwrap_or(CompilerVersion::latest_stable()); let gen_access_specifiers = language_version.is_at_least(LanguageVersion::V2_0) && options.experiment_on(Experiment::GEN_ACCESS_SPECIFIERS); let compilation_metadata = CompilationMetadata::new(compiler_version, language_version); diff --git a/third_party/move/move-compiler-v2/tests/testsuite.rs b/third_party/move/move-compiler-v2/tests/testsuite.rs index fc9b5300aaa21..acbab3106d398 100644 --- a/third_party/move/move-compiler-v2/tests/testsuite.rs +++ b/third_party/move/move-compiler-v2/tests/testsuite.rs @@ -106,7 +106,7 @@ const TEST_CONFIGS: Lazy> = Lazy::new(|| { // Turn optimization on by default. Some configs below may turn it off. .set_experiment(Experiment::OPTIMIZE, true) .set_experiment(Experiment::OPTIMIZE_WAITING_FOR_COMPARE_TESTS, true) - .set_language_version(LanguageVersion::V2_1); + .set_language_version(LanguageVersion::latest_stable()); opts.testing = true; let configs = vec![ // --- Tests for checking and ast processing diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/tests.rs b/third_party/move/move-compiler-v2/transactional-tests/tests/tests.rs index 15ac83d8d0dae..340a2fc584682 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/tests.rs +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/tests.rs @@ -27,7 +27,9 @@ struct TestConfig { name: &'static str, runner: fn(&Path) -> datatest_stable::Result<()>, experiments: &'static [(&'static str, bool)], - language_version: LanguageVersion, + /// Run the tests with language version 1 (if true), + /// or with latest language version (if false). + is_lang_v1: bool, /// Path substrings for tests to include. If empty, all tests are included. include: &'static [&'static str], /// Path substrings for tests to exclude (applied after the include filter). @@ -44,7 +46,7 @@ const TEST_CONFIGS: &[TestConfig] = &[ (Experiment::OPTIMIZE_WAITING_FOR_COMPARE_TESTS, true), (Experiment::ACQUIRES_CHECK, false), ], - language_version: LanguageVersion::V2_1, + is_lang_v1: false, include: &[], // all tests except those excluded below exclude: &["/operator_eval/"], }, @@ -55,7 +57,7 @@ const TEST_CONFIGS: &[TestConfig] = &[ (Experiment::OPTIMIZE, false), (Experiment::ACQUIRES_CHECK, false), ], - language_version: LanguageVersion::V2_1, + is_lang_v1: false, include: &[], // all tests except those excluded below exclude: &["/operator_eval/"], }, @@ -68,7 +70,7 @@ const TEST_CONFIGS: &[TestConfig] = &[ (Experiment::AST_SIMPLIFY, false), (Experiment::ACQUIRES_CHECK, false), ], - language_version: LanguageVersion::V2_1, + is_lang_v1: false, include: &[], // all tests except those excluded below exclude: &["/operator_eval/"], }, @@ -76,7 +78,7 @@ const TEST_CONFIGS: &[TestConfig] = &[ name: "operator-eval-lang-1", runner: |p| run(p, get_config_by_name("operator-eval-lang-1")), experiments: &[(Experiment::OPTIMIZE, true)], - language_version: LanguageVersion::V1, + is_lang_v1: true, include: &["/operator_eval/"], exclude: &[], }, @@ -84,7 +86,7 @@ const TEST_CONFIGS: &[TestConfig] = &[ name: "operator-eval-lang-2", runner: |p| run(p, get_config_by_name("operator-eval-lang-2")), experiments: &[(Experiment::OPTIMIZE, true)], - language_version: LanguageVersion::V2_1, + is_lang_v1: false, include: &["/operator_eval/"], exclude: &[], }, @@ -134,7 +136,11 @@ fn run(path: &Path, config: TestConfig) -> datatest_stable::Result<()> { // Enable access control file format generation for those tests v2_experiments.push((Experiment::GEN_ACCESS_SPECIFIERS.to_string(), true)) } - let language_version = config.language_version; + let language_version = if config.is_lang_v1 { + LanguageVersion::V1 + } else { + LanguageVersion::latest_stable() + }; let vm_test_config = if p.contains(SKIP_V1_COMPARISON_PATH) || move_test_debug() { TestRunConfig::CompilerV2 { language_version, diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/testsuite.rs b/third_party/move/move-model/bytecode/ast-generator-tests/tests/testsuite.rs index 557b3a7e837be..d1d392fcde9ca 100644 --- a/third_party/move/move-model/bytecode/ast-generator-tests/tests/testsuite.rs +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/testsuite.rs @@ -35,7 +35,7 @@ fn test_runner(path: &Path) -> datatest_stable::Result<()> { named_address_mapping: vec!["std=0x1".to_string()], ..Options::default() }; - options = options.set_language_version(LanguageVersion::V2_1); + options = options.set_language_version(LanguageVersion::latest_stable()); let mut test_output = String::new(); let mut error_writer = Buffer::no_color(); match run_move_compiler_for_analysis(&mut error_writer, options) { diff --git a/third_party/move/move-model/src/metadata.rs b/third_party/move/move-model/src/metadata.rs index 1e7b3a0f1f049..338b6d9e94a29 100644 --- a/third_party/move/move-model/src/metadata.rs +++ b/third_party/move/move-model/src/metadata.rs @@ -17,6 +17,8 @@ use std::{ }; const UNSTABLE_MARKER: &str = "-unstable"; +pub const LATEST_STABLE_LANGUAGE_VERSION: &str = "2.1"; +pub const LATEST_STABLE_COMPILER_VERSION: &str = "2.0"; pub static COMPILATION_METADATA_KEY: &[u8] = "compilation_metadata".as_bytes(); @@ -152,7 +154,7 @@ impl CompilerVersion { /// The latest stable compiler version. pub fn latest_stable() -> Self { - CompilerVersion::V2_0 + CompilerVersion::from_str(LATEST_STABLE_COMPILER_VERSION).expect("valid version") } /// Check whether the compiler version supports the given language version, @@ -256,7 +258,7 @@ impl LanguageVersion { /// The latest stable language version. pub fn latest_stable() -> Self { - LanguageVersion::V2_1 + LanguageVersion::from_str(LATEST_STABLE_LANGUAGE_VERSION).expect("valid version") } /// Whether the language version is equal to greater than `ver` diff --git a/third_party/move/tools/move-package/tests/test_runner.rs b/third_party/move/tools/move-package/tests/test_runner.rs index 937a5313cb19d..dbc20ebb3e51a 100644 --- a/third_party/move/tools/move-package/tests/test_runner.rs +++ b/third_party/move/tools/move-package/tests/test_runner.rs @@ -124,7 +124,7 @@ fn check_or_update( update_baseline: bool, compiler_version: CompilerVersion, ) -> datatest_stable::Result<()> { - let exp_ext = if compiler_version == CompilerVersion::V2_0 { + let exp_ext = if compiler_version != CompilerVersion::V1 { EXP_EXT_V2 } else { EXP_EXT