Skip to content

Commit

Permalink
remove use of v2_exp and v2 environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
rahxephon89 committed Jan 7, 2025
1 parent 708b1de commit e51881b
Show file tree
Hide file tree
Showing 51 changed files with 125 additions and 301 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions aptos-move/aptos-release-builder/src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use aptos_types::{
};
use futures::executor::block_on;
use handlebars::Handlebars;
use move_binary_format::file_format_common::VERSION_6;
use move_binary_format::file_format_common::VERSION_DEFAULT_LANG_V2;
use once_cell::sync::Lazy;
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};
use std::{
Expand Down Expand Up @@ -733,7 +733,7 @@ impl Default for ReleaseConfig {
metadata: ProposalMetadata::default(),
name: "framework".to_string(),
update_sequence: vec![ReleaseEntry::Framework(FrameworkReleaseConfig {
bytecode_version: VERSION_6,
bytecode_version: VERSION_DEFAULT_LANG_V2,
git_hash: None,
})],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ use codespan_reporting::{diagnostic::Severity, term::termcolor::Buffer};
use move_binary_format::file_format::{CompiledModule, CompiledScript};
use move_bytecode_verifier::verify_module;
use move_command_line_common::{
address::ParsedAddress,
env::{get_move_compiler_block_v1_from_env, get_move_compiler_v2_from_env},
files::verify_and_create_named_address_mapping,
testing::{EXP_EXT, EXP_EXT_V2},
address::ParsedAddress, env::get_move_compiler_block_v1_from_env,
files::verify_and_create_named_address_mapping, testing::EXP_EXT,
};
use move_compiler::{
self,
Expand Down Expand Up @@ -1114,22 +1112,17 @@ fn precompiled_v2_stdlib_if_needed(
}

pub fn run_aptos_test(path: &Path) -> Result<(), Box<dyn std::error::Error>> {
run_aptos_test_with_config(path, TestRunConfig::CompilerV1)
run_aptos_test_with_config(path, TestRunConfig::CompilerV2 {
language_version: LanguageVersion::default(),
v2_experiments: vec![("attach-compiled-module".to_owned(), true)],
})
}

pub fn run_aptos_test_with_config(
path: &Path,
config: TestRunConfig,
) -> Result<(), Box<dyn std::error::Error>> {
let (suffix, config) =
if get_move_compiler_v2_from_env() && !matches!(config, TestRunConfig::CompilerV2 { .. }) {
(Some(EXP_EXT_V2.to_owned()), TestRunConfig::CompilerV2 {
language_version: LanguageVersion::default(),
v2_experiments: vec![("attach-compiled-module".to_owned(), true)],
})
} else {
(Some(EXP_EXT.to_owned()), config)
};
let suffix = Some(EXP_EXT.to_owned());
let v1_lib = precompiled_v1_stdlib_if_needed(&config);
let v2_lib = precompiled_v2_stdlib_if_needed(&config);
set_paranoid_type_checks(true);
Expand Down
10 changes: 0 additions & 10 deletions aptos-move/aptos-transactional-test-harness/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,4 @@ fn runner(path: &Path) -> anyhow::Result<(), Box<dyn std::error::Error>> {
language_version: LanguageVersion::latest_stable(),
v2_experiments: vec![("attach-compiled-module".to_owned(), true)],
})
// if path.to_str().unwrap().contains("v2-tests/") {
// // TODO: we may later want to change this to comparison testing. For now we are mostly
// // interested in debugging v2 bytecode.
// run_aptos_test_with_config(path, TestRunConfig::CompilerV2 {
// language_version: LanguageVersion::latest_stable(),
// v2_experiments: vec![("attach-compiled-module".to_owned(), true)],
// })
// } else {
// run_aptos_test_with_config(path, TestRunConfig::CompilerV1)
// }
}
1 change: 0 additions & 1 deletion aptos-move/e2e-move-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ bcs = { workspace = true }
claims = { workspace = true }
hex = { workspace = true }
move-binary-format = { workspace = true }
move-command-line-common = { workspace = true }
move-core-types = { workspace = true }
move-model = { workspace = true }
move-package = { workspace = true }
Expand Down
8 changes: 1 addition & 7 deletions aptos-move/e2e-move-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub mod stake;
use anyhow::bail;
use aptos_framework::{BuildOptions, BuiltPackage, UPGRADE_POLICY_CUSTOM_FIELD};
pub use harness::*;
use move_command_line_common::env::get_move_compiler_v2_from_env;
#[cfg(test)]
use move_model::metadata::CompilerVersion;
use move_package::{package_hooks::PackageHooks, source_package::parsed_manifest::CustomDepInfo};
use move_symbol_pool::Symbol;
Expand Down Expand Up @@ -45,12 +45,6 @@ pub(crate) fn build_package(
package_path: PathBuf,
options: BuildOptions,
) -> anyhow::Result<BuiltPackage> {
let mut options = options;
if get_move_compiler_v2_from_env() {
options.compiler_version = Some(CompilerVersion::latest_stable());
options.language_version =
Some(CompilerVersion::latest_stable().infer_stable_language_version());
}
BuiltPackage::build(package_path.to_owned(), options)
}

Expand Down
28 changes: 3 additions & 25 deletions aptos-move/framework/tests/move_unit_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,26 @@ use aptos_types::on_chain_config::{
};
use aptos_vm::natives;
use move_cli::base::test::{run_move_unit_tests, UnitTestResult};
use move_command_line_common::env::get_move_compiler_v2_from_env;
use move_model::metadata::CompilerVersion;
use move_package::CompilerConfig;
use move_unit_test::UnitTestingConfig;
use move_vm_runtime::native_functions::NativeFunctionTable;
use tempfile::tempdir;

fn run_tests_for_pkg(path_to_pkg: impl Into<String>) {
let pkg_path = path_in_crate(path_to_pkg);
let mut compiler_config = CompilerConfig {
let compiler_config = CompilerConfig {
known_attributes: extended_checks::get_all_attribute_names().clone(),
..Default::default()
};
let mut build_config = move_package::BuildConfig {
let build_config = move_package::BuildConfig {
test_mode: true,
install_dir: Some(tempdir().unwrap().path().to_path_buf()),
compiler_config: compiler_config.clone(),
full_model_generation: true, // Run extended checks also on test code
..Default::default()
};

let mut ok = run_move_unit_tests(
let ok = run_move_unit_tests(
&pkg_path,
build_config.clone(),
// TODO(Gas): double check if this is correct
Expand All @@ -46,26 +44,6 @@ fn run_tests_for_pkg(path_to_pkg: impl Into<String>) {
if ok != UnitTestResult::Success {
panic!("move unit tests failed")
}
if get_move_compiler_v2_from_env() {
// Run test against v2 when MOVE_COMPILER_V2 is set
compiler_config.compiler_version = Some(CompilerVersion::latest_stable());
build_config.compiler_config = compiler_config;
ok = run_move_unit_tests(
&pkg_path,
build_config,
UnitTestingConfig::default(),
aptos_test_natives(),
aptos_test_feature_flags_genesis(),
/* gas_limit */ Some(100_000),
/* cost_table */ None,
/* compute_coverage */ false,
&mut std::io::stdout(),
)
.unwrap();
}
if ok != UnitTestResult::Success {
panic!("move unit tests failed for compiler v2")
}
}

pub fn aptos_test_natives() -> NativeFunctionTable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Error: Unable to publish module '00000000000000000000000000000000000000000000000
major_status: CONSTRAINT_NOT_SATISFIED,
sub_status: None,
location: 0x42::pwn,
indices: [(FunctionDefinition, 2)],
indices: [(FunctionDefinition, 1)],
offsets: [],
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
processed 1 task

task 0 'publish'. lines 1-93:
Error: error[E04024]: invalid usage of function type
┌─ TEMPFILE:9:62
Error: compilation errors:
error: Only inline functions may have function-typed parameters, but non-inline function `test_case::for_each_ref` has a function parameter:
┌─ TEMPFILE:9:16
9 │ public fun for_each_ref<Element>(v: &vector<Element>, f: |&Element|) {
^^^^^^^^^^ function-typed values only allowed for inline function arguments
^^^^^^^^^^^^ - Parameter `f` has function-valued type `|&Element|`.


10 changes: 2 additions & 8 deletions third_party/move/move-command-line-common/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@
// Copyright (c) The Move Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::env::{get_move_compiler_v2_from_env, read_bool_env_var};
use crate::env::read_bool_env_var;

/// Extension for raw output files
pub const OUT_EXT: &str = "out";
/// Extension for expected output files
pub const EXP_EXT: &str = "exp";
/// Extension for expected output files compiled by v2
pub const EXP_EXT_V2: &str = "v2_exp";

pub fn get_compiler_exp_extension() -> &'static str {
if get_move_compiler_v2_from_env() {
EXP_EXT_V2
} else {
EXP_EXT
}
EXP_EXT
}

/// If any of these env vars is set, the test harness should overwrite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
// SPDX-License-Identifier: Apache-2.0

pub const TEST_DIR: &str = "tests";
use move_transactional_test_runner::vm_test_harness::run_test;
use move_transactional_test_runner::vm_test_harness::run_test_v1;

datatest_stable::harness!(run_test, TEST_DIR, r".*\.(mvir|move)$");
datatest_stable::harness!(run_test_1, TEST_DIR, r".*\.(mvir|move)$");
2 changes: 0 additions & 2 deletions third_party/move/move-prover/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use clap::{builder::PossibleValuesParser, Arg, ArgAction, ArgAction::SetTrue, Co
use codespan_reporting::diagnostic::Severity;
use log::LevelFilter;
use move_abigen::AbigenOptions;
use move_command_line_common::env::{bool_to_str, get_move_compiler_v2_from_env};
use move_compiler::{command_line::SKIP_ATTRIBUTE_CHECKS, shared::NumericalAddress};
use move_docgen::DocgenOptions;
use move_errmapgen::ErrmapOptions;
Expand Down Expand Up @@ -189,7 +188,6 @@ impl Options {
.arg(
Arg::new("compiler-v2")
.long("compiler-v2")
.default_value(bool_to_str(get_move_compiler_v2_from_env()))
.action(SetTrue)
.help("whether to use Move compiler v2 to compile to bytecode")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ pub trait MoveTestAdapter<'a>: Sized {
fn default_syntax(&self) -> SyntaxChoice;
fn known_attributes(&self) -> &BTreeSet<String>;
fn run_config(&self) -> TestRunConfig {
TestRunConfig::CompilerV1
TestRunConfig::CompilerV2 {
language_version: LanguageVersion::default(),
v2_experiments: vec![],
}
}
fn init(
default_syntax: SyntaxChoice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use move_binary_format::{
use move_bytecode_verifier::VerifierConfig;
use move_command_line_common::{
address::ParsedAddress,
env::{get_move_compiler_block_v1_from_env, get_move_compiler_v2_from_env, read_bool_env_var},
env::{get_move_compiler_block_v1_from_env, read_bool_env_var},
files::verify_and_create_named_address_mapping,
testing::{EXP_EXT, EXP_EXT_V2},
testing::EXP_EXT,
};
use move_compiler::{
compiled_unit::AnnotatedCompiledUnit,
Expand Down Expand Up @@ -650,7 +650,20 @@ pub enum TestRunConfig {
}

pub fn run_test(path: &Path) -> Result<(), Box<dyn std::error::Error>> {
run_test_with_config(TestRunConfig::CompilerV1, path)
run_test_with_config(
TestRunConfig::CompilerV2 {
language_version: LanguageVersion::default(),
v2_experiments: vec![],
},
path,
)
}

pub fn run_test_v1(path: &Path) -> Result<(), Box<dyn std::error::Error>> {
run_test_with_config(
TestRunConfig::CompilerV1,
path,
)
}

fn precompiled_v1_stdlib_if_needed(
Expand All @@ -677,15 +690,7 @@ pub fn run_test_with_config(
config: TestRunConfig,
path: &Path,
) -> Result<(), Box<dyn std::error::Error>> {
let (suffix, config) =
if get_move_compiler_v2_from_env() && !matches!(config, TestRunConfig::CompilerV2 { .. }) {
(Some(EXP_EXT_V2.to_owned()), TestRunConfig::CompilerV2 {
language_version: LanguageVersion::default(),
v2_experiments: vec![],
})
} else {
(Some(EXP_EXT.to_owned()), config)
};
let (suffix, config) = (Some(EXP_EXT.to_owned()), config);
let v1_lib = precompiled_v1_stdlib_if_needed(&config);
let v2_lib = precompiled_v2_stdlib_if_needed(&config);
run_test_impl::<SimpleVMTestAdapter>(config, path, v1_lib, v2_lib, &suffix)
Expand All @@ -696,15 +701,6 @@ pub fn run_test_with_config_and_exp_suffix(
path: &Path,
exp_suffix: &Option<String>,
) -> Result<(), Box<dyn std::error::Error>> {
let config =
if get_move_compiler_v2_from_env() && !matches!(config, TestRunConfig::CompilerV2 { .. }) {
TestRunConfig::CompilerV2 {
language_version: LanguageVersion::default(),
v2_experiments: vec![],
}
} else {
config
};
let v1_lib = precompiled_v1_stdlib_if_needed(&config);
let v2_lib = precompiled_v2_stdlib_if_needed(&config);
run_test_impl::<SimpleVMTestAdapter>(config, path, v1_lib, v2_lib, exp_suffix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,45 @@ processed 10 tasks
task 3 'view'. lines 13-15:
[No Resource Exists]

task 4 'publish'. lines 17-35:
Error: compilation errors:
error: duplicate declaration, item, or annotation
┌─ TEMPFILE:4:11
4 │ module A::N {
│ ^ Duplicate definition for module '(A=0x42)::N'
┌─ TEMPFILE2:18:11
18 │ module A::N {
│ - Module previously defined here, with '(A=0x42)::N'



task 5 'run'. lines 37-37:
Error: Function execution failed with VMError: {
major_status: ABORTED,
sub_status: Some(0),
location: 0x42::N,
major_status: FUNCTION_RESOLUTION_FAILURE,
sub_status: None,
location: undefined,
indices: [],
offsets: [(FunctionDefinitionIndex(0), 1)],
offsets: [],
}

task 6 'run'. lines 39-45:
Error: compilation errors:
error: no function named `N::give` found
┌─ TEMPFILE3:42:9
42 │ A::N::give(&s)
│ ^^^^^^^^^^^^^^



task 7 'view'. lines 47-49:
key 0x42::N::R<u64> {
v: 0
}
[No Resource Exists]

task 8 'run'. lines 51-58:
Error: Unbound function 0000000000000000000000000000000000000000000000000000000000000042.N.take

task 9 'view'. lines 60-62:
[No Resource Exists]
Loading

0 comments on commit e51881b

Please sign in to comment.