Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compiler-v2] Set V2 as the default compiler #15408

Merged
merged 11 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions .github/actions/move-tests-compiler-v2/action.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/actions/rust-targeted-unit-tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ runs:
run: |
cargo x targeted-unit-tests -vvv --profile ci --cargo-profile ci --locked --no-fail-fast --retries 3
shell: bash
env:
MVC_BLOCK_V1: "true"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vineethk Added MVC_BLOCK_V1 for CI.

INDEXER_DATABASE_URL: postgresql://postgres@localhost/postgres
RUST_MIN_STACK: "4297152"
MVP_TEST_ON_CI: "true"
SOLC_EXE: /home/runner/bin/solc
Z3_EXE: /home/runner/bin/z3
CVC5_EXE: /home/runner/bin/cvc5
DOTNET_ROOT: /home/runner/.dotnet
BOOGIE_EXE: /home/runner/.dotnet/tools/boogie

- name: Run only the targeted unit tests for compiler v1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is added for crates that are not guarded by MVC_BLOCK_V1

run: |
cargo x targeted-compiler-unit-tests -vvv --profile ci --cargo-profile ci --locked --no-fail-fast --retries 3
shell: bash
env:
INDEXER_DATABASE_URL: postgresql://postgres@localhost/postgres
RUST_MIN_STACK: "4297152"
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/move-test-compiler-v2.yaml

