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

[move-ide] Added virtualized source file reader #16213

Closed
wants to merge 11 commits into from
Closed
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
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions crates/sui-core/src/authority/authority_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ pub fn build_test_modules_with_dep_addr(
for (addr_name, obj_id) in dep_original_addresses {
build_config
.config
.build_info
.additional_named_addresses
.insert(addr_name.to_string(), AccountAddress::from(obj_id));
}
Expand Down Expand Up @@ -461,6 +462,7 @@ pub async fn publish_package_on_single_authority(
for (addr_name, obj_id) in dep_original_addresses {
build_config
.config
.build_info
.additional_named_addresses
.insert(addr_name.to_string(), AccountAddress::from(obj_id));
}
Expand Down
43 changes: 28 additions & 15 deletions crates/sui-core/src/unit_tests/authority_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5375,6 +5375,7 @@ async fn test_publish_transitive_dependencies_ok() {
let mut build_config = BuildConfig::new_for_testing();
build_config
.config
.build_info
.additional_named_addresses
.insert("c".to_string(), AccountAddress::ZERO);

Expand Down Expand Up @@ -5407,10 +5408,14 @@ async fn test_publish_transitive_dependencies_ok() {
package_b_path.extend(["src", "unit_tests", "data", "transitive_dependencies", "b"]);

let mut build_config = BuildConfig::new_for_testing();
build_config.config.additional_named_addresses.extend([
("b".to_string(), AccountAddress::ZERO),
("c".to_string(), (package_c_id).into()),
]);
build_config
.config
.build_info
.additional_named_addresses
.extend([
("b".to_string(), AccountAddress::ZERO),
("c".to_string(), (package_c_id).into()),
]);

let modules = build_config
.build(package_b_path)
Expand Down Expand Up @@ -5443,11 +5448,15 @@ async fn test_publish_transitive_dependencies_ok() {
package_a_path.extend(["src", "unit_tests", "data", "transitive_dependencies", "a"]);

let mut build_config = BuildConfig::new_for_testing();
build_config.config.additional_named_addresses.extend([
("a".to_string(), AccountAddress::ZERO),
("b".to_string(), (package_b_id).into()),
("c".to_string(), (package_c_id).into()),
]);
build_config
.config
.build_info
.additional_named_addresses
.extend([
("a".to_string(), AccountAddress::ZERO),
("b".to_string(), (package_b_id).into()),
("c".to_string(), (package_c_id).into()),
]);

let modules = build_config
.build(package_a_path)
Expand Down Expand Up @@ -5486,12 +5495,16 @@ async fn test_publish_transitive_dependencies_ok() {
]);

let mut build_config = BuildConfig::new_for_testing();
build_config.config.additional_named_addresses.extend([
("examples".to_string(), AccountAddress::ZERO),
("a".to_string(), (package_a_id).into()),
("b".to_string(), (package_b_id).into()),
("c".to_string(), (package_c_id).into()),
]);
build_config
.config
.build_info
.additional_named_addresses
.extend([
("examples".to_string(), AccountAddress::ZERO),
("a".to_string(), (package_a_id).into()),
("b".to_string(), (package_b_id).into()),
("c".to_string(), (package_c_id).into()),
]);

let modules = build_config
.build(package_root_path)
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-core/src/unit_tests/move_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2774,7 +2774,7 @@ fn ascii_tag() -> TypeTag {
#[cfg_attr(msim, ignore)]
async fn test_object_no_id_error() {
let mut build_config = BuildConfig::new_for_testing();
build_config.config.test_mode = true;
build_config.config.build_info.test_mode = true;
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
// in this package object struct (NotObject) is defined incorrectly and publishing should
// fail (it's defined in test-only code hence cannot be checked by transactional testing
Expand Down
5 changes: 3 additions & 2 deletions crates/sui-core/src/unit_tests/move_package_publish_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,15 @@ async fn test_generate_lock_file() {
let lock_file_path = tmp.path().join("Move.lock");

let mut build_config = BuildConfig::new_for_testing();
build_config.config.lock_file = Some(lock_file_path.clone());
build_config.config.build_info.lock_file = Some(lock_file_path.clone());
build_config
.clone()
.build(path.clone())
.expect("Move package did not build");
// Update the lock file with placeholder compiler version so this isn't bumped every release.
build_config
.config
.build_info
.update_lock_file_toolchain_version(&path, "0.0.1".into())
.expect("Could not update lock file");

Expand Down Expand Up @@ -288,7 +289,7 @@ async fn test_custom_property_parse_published_at() {
#[tokio::test]
#[cfg_attr(msim, ignore)]
async fn test_custom_property_check_unpublished_dependencies() {
let build_config = BuildConfig::new_for_testing();
let mut build_config = BuildConfig::new_for_testing();
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.extend([
"src",
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-framework-tests/src/metered_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use sui_verifier::{default_verifier_config, meter::SuiVerifierMeter};

fn build(path: PathBuf) -> SuiResult<CompiledPackage> {
let mut config = sui_move_build::BuildConfig::new_for_testing();
config.config.warnings_are_errors = true;
config.config.build_info.warnings_are_errors = true;
config.build(path)
}

Expand Down
18 changes: 9 additions & 9 deletions crates/sui-framework-tests/src/unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ fn run_docs_examples_move_unit_tests() -> io::Result<()> {
/// Ensure packages build outside of test mode.
fn check_package_builds(path: PathBuf) {
let mut config = BuildConfig::new_for_testing();
config.config.dev_mode = true;
config.config.build_info.dev_mode = true;
config.run_bytecode_verifier = true;
config.print_diags_to_stderr = true;
config.config.warnings_are_errors = true;
config.config.silence_warnings = false;
config.config.no_lint = false;
config.config.build_info.warnings_are_errors = true;
config.config.build_info.silence_warnings = false;
config.config.build_info.no_lint = false;
config
.build(path.clone())
.unwrap_or_else(|e| panic!("Building package {}.\nWith error {e}", path.display()));
Expand All @@ -101,13 +101,13 @@ fn check_package_builds(path: PathBuf) {
fn check_move_unit_tests(path: PathBuf) {
let mut config = BuildConfig::new_for_testing();
// Make sure to verify tests
config.config.dev_mode = true;
config.config.test_mode = true;
config.config.build_info.dev_mode = true;
config.config.build_info.test_mode = true;
config.run_bytecode_verifier = true;
config.print_diags_to_stderr = true;
config.config.warnings_are_errors = true;
config.config.silence_warnings = false;
config.config.no_lint = false;
config.config.build_info.warnings_are_errors = true;
config.config.build_info.silence_warnings = false;
config.config.build_info.no_lint = false;
let move_config = config.config.clone();
let mut testing_config = UnitTestingConfig::default_with_bound(Some(3_000_000));
testing_config.filter = std::env::var(FILTER_ENV).ok().map(|s| s.to_string());
Expand Down
32 changes: 19 additions & 13 deletions crates/sui-framework/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use anyhow::Result;
use move_binary_format::CompiledModule;
use move_package::BuildConfig as MoveBuildConfig;
use move_package::{BuildConfig as MoveBuildConfig, BuildInfo};
use std::{
env, fs,
path::{Path, PathBuf},
Expand Down Expand Up @@ -88,13 +88,16 @@ fn build_packages(
out_dir: PathBuf,
) {
let config = MoveBuildConfig {
generate_docs: true,
warnings_are_errors: true,
install_dir: Some(PathBuf::from(".")),
no_lint: true,
..Default::default()
build_info: BuildInfo {
generate_docs: true,
warnings_are_errors: true,
install_dir: Some(PathBuf::from(".")),
no_lint: true,
..Default::default()
},
file_reader: None,
};
debug_assert!(!config.test_mode);
debug_assert!(!config.build_info.test_mode);
build_packages_with_move_config(
bridge_path.clone(),
deepbook_path.clone(),
Expand All @@ -110,12 +113,15 @@ fn build_packages(
true,
);
let config = MoveBuildConfig {
generate_docs: true,
test_mode: true,
warnings_are_errors: true,
install_dir: Some(PathBuf::from(".")),
no_lint: true,
..Default::default()
build_info: BuildInfo {
generate_docs: true,
test_mode: true,
warnings_are_errors: true,
install_dir: Some(PathBuf::from(".")),
no_lint: true,
..Default::default()
},
file_reader: None,
};
build_packages_with_move_config(
bridge_path,
Expand Down
23 changes: 15 additions & 8 deletions crates/sui-move-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use move_package::{
},
package_hooks::{PackageHooks, PackageIdentifier},
resolution::resolution_graph::ResolvedGraph,
BuildConfig as MoveBuildConfig,
BuildConfig as MoveBuildConfig, BuildInfo,
};
use move_package::{
resolution::resolution_graph::Package, source_package::parsed_manifest::CustomDepInfo,
Expand Down Expand Up @@ -85,9 +85,9 @@ impl BuildConfig {
let mut build_config: Self = Default::default();
let install_dir = tempfile::tempdir().unwrap().into_path();
let lock_file = install_dir.join("Move.lock");
build_config.config.install_dir = Some(install_dir);
build_config.config.lock_file = Some(lock_file);
build_config.config.no_lint = true;
build_config.config.build_info.install_dir = Some(install_dir);
build_config.config.build_info.lock_file = Some(lock_file);
build_config.config.build_info.no_lint = true;
build_config
}

Expand All @@ -100,6 +100,7 @@ impl BuildConfig {
for (addr_name, obj_id) in dep_original_addresses {
build_config
.config
.build_info
.additional_named_addresses
.insert(addr_name.into(), AccountAddress::from(obj_id));
}
Expand All @@ -125,7 +126,7 @@ impl BuildConfig {
resolution_graph: ResolvedGraph,
writer: &mut W,
) -> anyhow::Result<(MoveCompiledPackage, FnInfoMap)> {
let build_plan = BuildPlan::create(resolution_graph)?;
let mut build_plan = BuildPlan::create(resolution_graph, None)?;
let mut fn_info = None;
let compiled_pkg = build_plan.compile_with_driver(writer, |compiler| {
let (files, units_res) = compiler.build()?;
Expand Down Expand Up @@ -215,7 +216,10 @@ pub fn decorate_warnings(warning_diags: Diagnostics, files: Option<&FilesSourceT
pub fn set_sui_flavor(build_config: &mut MoveBuildConfig) -> Option<String> {
use move_compiler::editions::Flavor;

let flavor = build_config.default_flavor.get_or_insert(Flavor::Sui);
let flavor = build_config
.build_info
.default_flavor
.get_or_insert(Flavor::Sui);
if flavor != &Flavor::Sui {
return Some(format!(
"The flavor of the Move compiler cannot be overridden with anything but \
Expand Down Expand Up @@ -578,8 +582,11 @@ impl CompiledPackage {
impl Default for BuildConfig {
fn default() -> Self {
let config = MoveBuildConfig {
default_flavor: Some(move_compiler::editions::Flavor::Sui),
..MoveBuildConfig::default()
build_info: BuildInfo {
default_flavor: Some(move_compiler::editions::Flavor::Sui),
..BuildInfo::default()
},
file_reader: None,
};
BuildConfig {
config,
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-move/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ pub fn resolve_lock_file_path(
mut build_config: MoveBuildConfig,
package_path: Option<PathBuf>,
) -> Result<MoveBuildConfig, anyhow::Error> {
if build_config.lock_file.is_none() {
if build_config.build_info.lock_file.is_none() {
let package_root = base::reroot_path(package_path)?;
let lock_file_path = package_root.join(SourcePackageLayout::Lock.path());
build_config.lock_file = Some(lock_file_path);
build_config.build_info.lock_file = Some(lock_file_path);
}
Ok(build_config)
}
4 changes: 2 additions & 2 deletions crates/sui-source-validation-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ pub async fn verify_package(
MoveBuildConfig::default(),
Some(package_path.as_ref().to_path_buf()),
)?;
config.no_lint = true;
config.silence_warnings = true;
config.build_info.no_lint = true;
config.build_info.silence_warnings = true;
let build_config = BuildConfig {
config,
run_bytecode_verifier: false, /* no need to run verifier if code is on-chain */
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-source-validation-service/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async fn run_publish(
let build_config = BuildConfig::new_for_testing().config;
let resp = SuiClientCommands::Publish {
package_path: package_path.clone(),
build_config,
build_info: build_config.build_info,
gas: Some(gas_obj_id),
gas_budget: rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH,
skip_dependency_verification: false,
Expand Down Expand Up @@ -208,7 +208,7 @@ async fn run_upgrade(
let resp = SuiClientCommands::Upgrade {
package_path: upgrade_pkg_path,
upgrade_capability: cap.reference.object_id,
build_config,
build_info: build_config.build_info,
gas: Some(gas_obj_id),
gas_budget: rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH,
skip_dependency_verification: false,
Expand Down
Loading
Loading