This file was deleted.

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.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"bytecode": "0xa11ceb0b0700000a0c010002020208030a30053a23075d7b08d8012006f8010a1082029a010a9c030d0ca9037e0da704060fad040400020003060000040700000500010001000602030001000704050001000804060001000907080001000a04030001000b09050001000c090600010205070301080002050301080101060800010301050206080006080101010106080100076163636f756e74066f626a6563740467756964044755494402494406637265617465096372656174655f69640c6372656174696f6e5f6e756d0f63726561746f725f616464726573730565715f69640269640f69645f6372656174696f6e5f6e756d1269645f63726561746f725f616464726573730461646472000000000000000000000000000000000000000000000000000000000000000103080000000000000000126170746f733a3a6d657461646174615f763185010100000000000000001d45475549445f47454e455241544f525f4e4f545f5055424c49534845445b475549442067656e657261746f72206d757374206265207075626c6973686564206168656164206f66206669727374207573616765206f6620606372656174655f776974685f6361706162696c697479602066756e6374696f6e2e00000002010a080101020207030d0500030000050d0a01140c020a02060100000000000000160b01150b020b001201120002010100000a040b010b00120102020100000a050b00100010011402030100000a050b00100010021402040100000a050b0010000b012102050100000a040b0010001402060100000a040b0010011402070100000a040b00100214020000010001010000000100",
"bytecode": "0xa11ceb0b0700000a0b010002020208030a30053a23075d7b08d8012010f801b9010ab1030d0cbe037e0dbc04060fc2040400000001060000030700000600010001000703040001000406020001000806070001000908090001000206040001000a0a020001000b0a0700010205070301080001030205030108010001060800010502060800060801010101060801046775696404475549440269640249440c6372656174696f6e5f6e756d046164647206637265617465096372656174655f69640f63726561746f725f616464726573730565715f69640f69645f6372656174696f6e5f6e756d1269645f63726561746f725f61646472657373076163636f756e74066f626a656374000000000000000000000000000000000000000000000000000000000000000114636f6d70696c6174696f6e5f6d65746164617461090003322e3003322e31126170746f733a3a6d657461646174615f763185010100000000000000001d45475549445f47454e455241544f525f4e4f545f5055424c49534845445b475549442067656e657261746f72206d757374206265207075626c6973686564206168656164206f66206669727374207573616765206f6620606372656174655f776974685f6361706162696c697479602066756e6374696f6e2e00000002010208010102020403050500030000020d0a01140c020a02060100000000000000160b01150b020b0012011200020101000005040b010b001201020201000005050b001000100114020301000005050b001000100214020401000005050b0010000b0121020501000005040b00100014020601000005040b00100114020701000005040b0010021402000001000101000c000d00",
rahxephon89 marked this conversation as resolved.
Show resolved Hide resolved
"abi": {
"address": "0x1",
"name": "guid",
Expand Down
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
processed 2 tasks

task 1 'run'. lines 4-21:
Error: Failed to execute transaction. ExecutionStatus: ExecutionFailure { location: Script, function: 0, code_offset: 11 }
Error: Failed to execute transaction. ExecutionStatus: ExecutionFailure { location: Script, function: 0, code_offset: 10 }
Original file line number Diff line number Diff line change
@@ -1,76 +1,62 @@
processed 4 tasks

task 1 'print-bytecode'. lines 4-35:
Error: extended checks failed:
// Move bytecode v7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide a brief comment about this change in output due to compiler v2? I see that this change pre-exists (as seen from .v2_exp).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we have a V1-only bug for this: #14722

module f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6.game {
use 0000000000000000000000000000000000000000000000000000000000000001::signer;
use 0000000000000000000000000000000000000000000000000000000000000001::debug;

bug: BYTECODE VERIFICATION FAILED
┌─ TEMPFILE:25:13
25 │ debug::print(field); // INTERNAL TEST ERROR: INTERNAL VM INVARIANT VIOLATION
│ ^^^^^^^^^^^^^^^^^^^ ICE failed bytecode verifier: VMError {
major_status: CALL_TYPE_MISMATCH_ERROR,
sub_status: None,
message: None,
exec_state: None,
location: Module(
ModuleId {
address: f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6,
name: Identifier(
"game",
),
},
),
indices: [
(
FunctionDefinition,
0,
),
],
offsets: [
(
FunctionDefinitionIndex(0),
25,
),
],
}



task 2 'publish'. lines 37-68:
Error: extended checks failed:

bug: BYTECODE VERIFICATION FAILED
┌─ TEMPFILE1:58:13
58 │ debug::print(field); // INTERNAL TEST ERROR: INTERNAL VM INVARIANT VIOLATION
│ ^^^^^^^^^^^^^^^^^^^ ICE failed bytecode verifier: VMError {
major_status: CALL_TYPE_MISMATCH_ERROR,
sub_status: None,
message: None,
exec_state: None,
location: Module(
ModuleId {
address: f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6,
name: Identifier(
"game",
),
},
),
indices: [
(
FunctionDefinition,
0,
),
],
offsets: [
(
FunctionDefinitionIndex(0),
25,
),
],
struct InnerStruct has copy, store, key {
amount: u64
}
struct OuterStruct has key {
any_field: vector<InnerStruct>
}


entry public test_upgrade(Arg0: &signer) /* def_idx: 0 */ {
L1: loc0: &mut vector<InnerStruct>
L2: loc1: u64
L3: loc2: u64
B0:
0: CopyLoc[0](Arg0: &signer)
1: Call signer::address_of(&signer): address
2: MoveLoc[0](Arg0: &signer)
3: VecPack(3, 0)
4: Pack[1](OuterStruct)
5: MoveTo[1](OuterStruct)
6: MutBorrowGlobal[1](OuterStruct)
7: MutBorrowField[0](OuterStruct.any_field: vector<InnerStruct>)
8: StLoc[1](loc0: &mut vector<InnerStruct>)
9: LdU64(0)
10: StLoc[2](loc1: u64)
11: CopyLoc[1](loc0: &mut vector<InnerStruct>)
12: FreezeRef
13: VecLen(3)
14: StLoc[3](loc2: u64)
B1:
15: CopyLoc[2](loc1: u64)
16: CopyLoc[3](loc2: u64)
17: Lt
18: BrFalse(29)
B2:
19: CopyLoc[1](loc0: &mut vector<InnerStruct>)
20: CopyLoc[2](loc1: u64)
21: VecMutBorrow(3)
22: FreezeRef
23: Call debug::print<InnerStruct>(&InnerStruct)
24: MoveLoc[2](loc1: u64)
25: LdU64(1)
26: Add
27: StLoc[2](loc1: u64)
28: Branch(15)
B3:
29: MoveLoc[1](loc0: &mut vector<InnerStruct>)
30: Pop
31: Ret
}
}

task 3 'run'. lines 70-70:
Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(Some(LINKER_ERROR))
mutable inputs after call: local#0: 0
return values: 0
14 changes: 4 additions & 10 deletions aptos-move/aptos-transactional-test-harness/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@ use std::path::Path;
datatest_stable::harness!(runner, "tests", r".*\.(mvir|move)$");

fn runner(path: &Path) -> anyhow::Result<(), Box<dyn std::error::Error>> {
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::default(),
v2_experiments: vec![("attach-compiled-module".to_owned(), true)],
})
} else {
run_aptos_test_with_config(path, TestRunConfig::CompilerV1)
}
run_aptos_test_with_config(path, TestRunConfig::CompilerV2 {
language_version: LanguageVersion::latest_stable(),
v2_experiments: vec![("attach-compiled-module".to_owned(), true)],
})
}
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 @@ -31,7 +31,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
6 changes: 1 addition & 5 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,10 +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());
}
BuiltPackage::build(package_path.to_owned(), options)
}

Expand Down
4 changes: 2 additions & 2 deletions aptos-move/e2e-move-tests/src/tests/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ fn test_compilation_metadata_internal(
let path = builder.write_to_temp().unwrap();

let compiler_version = if v2_flag {
CompilerVersion::V2_1
CompilerVersion::latest()
} else {
CompilerVersion::V1
};
Expand Down Expand Up @@ -298,7 +298,7 @@ fn test_compilation_metadata_script_internal(
let path = builder.write_to_temp().unwrap();

let compiler_version = if v2_flag {
CompilerVersion::V2_1
CompilerVersion::latest()
} else {
CompilerVersion::V1
};
Expand Down
Loading
Loading