From 1fe1d543d08e04543e85ace3a95f649c0383d717 Mon Sep 17 00:00:00 2001 From: Michael George Date: Fri, 28 Feb 2025 10:34:54 -0500 Subject: [PATCH 1/4] Added sui implicit dependencies everywhere a sui `BuildConfig` is created --- Cargo.lock | 2 + crates/sui-move-build/src/lib.rs | 47 +++++++++++++++---- crates/sui-move/Cargo.toml | 1 + crates/sui-move/src/build.rs | 8 +++- .../src/system_package_versions.rs | 2 + .../sui-source-validation-service/Cargo.toml | 1 + .../sui-source-validation-service/src/lib.rs | 4 +- crates/sui/src/client_commands.rs | 36 +++++++++++--- 8 files changed, 83 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b6d034ce8427b..3b700376e0ffc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14323,6 +14323,7 @@ dependencies = [ "sui-macros", "sui-move-build", "sui-move-natives-latest", + "sui-package-management", "sui-protocol-config", "sui-types", "telemetry-subscribers", @@ -15286,6 +15287,7 @@ dependencies = [ "sui-json-rpc-types", "sui-move", "sui-move-build", + "sui-package-management", "sui-sdk", "sui-source-validation", "telemetry-subscribers", diff --git a/crates/sui-move-build/src/lib.rs b/crates/sui-move-build/src/lib.rs index f41c268194bd9..85e1ee03f3864 100644 --- a/crates/sui-move-build/src/lib.rs +++ b/crates/sui-move-build/src/lib.rs @@ -34,15 +34,21 @@ use move_package::{ }, package_hooks::{PackageHooks, PackageIdentifier}, resolution::{dependency_graph::DependencyGraph, resolution_graph::ResolvedGraph}, - source_package::parsed_manifest::{Dependencies, PackageName}, - BuildConfig as MoveBuildConfig, LintFlag, + source_package::parsed_manifest::{ + Dependencies, Dependency, DependencyKind, GitInfo, InternalDependency, PackageName, + }, + BuildConfig as MoveBuildConfig, }; use move_package::{ source_package::parsed_manifest::OnChainInfo, source_package::parsed_manifest::SourceManifest, }; use move_symbol_pool::Symbol; use serde_reflection::Registry; -use sui_package_management::{resolve_published_id, PublishedAtError}; +use sui_package_management::{ + resolve_published_id, + system_package_versions::{SystemPackagesVersion, SYSTEM_GIT_REPO}, + PublishedAtError, +}; use sui_protocol_config::{Chain, ProtocolConfig, ProtocolVersion}; use sui_types::{ base_types::ObjectID, @@ -110,18 +116,17 @@ pub struct BuildConfig { impl BuildConfig { pub fn new_for_testing() -> Self { move_package::package_hooks::register_package_hooks(Box::new(SuiPackageHooks)); - - // Note: in the future, consider changing this to dependencies on the local system - // packages: - let implicit_dependencies = Dependencies::new(); let install_dir = tempfile::tempdir().unwrap().into_path(); + let config = MoveBuildConfig { default_flavor: Some(move_compiler::editions::Flavor::Sui), - implicit_dependencies, + lock_file: Some(install_dir.join("Move.lock")), install_dir: Some(install_dir), - lint_flag: LintFlag::LEVEL_NONE, silence_warnings: true, + lint_flag: move_package::LintFlag::LEVEL_NONE, + // TODO: in the future this should probably be changed to a set of local deps: + implicit_dependencies: Dependencies::new(), ..MoveBuildConfig::default() }; BuildConfig { @@ -709,6 +714,30 @@ impl CompiledPackage { } } +/// Create a set of [Dependencies] from a [SystemPackagesVersion]; the dependencies are override git +/// dependencies to the specific revision given by the [SystemPackagesVersion] +pub fn implicit_deps(packages: &SystemPackagesVersion) -> Dependencies { + packages + .packages + .iter() + .map(|package| { + ( + package.package_name.clone().into(), + Dependency::Internal(InternalDependency { + kind: DependencyKind::Git(GitInfo { + git_url: SYSTEM_GIT_REPO.into(), + git_rev: packages.git_revision.clone().into(), + subdir: package.repo_path.clone().into(), + }), + subst: None, + digest: None, + dep_override: true, + }), + ) + }) + .collect() +} + impl GetModule for CompiledPackage { type Error = anyhow::Error; // TODO: return ref here for better efficiency? Borrow checker + all_modules_map() make it hard to do this diff --git a/crates/sui-move/Cargo.toml b/crates/sui-move/Cargo.toml index b6bfeb84b9472..13584cdae882a 100644 --- a/crates/sui-move/Cargo.toml +++ b/crates/sui-move/Cargo.toml @@ -34,6 +34,7 @@ sui-move-natives = { path = "../../sui-execution/latest/sui-move-natives", packa sui-move-build.workspace = true sui-protocol-config.workspace = true sui-types.workspace = true +sui-package-management.workspace = true better_any = "0.1.1" [target.'cfg(not(target_env = "msvc"))'.dependencies] diff --git a/crates/sui-move/src/build.rs b/crates/sui-move/src/build.rs index 9c5ded8e4d077..07d634b22f0ef 100644 --- a/crates/sui-move/src/build.rs +++ b/crates/sui-move/src/build.rs @@ -7,7 +7,10 @@ use move_cli::base; use move_package::BuildConfig as MoveBuildConfig; use serde_json::json; use std::{fs, path::Path}; -use sui_move_build::{check_invalid_dependencies, check_unpublished_dependencies, BuildConfig}; +use sui_move_build::{ + check_invalid_dependencies, check_unpublished_dependencies, implicit_deps, BuildConfig, +}; +use sui_package_management::system_package_versions::latest_system_packages; const LAYOUTS_DIR: &str = "layouts"; const STRUCT_LAYOUTS_FILENAME: &str = "struct_layouts.yaml"; @@ -61,12 +64,13 @@ impl Build { pub fn execute_internal( rerooted_path: &Path, - config: MoveBuildConfig, + mut config: MoveBuildConfig, with_unpublished_deps: bool, dump_bytecode_as_base64: bool, generate_struct_layouts: bool, chain_id: Option, ) -> anyhow::Result<()> { + config.implicit_dependencies = implicit_deps(latest_system_packages()); let mut pkg = BuildConfig { config, run_bytecode_verifier: true, diff --git a/crates/sui-package-management/src/system_package_versions.rs b/crates/sui-package-management/src/system_package_versions.rs index 55a6def42c802..339006dfebd5c 100644 --- a/crates/sui-package-management/src/system_package_versions.rs +++ b/crates/sui-package-management/src/system_package_versions.rs @@ -16,6 +16,8 @@ static VERSION_TABLE: LazyLock> ))) }); +pub const SYSTEM_GIT_REPO: &str = "https://github.com/MystenLabs/sui.git"; + #[derive(Debug)] pub struct SystemPackagesVersion { pub git_revision: String, diff --git a/crates/sui-source-validation-service/Cargo.toml b/crates/sui-source-validation-service/Cargo.toml index 36f1bf325d4f1..4a27d4b0a1f49 100644 --- a/crates/sui-source-validation-service/Cargo.toml +++ b/crates/sui-source-validation-service/Cargo.toml @@ -27,6 +27,7 @@ url = "2.3.1" sui-move.workspace = true sui-move-build.workspace = true +sui-package-management.workspace = true sui-sdk.workspace = true sui-source-validation.workspace = true diff --git a/crates/sui-source-validation-service/src/lib.rs b/crates/sui-source-validation-service/src/lib.rs index ff95996921ea5..547832b257787 100644 --- a/crates/sui-source-validation-service/src/lib.rs +++ b/crates/sui-source-validation-service/src/lib.rs @@ -9,6 +9,7 @@ use std::path::PathBuf; use std::sync::{Arc, RwLock}; use std::time::Duration; use std::{ffi::OsString, fs, path::Path, process::Command}; +use sui_package_management::system_package_versions::latest_system_packages; use tokio::sync::oneshot::Sender; use anyhow::{anyhow, bail}; @@ -30,7 +31,7 @@ use move_core_types::account_address::AccountAddress; use move_package::{BuildConfig as MoveBuildConfig, LintFlag}; use move_symbol_pool::Symbol; use sui_move::manage_package::resolve_lock_file_path; -use sui_move_build::{BuildConfig, SuiPackageHooks}; +use sui_move_build::{implicit_deps, BuildConfig, SuiPackageHooks}; use sui_sdk::rpc_types::SuiTransactionBlockEffects; use sui_sdk::types::base_types::ObjectID; use sui_sdk::SuiClientBuilder; @@ -163,6 +164,7 @@ pub async fn verify_package( resolve_lock_file_path(MoveBuildConfig::default(), Some(package_path.as_ref()))?; config.lint_flag = LintFlag::LEVEL_NONE; config.silence_warnings = true; + config.implicit_dependencies = implicit_deps(latest_system_packages()); let build_config = BuildConfig { config, run_bytecode_verifier: false, /* no need to run verifier if code is on-chain */ diff --git a/crates/sui/src/client_commands.rs b/crates/sui/src/client_commands.rs index 4a34db4fc4b42..9df2282efa048 100644 --- a/crates/sui/src/client_commands.rs +++ b/crates/sui/src/client_commands.rs @@ -31,7 +31,7 @@ use reqwest::StatusCode; use move_binary_format::CompiledModule; use move_bytecode_verifier_meter::Scope; use move_core_types::{account_address::AccountAddress, language_storage::TypeTag}; -use move_package::BuildConfig as MoveBuildConfig; +use move_package::{source_package::parsed_manifest::Dependencies, BuildConfig as MoveBuildConfig}; use prometheus::Registry; use serde::Serialize; use serde_json::{json, Value}; @@ -52,9 +52,12 @@ use sui_json_rpc_types::{ use sui_keys::keystore::AccountKeystore; use sui_move_build::{ build_from_resolution_graph, check_invalid_dependencies, check_unpublished_dependencies, - gather_published_ids, BuildConfig, CompiledPackage, + gather_published_ids, implicit_deps, BuildConfig, CompiledPackage, +}; +use sui_package_management::{ + system_package_versions::{latest_system_packages, system_packages_for_protocol}, + LockCommand, PublishedAtError, }; -use sui_package_management::{LockCommand, PublishedAtError}; use sui_replay::ReplayToolCommand; use sui_sdk::{ apis::ReadApi, @@ -1677,7 +1680,7 @@ impl SuiClientCommands { ), SuiClientCommands::VerifySource { package_path, - build_config, + mut build_config, verify_deps, skip_source, address_override, @@ -1694,6 +1697,7 @@ impl SuiClientCommands { (true, true, Some(at)) => ValidationMode::root_and_deps_at(*at), }; + build_config.implicit_dependencies = implicit_deps(latest_system_packages()); let build_config = resolve_lock_file_path(build_config, Some(&package_path))?; let chain_id = context .get_client() @@ -1763,10 +1767,11 @@ fn check_dep_verification_flags( } fn compile_package_simple( - build_config: MoveBuildConfig, + mut build_config: MoveBuildConfig, package_path: &Path, chain_id: Option, ) -> Result { + build_config.implicit_dependencies = implicit_deps(latest_system_packages()); let config = BuildConfig { config: resolve_lock_file_path(build_config, Some(package_path))?, run_bytecode_verifier: false, @@ -1855,11 +1860,15 @@ pub(crate) async fn upgrade_package( pub(crate) async fn compile_package( read_api: &ReadApi, - build_config: MoveBuildConfig, + mut build_config: MoveBuildConfig, package_path: &Path, with_unpublished_dependencies: bool, skip_dependency_verification: bool, ) -> Result { + let protocol_config = read_api.get_protocol_config(None).await?; + let protocol_version = protocol_config.protocol_version; + + build_config.implicit_dependencies = implicit_deps_for_protocol_version(protocol_version)?; let config = resolve_lock_file_path(build_config, Some(package_path))?; let run_bytecode_verifier = true; let print_diags_to_stderr = true; @@ -1989,6 +1998,21 @@ pub(crate) async fn compile_package( Ok(compiled_package) } +/// Return the correct implicit dependencies for the [version], producing a warning or error if the +/// protocol version is unknown or old +fn implicit_deps_for_protocol_version(version: ProtocolVersion) -> anyhow::Result { + if version > ProtocolVersion::MAX + 2 { + eprintln!( + "[{}]: The network is using protocol version {:?}, which is newer than this binary; \ + the system packages used for compilation (e.g. MoveStdlib) may be out of date.", + "warning".bold().yellow(), + version + ) + } + + Ok(implicit_deps(system_packages_for_protocol(version)?.0)) +} + impl Display for SuiClientCommandResult { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { let mut writer = String::new(); From c32eafea9b98bc8e79ba0542df3edefc7e1c2e5f Mon Sep 17 00:00:00 2001 From: Michael George Date: Thu, 20 Feb 2025 17:26:45 -0500 Subject: [PATCH 2/4] removed dep from sui move new --- crates/sui-move/src/new.rs | 7 +----- crates/sui-source-validation/src/lib.rs | 6 +++++ .../shell_tests/new_tests/new_then_test.sh | 10 -------- ...ests__new_tests__manifest_template.sh.snap | 1 - ...l_tests__new_tests__new_then_build.sh.snap | 3 +++ ...d_bytecode_with_address_resolution.sh.snap | 10 ++++++++ ...verification_deprecation__no_flags.sh.snap | 25 +++++++++++++++++++ ...cation_deprecation__skip_dep_verif.sh.snap | 25 +++++++++++++++++++ 8 files changed, 70 insertions(+), 17 deletions(-) diff --git a/crates/sui-move/src/new.rs b/crates/sui-move/src/new.rs index d0ba1242d35d5..cf9790afa23ff 100644 --- a/crates/sui-move/src/new.rs +++ b/crates/sui-move/src/new.rs @@ -6,11 +6,6 @@ use move_cli::base::new; use move_package::source_package::layout::SourcePackageLayout; use std::{fs::create_dir_all, io::Write, path::Path}; -const SUI_PKG_NAME: &str = "Sui"; - -// Use testnet by default. Probably want to add options to make this configurable later -const SUI_PKG_PATH: &str = "{ git = \"https://github.com/MystenLabs/sui.git\", subdir = \"crates/sui-framework/packages/sui-framework\", rev = \"framework/testnet\", override = true }"; - #[derive(Parser)] #[group(id = "sui-move-new")] pub struct New { @@ -24,7 +19,7 @@ impl New { let provided_name = &self.new.name.to_string(); self.new - .execute(path, [(SUI_PKG_NAME, SUI_PKG_PATH)], [(name, "0x0")], "")?; + .execute(path, [] as [(&str, &str); 0], [(name, "0x0")], "")?; let p = path.unwrap_or_else(|| Path::new(&provided_name)); let mut w = std::fs::File::create( p.join(SourcePackageLayout::Sources.path()) diff --git a/crates/sui-source-validation/src/lib.rs b/crates/sui-source-validation/src/lib.rs index 8a8749ac3a7d4..0f271b906feb0 100644 --- a/crates/sui-source-validation/src/lib.rs +++ b/crates/sui-source-validation/src/lib.rs @@ -234,6 +234,12 @@ impl ValidationMode { } })?; + // only keep modules that are actually used + let deps_compiled_units: Vec<_> = deps_compiled_units + .into_iter() + .filter(|pkg| sui_package.dependency_ids.published.contains_key(&pkg.0)) + .collect(); + for (package, local_unit) in deps_compiled_units { let m = &local_unit.unit; let module = m.name; diff --git a/crates/sui/tests/shell_tests/new_tests/new_then_test.sh b/crates/sui/tests/shell_tests/new_tests/new_then_test.sh index 051d2945589a5..fe9ce4db7ff22 100644 --- a/crates/sui/tests/shell_tests/new_tests/new_then_test.sh +++ b/crates/sui/tests/shell_tests/new_tests/new_then_test.sh @@ -4,14 +4,4 @@ # check that sui move new followed by sui move test succeeds sui move new example -# we mangle the generated toml file to replace the framework dependency with a local dependency -FRAMEWORK_DIR=$(echo $CARGO_MANIFEST_DIR | sed 's#/crates/sui##g') -cat example/Move.toml \ - | sed 's#\(Sui = .*\)git = "[^"]*", \(.*\)#\1\2#' \ - | sed 's#\(Sui = .*\), rev = "[^"]*"\(.*\)#\1\2#' \ - | sed 's#\(Sui = .*\)subdir = "\([^"]*\)"\(.*\)#\1local = "FRAMEWORK/\2"\3#' \ - | sed "s#\(Sui = .*\)FRAMEWORK\(.*\)#\1$FRAMEWORK_DIR\2#" \ - > Move.toml -mv Move.toml example/Move.toml - cd example && sui move test diff --git a/crates/sui/tests/snapshots/shell_tests__new_tests__manifest_template.sh.snap b/crates/sui/tests/snapshots/shell_tests__new_tests__manifest_template.sh.snap index 64f1a3cae2ce4..175fbb7c897d9 100644 --- a/crates/sui/tests/snapshots/shell_tests__new_tests__manifest_template.sh.snap +++ b/crates/sui/tests/snapshots/shell_tests__new_tests__manifest_template.sh.snap @@ -20,7 +20,6 @@ edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move # authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] [dependencies] -Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet", override = true } # For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`. # Revision can be a branch, a tag, and a commit hash. diff --git a/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_build.sh.snap b/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_build.sh.snap index 06501ff6f3e5a..c0b6b1186e276 100644 --- a/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_build.sh.snap +++ b/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_build.sh.snap @@ -28,6 +28,9 @@ exit_code: 0 ----- stdout ----- ----- stderr ----- +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING example diff --git a/crates/sui/tests/snapshots/shell_tests__with_network__move_build_bytecode_with_address_resolution__move_build_bytecode_with_address_resolution.sh.snap b/crates/sui/tests/snapshots/shell_tests__with_network__move_build_bytecode_with_address_resolution__move_build_bytecode_with_address_resolution.sh.snap index fc4994ae909d1..2b0989b231537 100644 --- a/crates/sui/tests/snapshots/shell_tests__with_network__move_build_bytecode_with_address_resolution__move_build_bytecode_with_address_resolution.sh.snap +++ b/crates/sui/tests/snapshots/shell_tests__with_network__move_build_bytecode_with_address_resolution__move_build_bytecode_with_address_resolution.sh.snap @@ -22,7 +22,17 @@ exit_code: 0 } ----- stderr ----- +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING simple Successfully verified dependencies on-chain against source. INCLUDING DEPENDENCY simple +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING depends_on_simple diff --git a/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__no_flags.sh.snap b/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__no_flags.sh.snap index d0017cd7750c0..af9ac007c5dcb 100644 --- a/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__no_flags.sh.snap +++ b/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__no_flags.sh.snap @@ -65,26 +65,51 @@ exit_code: 0 === munge Move.toml files === === publish dependency === [Note]: Dependency sources are no longer verified automatically during publication and upgrade. You can pass the `--verify-deps` option if you would like to verify them as part of publication or upgrade. +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING dependency Skipping dependency verification === publish package v0 (should note deprecation) === [Note]: Dependency sources are no longer verified automatically during publication and upgrade. You can pass the `--verify-deps` option if you would like to verify them as part of publication or upgrade. INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example Skipping dependency verification === upgrade package (should note deprecation) === [Note]: Dependency sources are no longer verified automatically during publication and upgrade. You can pass the `--verify-deps` option if you would like to verify them as part of publication or upgrade. INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example Skipping dependency verification === modify dependency === === try to publish with modified dep (should succeed) === [Note]: Dependency sources are no longer verified automatically during publication and upgrade. You can pass the `--verify-deps` option if you would like to verify them as part of publication or upgrade. INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example Skipping dependency verification === try to upgrade with modified dep (should succeed) === [Note]: Dependency sources are no longer verified automatically during publication and upgrade. You can pass the `--verify-deps` option if you would like to verify them as part of publication or upgrade. INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example Skipping dependency verification diff --git a/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__skip_dep_verif.sh.snap b/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__skip_dep_verif.sh.snap index dcfb6f87af9ea..9390b8551185f 100644 --- a/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__skip_dep_verif.sh.snap +++ b/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__skip_dep_verif.sh.snap @@ -65,26 +65,51 @@ exit_code: 0 === munge Move.toml files === === publish dependency (should warn about deprecation) === [Warning]: Dependency sources are no longer verified automatically during publication and upgrade, so the `--skip-dependency-verification` flag is no longer necessary. +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING dependency Skipping dependency verification === publish package v0 (should warn about deprecation) === [Warning]: Dependency sources are no longer verified automatically during publication and upgrade, so the `--skip-dependency-verification` flag is no longer necessary. INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example Skipping dependency verification === upgrade package (should warn about deprecation) === [Warning]: Dependency sources are no longer verified automatically during publication and upgrade, so the `--skip-dependency-verification` flag is no longer necessary. INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example Skipping dependency verification === modify dependency === === try to publish with modified dep (should succeed) === [Warning]: Dependency sources are no longer verified automatically during publication and upgrade, so the `--skip-dependency-verification` flag is no longer necessary. INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example Skipping dependency verification === try to upgrade with modified dep (should succeed) === [Warning]: Dependency sources are no longer verified automatically during publication and upgrade, so the `--skip-dependency-verification` flag is no longer necessary. INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example Skipping dependency verification From c2262ab07f94667c980ed9ad59fedc2f83b19999 Mon Sep 17 00:00:00 2001 From: Michael George Date: Fri, 21 Feb 2025 14:38:16 -0500 Subject: [PATCH 3/4] Including implicit deps for `sui move test` --- crates/sui-move/src/unit_test.rs | 6 ++++-- .../dependency/Move.toml | 3 +-- .../example/Move.toml | 2 +- .../shell_tests__new_tests__new_then_test.sh.snap | 13 +++---------- ...rce_verification_deprecation__no_flags.sh.snap | 15 --------------- ...rification_deprecation__skip_dep_verif.sh.snap | 15 --------------- ...rification_deprecation__with_dep_verif.sh.snap | 10 ++++++++++ 7 files changed, 19 insertions(+), 45 deletions(-) diff --git a/crates/sui-move/src/unit_test.rs b/crates/sui-move/src/unit_test.rs index 6d9afd93b35e5..9b37cb86df0cf 100644 --- a/crates/sui-move/src/unit_test.rs +++ b/crates/sui-move/src/unit_test.rs @@ -11,9 +11,10 @@ use move_unit_test::{extensions::set_extension_hook, UnitTestingConfig}; use move_vm_runtime::native_extensions::NativeContextExtensions; use once_cell::sync::Lazy; use std::{cell::RefCell, collections::BTreeMap, path::Path, sync::Arc}; -use sui_move_build::decorate_warnings; +use sui_move_build::{decorate_warnings, implicit_deps}; use sui_move_natives::test_scenario::InMemoryTestStore; use sui_move_natives::{object_runtime::ObjectRuntime, NativesCostTable}; +use sui_package_management::system_package_versions::latest_system_packages; use sui_protocol_config::ProtocolConfig; use sui_types::{ gas_model::tables::initial_cost_schedule_for_unit_tests, in_memory_storage::InMemoryStorage, @@ -71,7 +72,7 @@ static SET_EXTENSION_HOOK: Lazy<()> = /// successfully started running the test, and the inner result indicatests whether all tests pass. pub fn run_move_unit_tests( path: &Path, - build_config: BuildConfig, + mut build_config: BuildConfig, config: Option, compute_coverage: bool, save_disassembly: bool, @@ -81,6 +82,7 @@ pub fn run_move_unit_tests( let config = config .unwrap_or_else(|| UnitTestingConfig::default_with_bound(Some(MAX_UNIT_TEST_INSTRUCTIONS))); + build_config.implicit_dependencies = implicit_deps(latest_system_packages()); let result = move_cli::base::test::run_move_unit_tests( path, diff --git a/crates/sui/tests/shell_tests/with_network/source_verification_deprecation/dependency/Move.toml b/crates/sui/tests/shell_tests/with_network/source_verification_deprecation/dependency/Move.toml index bdaa4f5cb5000..bacb0b76d84ea 100644 --- a/crates/sui/tests/shell_tests/with_network/source_verification_deprecation/dependency/Move.toml +++ b/crates/sui/tests/shell_tests/with_network/source_verification_deprecation/dependency/Move.toml @@ -3,8 +3,7 @@ name = "dependency" edition = "2024.beta" [dependencies] -# Sui = { local = "FRAMEWORK_DIR", override = true } +Sui = { local = "FRAMEWORK_DIR", override = true } [addresses] dependency = "0x0" - diff --git a/crates/sui/tests/shell_tests/with_network/source_verification_deprecation/example/Move.toml b/crates/sui/tests/shell_tests/with_network/source_verification_deprecation/example/Move.toml index 75849203259ac..7c64b4d6eddd0 100644 --- a/crates/sui/tests/shell_tests/with_network/source_verification_deprecation/example/Move.toml +++ b/crates/sui/tests/shell_tests/with_network/source_verification_deprecation/example/Move.toml @@ -3,7 +3,7 @@ name = "example" edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move [dependencies] -# Sui = { local = "FRAMEWORK_DIR" } +Sui = { local = "FRAMEWORK_DIR" } dependency = { local = "../dependency" } [addresses] diff --git a/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_test.sh.snap b/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_test.sh.snap index e70031835eb4f..38fc444f8515b 100644 --- a/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_test.sh.snap +++ b/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_test.sh.snap @@ -9,22 +9,15 @@ description: tests/shell_tests/new_tests/new_then_test.sh # check that sui move new followed by sui move test succeeds sui move new example -# we mangle the generated toml file to replace the framework dependency with a local dependency -FRAMEWORK_DIR=$(echo $CARGO_MANIFEST_DIR | sed 's#/crates/sui##g') -cat example/Move.toml \ - | sed 's#\(Sui = .*\)git = "[^"]*", \(.*\)#\1\2#' \ - | sed 's#\(Sui = .*\), rev = "[^"]*"\(.*\)#\1\2#' \ - | sed 's#\(Sui = .*\)subdir = "\([^"]*\)"\(.*\)#\1local = "FRAMEWORK/\2"\3#' \ - | sed "s#\(Sui = .*\)FRAMEWORK\(.*\)#\1$FRAMEWORK_DIR\2#" \ - > Move.toml -mv Move.toml example/Move.toml - cd example && sui move test ----- results ----- success: true exit_code: 0 ----- stdout ----- +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING example diff --git a/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__no_flags.sh.snap b/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__no_flags.sh.snap index af9ac007c5dcb..7df98d9c05118 100644 --- a/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__no_flags.sh.snap +++ b/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__no_flags.sh.snap @@ -65,9 +65,6 @@ exit_code: 0 === munge Move.toml files === === publish dependency === [Note]: Dependency sources are no longer verified automatically during publication and upgrade. You can pass the `--verify-deps` option if you would like to verify them as part of publication or upgrade. -INCLUDING DEPENDENCY Bridge -INCLUDING DEPENDENCY DeepBook -INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING dependency @@ -75,9 +72,6 @@ Skipping dependency verification === publish package v0 (should note deprecation) === [Note]: Dependency sources are no longer verified automatically during publication and upgrade. You can pass the `--verify-deps` option if you would like to verify them as part of publication or upgrade. INCLUDING DEPENDENCY dependency -INCLUDING DEPENDENCY Bridge -INCLUDING DEPENDENCY DeepBook -INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING example @@ -85,9 +79,6 @@ Skipping dependency verification === upgrade package (should note deprecation) === [Note]: Dependency sources are no longer verified automatically during publication and upgrade. You can pass the `--verify-deps` option if you would like to verify them as part of publication or upgrade. INCLUDING DEPENDENCY dependency -INCLUDING DEPENDENCY Bridge -INCLUDING DEPENDENCY DeepBook -INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING example @@ -96,9 +87,6 @@ Skipping dependency verification === try to publish with modified dep (should succeed) === [Note]: Dependency sources are no longer verified automatically during publication and upgrade. You can pass the `--verify-deps` option if you would like to verify them as part of publication or upgrade. INCLUDING DEPENDENCY dependency -INCLUDING DEPENDENCY Bridge -INCLUDING DEPENDENCY DeepBook -INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING example @@ -106,9 +94,6 @@ Skipping dependency verification === try to upgrade with modified dep (should succeed) === [Note]: Dependency sources are no longer verified automatically during publication and upgrade. You can pass the `--verify-deps` option if you would like to verify them as part of publication or upgrade. INCLUDING DEPENDENCY dependency -INCLUDING DEPENDENCY Bridge -INCLUDING DEPENDENCY DeepBook -INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING example diff --git a/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__skip_dep_verif.sh.snap b/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__skip_dep_verif.sh.snap index 9390b8551185f..e41b4a1b17772 100644 --- a/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__skip_dep_verif.sh.snap +++ b/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__skip_dep_verif.sh.snap @@ -65,9 +65,6 @@ exit_code: 0 === munge Move.toml files === === publish dependency (should warn about deprecation) === [Warning]: Dependency sources are no longer verified automatically during publication and upgrade, so the `--skip-dependency-verification` flag is no longer necessary. -INCLUDING DEPENDENCY Bridge -INCLUDING DEPENDENCY DeepBook -INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING dependency @@ -75,9 +72,6 @@ Skipping dependency verification === publish package v0 (should warn about deprecation) === [Warning]: Dependency sources are no longer verified automatically during publication and upgrade, so the `--skip-dependency-verification` flag is no longer necessary. INCLUDING DEPENDENCY dependency -INCLUDING DEPENDENCY Bridge -INCLUDING DEPENDENCY DeepBook -INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING example @@ -85,9 +79,6 @@ Skipping dependency verification === upgrade package (should warn about deprecation) === [Warning]: Dependency sources are no longer verified automatically during publication and upgrade, so the `--skip-dependency-verification` flag is no longer necessary. INCLUDING DEPENDENCY dependency -INCLUDING DEPENDENCY Bridge -INCLUDING DEPENDENCY DeepBook -INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING example @@ -96,9 +87,6 @@ Skipping dependency verification === try to publish with modified dep (should succeed) === [Warning]: Dependency sources are no longer verified automatically during publication and upgrade, so the `--skip-dependency-verification` flag is no longer necessary. INCLUDING DEPENDENCY dependency -INCLUDING DEPENDENCY Bridge -INCLUDING DEPENDENCY DeepBook -INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING example @@ -106,9 +94,6 @@ Skipping dependency verification === try to upgrade with modified dep (should succeed) === [Warning]: Dependency sources are no longer verified automatically during publication and upgrade, so the `--skip-dependency-verification` flag is no longer necessary. INCLUDING DEPENDENCY dependency -INCLUDING DEPENDENCY Bridge -INCLUDING DEPENDENCY DeepBook -INCLUDING DEPENDENCY SuiSystem INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING example diff --git a/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__with_dep_verif.sh.snap b/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__with_dep_verif.sh.snap index 99298f46778d5..133331ffca651 100644 --- a/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__with_dep_verif.sh.snap +++ b/crates/sui/tests/snapshots/shell_tests__with_network__source_verification_deprecation__with_dep_verif.sh.snap @@ -71,20 +71,30 @@ Fix this by rebuilding your packages with source versions matching on-chain vers ----- stderr ----- === munge Move.toml files === === publish dependency === +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING dependency Successfully verified dependencies on-chain against source. === publish package v0 (should NOT warn) === INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example Successfully verified dependencies on-chain against source. === upgrade package (should NOT warn) === INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example Successfully verified dependencies on-chain against source. === modify dependency === === try to publish with modified dep (should fail) === INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example === try to upgrade with modified dep (should fail) === INCLUDING DEPENDENCY dependency +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib BUILDING example From 64506110bec365a1b07dcc396ddb901176672ecb Mon Sep 17 00:00:00 2001 From: Michael George Date: Mon, 24 Feb 2025 17:25:01 -0500 Subject: [PATCH 4/4] added tests that publish against devnet, mainnet, testnet and check implicit dependencies --- crates/sui-move-build/src/lib.rs | 4 +- crates/sui/src/client_commands.rs | 10 ++- .../data/module_dependency_invalid/Move.toml | 3 + .../module_dependency_nonexistent/Move.toml | 3 + .../module_dependency_unpublished/Move.toml | 3 + .../Move.toml | 3 + .../sui/tests/shell_tests/implicits/build.sh | 5 ++ .../tests/shell_tests/implicits/build_dev.sh | 5 ++ .../shell_tests/implicits/example/Move.toml | 6 ++ .../implicits/example/sources/example.move | 10 +++ .../sui/tests/shell_tests/implicits/test.sh | 5 ++ .../tests/shell_tests/implicits/test_dev.sh | 5 ++ .../shell_tests/new_tests/new_then_build.sh | 11 --- .../shell_tests/new_tests/new_then_test.sh | 1 - .../with_network/implicits/example/Move.toml | 6 ++ .../implicits/example/sources/example.move | 10 +++ .../implicits/pub_with_implicit_deps.sh | 18 +++++ .../new_tests/new_then_publish.sh | 31 ++++++++ .../shell_tests__implicits__build.sh.snap | 17 +++++ .../shell_tests__implicits__build_dev.sh.snap | 17 +++++ .../shell_tests__implicits__test.sh.snap | 25 ++++++ .../shell_tests__implicits__test_dev.sh.snap | 25 ++++++ ...l_tests__new_tests__new_then_build.sh.snap | 11 --- ...ll_tests__new_tests__new_then_test.sh.snap | 1 - ..._implicits__pub_with_implicit_deps.sh.snap | 59 ++++++++++++++ ...twork__new_tests__new_then_publish.sh.snap | 76 +++++++++++++++++++ .../tests/test_dependency_graph.rs | 2 +- 27 files changed, 341 insertions(+), 31 deletions(-) create mode 100644 crates/sui/tests/shell_tests/implicits/build.sh create mode 100644 crates/sui/tests/shell_tests/implicits/build_dev.sh create mode 100644 crates/sui/tests/shell_tests/implicits/example/Move.toml create mode 100644 crates/sui/tests/shell_tests/implicits/example/sources/example.move create mode 100644 crates/sui/tests/shell_tests/implicits/test.sh create mode 100644 crates/sui/tests/shell_tests/implicits/test_dev.sh create mode 100644 crates/sui/tests/shell_tests/with_network/implicits/example/Move.toml create mode 100644 crates/sui/tests/shell_tests/with_network/implicits/example/sources/example.move create mode 100644 crates/sui/tests/shell_tests/with_network/implicits/pub_with_implicit_deps.sh create mode 100644 crates/sui/tests/shell_tests/with_network/new_tests/new_then_publish.sh create mode 100644 crates/sui/tests/snapshots/shell_tests__implicits__build.sh.snap create mode 100644 crates/sui/tests/snapshots/shell_tests__implicits__build_dev.sh.snap create mode 100644 crates/sui/tests/snapshots/shell_tests__implicits__test.sh.snap create mode 100644 crates/sui/tests/snapshots/shell_tests__implicits__test_dev.sh.snap create mode 100644 crates/sui/tests/snapshots/shell_tests__with_network__implicits__pub_with_implicit_deps.sh.snap create mode 100644 crates/sui/tests/snapshots/shell_tests__with_network__new_tests__new_then_publish.sh.snap diff --git a/crates/sui-move-build/src/lib.rs b/crates/sui-move-build/src/lib.rs index 85e1ee03f3864..b00311dafd5f4 100644 --- a/crates/sui-move-build/src/lib.rs +++ b/crates/sui-move-build/src/lib.rs @@ -125,7 +125,7 @@ impl BuildConfig { install_dir: Some(install_dir), silence_warnings: true, lint_flag: move_package::LintFlag::LEVEL_NONE, - // TODO: in the future this should probably be changed to a set of local deps: + // TODO[DVX-793]: in the future, we may want to provide local implicit dependencies to tests implicit_dependencies: Dependencies::new(), ..MoveBuildConfig::default() }; @@ -304,7 +304,7 @@ pub fn build_from_resolution_graph( }) } -/// Returns the deps from `resolution_graph` that have no source code +/// Returns the bytecode deps from `resolution_graph` that have no source code fn collect_bytecode_deps( resolution_graph: &ResolvedGraph, ) -> SuiResult> { diff --git a/crates/sui/src/client_commands.rs b/crates/sui/src/client_commands.rs index 9df2282efa048..d4b62dba26e7e 100644 --- a/crates/sui/src/client_commands.rs +++ b/crates/sui/src/client_commands.rs @@ -1866,9 +1866,9 @@ pub(crate) async fn compile_package( skip_dependency_verification: bool, ) -> Result { let protocol_config = read_api.get_protocol_config(None).await?; - let protocol_version = protocol_config.protocol_version; - build_config.implicit_dependencies = implicit_deps_for_protocol_version(protocol_version)?; + build_config.implicit_dependencies = + implicit_deps_for_protocol_version(protocol_config.protocol_version)?; let config = resolve_lock_file_path(build_config, Some(package_path))?; let run_bytecode_verifier = true; let print_diags_to_stderr = true; @@ -2003,9 +2003,11 @@ pub(crate) async fn compile_package( fn implicit_deps_for_protocol_version(version: ProtocolVersion) -> anyhow::Result { if version > ProtocolVersion::MAX + 2 { eprintln!( - "[{}]: The network is using protocol version {:?}, which is newer than this binary; \ - the system packages used for compilation (e.g. MoveStdlib) may be out of date.", + "[{}]: The network is using protocol version {:?}, but this binary only recognizes protocol version {:?}; \ + the system packages used for compilation (e.g. MoveStdlib) may be out of date. If you have errors related to \ + system packages, you may need to update your CLI.", "warning".bold().yellow(), + ProtocolVersion::MAX, version ) } diff --git a/crates/sui/tests/data/module_dependency_invalid/Move.toml b/crates/sui/tests/data/module_dependency_invalid/Move.toml index c7d3a5b88cde4..85a21ed1f7a94 100644 --- a/crates/sui/tests/data/module_dependency_invalid/Move.toml +++ b/crates/sui/tests/data/module_dependency_invalid/Move.toml @@ -4,5 +4,8 @@ version = "0.0.1" published-at = "mystery" edition = "2024.beta" +[dependencies] +MoveStdlib = { local = "../../../../sui-framework/packages/move-stdlib" } + [addresses] invalid = "0x0" diff --git a/crates/sui/tests/data/module_dependency_nonexistent/Move.toml b/crates/sui/tests/data/module_dependency_nonexistent/Move.toml index f9d17992d48a5..1155f472374cd 100644 --- a/crates/sui/tests/data/module_dependency_nonexistent/Move.toml +++ b/crates/sui/tests/data/module_dependency_nonexistent/Move.toml @@ -4,5 +4,8 @@ version = "0.0.1" published-at = "0xabc123" edition = "2024.beta" +[dependencies] +MoveStdlib = { local = "../../../../sui-framework/packages/move-stdlib" } + [addresses] nonexistent = "0x0" diff --git a/crates/sui/tests/data/module_dependency_unpublished/Move.toml b/crates/sui/tests/data/module_dependency_unpublished/Move.toml index 9261cb1cb05f9..8160a0fea3009 100644 --- a/crates/sui/tests/data/module_dependency_unpublished/Move.toml +++ b/crates/sui/tests/data/module_dependency_unpublished/Move.toml @@ -5,5 +5,8 @@ edition = "2024.beta" # No published-at address for this package. # published-at = "0x0" +[dependencies] +MoveStdlib = { local = "../../../../sui-framework/packages/move-stdlib" } + [addresses] invalid = "0x0" diff --git a/crates/sui/tests/data/module_dependency_unpublished_non_zero_address/Move.toml b/crates/sui/tests/data/module_dependency_unpublished_non_zero_address/Move.toml index 4f23d8bbd2a7d..7ed9271e60bf4 100644 --- a/crates/sui/tests/data/module_dependency_unpublished_non_zero_address/Move.toml +++ b/crates/sui/tests/data/module_dependency_unpublished_non_zero_address/Move.toml @@ -5,6 +5,9 @@ edition = "2024.beta" # No published-at address for this package. # published-at = "0x0" +[dependencies] +MoveStdlib = { local = "../../../../sui-framework/packages/move-stdlib" } + [addresses] # Address not set to 0x0. Error if --with-unpublished-dependencies is set. non_zero = "0xbad" diff --git a/crates/sui/tests/shell_tests/implicits/build.sh b/crates/sui/tests/shell_tests/implicits/build.sh new file mode 100644 index 0000000000000..f0fa24d803417 --- /dev/null +++ b/crates/sui/tests/shell_tests/implicits/build.sh @@ -0,0 +1,5 @@ +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# tests that building a package that implicitly depends on `Bridge` can build +sui move build -p example 2> /dev/null diff --git a/crates/sui/tests/shell_tests/implicits/build_dev.sh b/crates/sui/tests/shell_tests/implicits/build_dev.sh new file mode 100644 index 0000000000000..a669e569e54c0 --- /dev/null +++ b/crates/sui/tests/shell_tests/implicits/build_dev.sh @@ -0,0 +1,5 @@ +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# tests that building a package that implicitly depends on `Bridge` works in dev mode +sui move build --dev -p example 2> /dev/null diff --git a/crates/sui/tests/shell_tests/implicits/example/Move.toml b/crates/sui/tests/shell_tests/implicits/example/Move.toml new file mode 100644 index 0000000000000..121ad307156b3 --- /dev/null +++ b/crates/sui/tests/shell_tests/implicits/example/Move.toml @@ -0,0 +1,6 @@ +[package] +name = "example" +edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move + +[addresses] +example = "0x0" diff --git a/crates/sui/tests/shell_tests/implicits/example/sources/example.move b/crates/sui/tests/shell_tests/implicits/example/sources/example.move new file mode 100644 index 0000000000000..c5c6ca83f870b --- /dev/null +++ b/crates/sui/tests/shell_tests/implicits/example/sources/example.move @@ -0,0 +1,10 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +module example::example; + +use bridge::bridge; + +public fun bridge_update_node_url(bridge: &mut bridge::Bridge, new_url: vector, ctx: &TxContext) { + bridge::update_node_url(bridge, new_url, ctx) +} diff --git a/crates/sui/tests/shell_tests/implicits/test.sh b/crates/sui/tests/shell_tests/implicits/test.sh new file mode 100644 index 0000000000000..e08e78514935d --- /dev/null +++ b/crates/sui/tests/shell_tests/implicits/test.sh @@ -0,0 +1,5 @@ +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# checks that testing a package that implicitly depends on `Bridge` works +sui move test -p example 2> /dev/null diff --git a/crates/sui/tests/shell_tests/implicits/test_dev.sh b/crates/sui/tests/shell_tests/implicits/test_dev.sh new file mode 100644 index 0000000000000..dea952ae0d095 --- /dev/null +++ b/crates/sui/tests/shell_tests/implicits/test_dev.sh @@ -0,0 +1,5 @@ +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# checks that testing a package with `--dev` that implicitly depends on `Bridge` works +sui move test -p example --dev 2> /dev/null diff --git a/crates/sui/tests/shell_tests/new_tests/new_then_build.sh b/crates/sui/tests/shell_tests/new_tests/new_then_build.sh index 26ef628b91151..7ade3741f587f 100644 --- a/crates/sui/tests/shell_tests/new_tests/new_then_build.sh +++ b/crates/sui/tests/shell_tests/new_tests/new_then_build.sh @@ -4,15 +4,4 @@ # tests that sui move new followed by sui move build succeeds sui move new example - -# we mangle the generated toml file to replace the framework dependency with a local dependency -FRAMEWORK_DIR=$(echo $CARGO_MANIFEST_DIR | sed 's#/crates/sui##g') -cat example/Move.toml \ - | sed 's#\(Sui = .*\)git = "[^"]*", \(.*\)#\1\2#' \ - | sed 's#\(Sui = .*\), rev = "[^"]*"\(.*\)#\1\2#' \ - | sed 's#\(Sui = .*\)subdir = "\([^"]*\)"\(.*\)#\1local = "FRAMEWORK/\2"\3#' \ - | sed "s#\(Sui = .*\)FRAMEWORK\(.*\)#\1$FRAMEWORK_DIR\2#" \ - > Move.toml -mv Move.toml example/Move.toml - cd example && sui move build diff --git a/crates/sui/tests/shell_tests/new_tests/new_then_test.sh b/crates/sui/tests/shell_tests/new_tests/new_then_test.sh index fe9ce4db7ff22..e247d83ed4f24 100644 --- a/crates/sui/tests/shell_tests/new_tests/new_then_test.sh +++ b/crates/sui/tests/shell_tests/new_tests/new_then_test.sh @@ -3,5 +3,4 @@ # check that sui move new followed by sui move test succeeds sui move new example - cd example && sui move test diff --git a/crates/sui/tests/shell_tests/with_network/implicits/example/Move.toml b/crates/sui/tests/shell_tests/with_network/implicits/example/Move.toml new file mode 100644 index 0000000000000..121ad307156b3 --- /dev/null +++ b/crates/sui/tests/shell_tests/with_network/implicits/example/Move.toml @@ -0,0 +1,6 @@ +[package] +name = "example" +edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move + +[addresses] +example = "0x0" diff --git a/crates/sui/tests/shell_tests/with_network/implicits/example/sources/example.move b/crates/sui/tests/shell_tests/with_network/implicits/example/sources/example.move new file mode 100644 index 0000000000000..c5c6ca83f870b --- /dev/null +++ b/crates/sui/tests/shell_tests/with_network/implicits/example/sources/example.move @@ -0,0 +1,10 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +module example::example; + +use bridge::bridge; + +public fun bridge_update_node_url(bridge: &mut bridge::Bridge, new_url: vector, ctx: &TxContext) { + bridge::update_node_url(bridge, new_url, ctx) +} diff --git a/crates/sui/tests/shell_tests/with_network/implicits/pub_with_implicit_deps.sh b/crates/sui/tests/shell_tests/with_network/implicits/pub_with_implicit_deps.sh new file mode 100644 index 0000000000000..18b68ef4af660 --- /dev/null +++ b/crates/sui/tests/shell_tests/with_network/implicits/pub_with_implicit_deps.sh @@ -0,0 +1,18 @@ +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# tests that publishing a package with an implicit dependency on `Bridge` succeeds + +echo "=== set up networks ===" | tee /dev/stderr +sui client --client.config $CONFIG new-env --alias devnet --rpc https://fullnode.devnet.sui.io:443 +sui client --client.config $CONFIG new-env --alias testnet --rpc https://fullnode.testnet.sui.io:443 +sui client --client.config $CONFIG new-env --alias mainnet --rpc https://fullnode.mainnet.sui.io:443 + +for i in localnet devnet testnet mainnet; do + echo "=== publish package ($i) ===" | tee /dev/stderr + sui client --client.config $CONFIG switch --env "$i" \ + 2> /dev/null + sui client --client.config $CONFIG publish "example" \ + --dry-run \ + --json 2> /dev/null | jq '.effects.status' +done diff --git a/crates/sui/tests/shell_tests/with_network/new_tests/new_then_publish.sh b/crates/sui/tests/shell_tests/with_network/new_tests/new_then_publish.sh new file mode 100644 index 0000000000000..f439f0fbbeca6 --- /dev/null +++ b/crates/sui/tests/shell_tests/with_network/new_tests/new_then_publish.sh @@ -0,0 +1,31 @@ +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# tests that sui move new followed by sui move publish succeeds on network defined by current branch + +sui move new example +echo "module example::example;" >> example/sources/example.move + +echo "=== publish package (localnet) ===" | tee /dev/stderr +sui client --client.config $CONFIG publish "example" \ + --json 2> /dev/null > output +cat output | jq '.effects.status' +UPGRADE_CAP=$(cat output | jq -r '.objectChanges[] | select(.objectType == "0x2::package::UpgradeCap") | .objectId') + +echo "=== upgrade package (localnet) ===" | tee /dev/stderr +sui client --client.config $CONFIG upgrade --upgrade-capability $UPGRADE_CAP example \ + --json 2> /dev/null | jq '.effects.status' + +echo "=== set up networks ===" | tee /dev/stderr +sui client --client.config $CONFIG new-env --alias devnet --rpc https://fullnode.devnet.sui.io:443 +sui client --client.config $CONFIG new-env --alias testnet --rpc https://fullnode.testnet.sui.io:443 +sui client --client.config $CONFIG new-env --alias mainnet --rpc https://fullnode.mainnet.sui.io:443 + +for i in devnet testnet mainnet; do + echo "=== publish package ($i) ===" | tee /dev/stderr + sui client --client.config $CONFIG switch --env "$i" \ + 2> /dev/null + sui client --client.config $CONFIG publish "example" \ + --dry-run \ + --json 2> /dev/null | jq '.effects.status' +done diff --git a/crates/sui/tests/snapshots/shell_tests__implicits__build.sh.snap b/crates/sui/tests/snapshots/shell_tests__implicits__build.sh.snap new file mode 100644 index 0000000000000..205f7b0688de9 --- /dev/null +++ b/crates/sui/tests/snapshots/shell_tests__implicits__build.sh.snap @@ -0,0 +1,17 @@ +--- +source: crates/sui/tests/shell_tests.rs +description: tests/shell_tests/implicits/build.sh +--- +----- script ----- +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# tests that building a package that implicitly depends on `Bridge` can build +sui move build -p example 2> /dev/null + +----- results ----- +success: true +exit_code: 0 +----- stdout ----- + +----- stderr ----- diff --git a/crates/sui/tests/snapshots/shell_tests__implicits__build_dev.sh.snap b/crates/sui/tests/snapshots/shell_tests__implicits__build_dev.sh.snap new file mode 100644 index 0000000000000..9a31f091d9b83 --- /dev/null +++ b/crates/sui/tests/snapshots/shell_tests__implicits__build_dev.sh.snap @@ -0,0 +1,17 @@ +--- +source: crates/sui/tests/shell_tests.rs +description: tests/shell_tests/implicits/build_dev.sh +--- +----- script ----- +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# tests that building a package that implicitly depends on `Bridge` works in dev mode +sui move build --dev -p example 2> /dev/null + +----- results ----- +success: true +exit_code: 0 +----- stdout ----- + +----- stderr ----- diff --git a/crates/sui/tests/snapshots/shell_tests__implicits__test.sh.snap b/crates/sui/tests/snapshots/shell_tests__implicits__test.sh.snap new file mode 100644 index 0000000000000..f57cc011553b5 --- /dev/null +++ b/crates/sui/tests/snapshots/shell_tests__implicits__test.sh.snap @@ -0,0 +1,25 @@ +--- +source: crates/sui/tests/shell_tests.rs +description: tests/shell_tests/implicits/test.sh +--- +----- script ----- +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# checks that testing a package that implicitly depends on `Bridge` works +sui move test -p example 2> /dev/null + +----- results ----- +success: true +exit_code: 0 +----- stdout ----- +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib +BUILDING example +Running Move unit tests +Test result: OK. Total tests: 0; passed: 0; failed: 0 + +----- stderr ----- diff --git a/crates/sui/tests/snapshots/shell_tests__implicits__test_dev.sh.snap b/crates/sui/tests/snapshots/shell_tests__implicits__test_dev.sh.snap new file mode 100644 index 0000000000000..2813995e03f9f --- /dev/null +++ b/crates/sui/tests/snapshots/shell_tests__implicits__test_dev.sh.snap @@ -0,0 +1,25 @@ +--- +source: crates/sui/tests/shell_tests.rs +description: tests/shell_tests/implicits/test_dev.sh +--- +----- script ----- +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# checks that testing a package with `--dev` that implicitly depends on `Bridge` works +sui move test -p example --dev 2> /dev/null + +----- results ----- +success: true +exit_code: 0 +----- stdout ----- +INCLUDING DEPENDENCY Bridge +INCLUDING DEPENDENCY DeepBook +INCLUDING DEPENDENCY SuiSystem +INCLUDING DEPENDENCY Sui +INCLUDING DEPENDENCY MoveStdlib +BUILDING example +Running Move unit tests +Test result: OK. Total tests: 0; passed: 0; failed: 0 + +----- stderr ----- diff --git a/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_build.sh.snap b/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_build.sh.snap index c0b6b1186e276..56234681aa994 100644 --- a/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_build.sh.snap +++ b/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_build.sh.snap @@ -9,17 +9,6 @@ description: tests/shell_tests/new_tests/new_then_build.sh # tests that sui move new followed by sui move build succeeds sui move new example - -# we mangle the generated toml file to replace the framework dependency with a local dependency -FRAMEWORK_DIR=$(echo $CARGO_MANIFEST_DIR | sed 's#/crates/sui##g') -cat example/Move.toml \ - | sed 's#\(Sui = .*\)git = "[^"]*", \(.*\)#\1\2#' \ - | sed 's#\(Sui = .*\), rev = "[^"]*"\(.*\)#\1\2#' \ - | sed 's#\(Sui = .*\)subdir = "\([^"]*\)"\(.*\)#\1local = "FRAMEWORK/\2"\3#' \ - | sed "s#\(Sui = .*\)FRAMEWORK\(.*\)#\1$FRAMEWORK_DIR\2#" \ - > Move.toml -mv Move.toml example/Move.toml - cd example && sui move build ----- results ----- diff --git a/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_test.sh.snap b/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_test.sh.snap index 38fc444f8515b..2af9fe1df8519 100644 --- a/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_test.sh.snap +++ b/crates/sui/tests/snapshots/shell_tests__new_tests__new_then_test.sh.snap @@ -8,7 +8,6 @@ description: tests/shell_tests/new_tests/new_then_test.sh # check that sui move new followed by sui move test succeeds sui move new example - cd example && sui move test ----- results ----- diff --git a/crates/sui/tests/snapshots/shell_tests__with_network__implicits__pub_with_implicit_deps.sh.snap b/crates/sui/tests/snapshots/shell_tests__with_network__implicits__pub_with_implicit_deps.sh.snap new file mode 100644 index 0000000000000..979ee9b181036 --- /dev/null +++ b/crates/sui/tests/snapshots/shell_tests__with_network__implicits__pub_with_implicit_deps.sh.snap @@ -0,0 +1,59 @@ +--- +source: crates/sui/tests/shell_tests.rs +description: tests/shell_tests/with_network/implicits/pub_with_implicit_deps.sh +--- +----- script ----- +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# tests that publishing a package with an implicit dependency on `Bridge` succeeds + +echo "=== set up networks ===" | tee /dev/stderr +sui client --client.config $CONFIG new-env --alias devnet --rpc https://fullnode.devnet.sui.io:443 +sui client --client.config $CONFIG new-env --alias testnet --rpc https://fullnode.testnet.sui.io:443 +sui client --client.config $CONFIG new-env --alias mainnet --rpc https://fullnode.mainnet.sui.io:443 + +for i in localnet devnet testnet mainnet; do + echo "=== publish package ($i) ===" | tee /dev/stderr + sui client --client.config $CONFIG switch --env "$i" \ + 2> /dev/null + sui client --client.config $CONFIG publish "example" \ + --dry-run \ + --json 2> /dev/null | jq '.effects.status' +done + +----- results ----- +success: true +exit_code: 0 +----- stdout ----- +=== set up networks === +Added new Sui env [devnet] to config. +Added new Sui env [testnet] to config. +Added new Sui env [mainnet] to config. +=== publish package (localnet) === +Active environment switched to [localnet] +{ + "status": "success" +} +=== publish package (devnet) === +Active environment switched to [devnet] +{ + "status": "success" +} +=== publish package (testnet) === +Active environment switched to [testnet] +{ + "status": "success" +} +=== publish package (mainnet) === +Active environment switched to [mainnet] +{ + "status": "success" +} + +----- stderr ----- +=== set up networks === +=== publish package (localnet) === +=== publish package (devnet) === +=== publish package (testnet) === +=== publish package (mainnet) === diff --git a/crates/sui/tests/snapshots/shell_tests__with_network__new_tests__new_then_publish.sh.snap b/crates/sui/tests/snapshots/shell_tests__with_network__new_tests__new_then_publish.sh.snap new file mode 100644 index 0000000000000..6b0377733fef3 --- /dev/null +++ b/crates/sui/tests/snapshots/shell_tests__with_network__new_tests__new_then_publish.sh.snap @@ -0,0 +1,76 @@ +--- +source: crates/sui/tests/shell_tests.rs +description: tests/shell_tests/with_network/new_tests/new_then_publish.sh +--- +----- script ----- +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# tests that sui move new followed by sui move publish succeeds on network defined by current branch + +sui move new example +echo "module example::example;" >> example/sources/example.move + +echo "=== publish package (localnet) ===" | tee /dev/stderr +sui client --client.config $CONFIG publish "example" \ + --json 2> /dev/null > output +cat output | jq '.effects.status' +UPGRADE_CAP=$(cat output | jq -r '.objectChanges[] | select(.objectType == "0x2::package::UpgradeCap") | .objectId') + +echo "=== upgrade package (localnet) ===" | tee /dev/stderr +sui client --client.config $CONFIG upgrade --upgrade-capability $UPGRADE_CAP example \ + --json 2> /dev/null | jq '.effects.status' + +echo "=== set up networks ===" | tee /dev/stderr +sui client --client.config $CONFIG new-env --alias devnet --rpc https://fullnode.devnet.sui.io:443 +sui client --client.config $CONFIG new-env --alias testnet --rpc https://fullnode.testnet.sui.io:443 +sui client --client.config $CONFIG new-env --alias mainnet --rpc https://fullnode.mainnet.sui.io:443 + +for i in devnet testnet mainnet; do + echo "=== publish package ($i) ===" | tee /dev/stderr + sui client --client.config $CONFIG switch --env "$i" \ + 2> /dev/null + sui client --client.config $CONFIG publish "example" \ + --dry-run \ + --json 2> /dev/null | jq '.effects.status' +done + +----- results ----- +success: true +exit_code: 0 +----- stdout ----- +=== publish package (localnet) === +{ + "status": "success" +} +=== upgrade package (localnet) === +{ + "status": "success" +} +=== set up networks === +Added new Sui env [devnet] to config. +Added new Sui env [testnet] to config. +Added new Sui env [mainnet] to config. +=== publish package (devnet) === +Active environment switched to [devnet] +{ + "status": "success" +} +=== publish package (testnet) === +Active environment switched to [testnet] +{ + "status": "success" +} +=== publish package (mainnet) === +Active environment switched to [mainnet] +{ + "status": "success" +} + +----- stderr ----- +=== publish package (localnet) === +=== upgrade package (localnet) === +=== set up networks === +=== publish package (devnet) === +=== publish package (testnet) === +=== publish package (mainnet) === diff --git a/external-crates/move/crates/move-package/tests/test_dependency_graph.rs b/external-crates/move/crates/move-package/tests/test_dependency_graph.rs index 1363bd493fc1b..38c8e1a33dece 100644 --- a/external-crates/move/crates/move-package/tests/test_dependency_graph.rs +++ b/external-crates/move/crates/move-package/tests/test_dependency_graph.rs @@ -43,7 +43,7 @@ fn no_dep_graph() { /* skip_fetch_latest_git_deps */ true, std::io::sink(), tempfile::tempdir().unwrap().path().to_path_buf(), - /* implicit deps */ Dependencies::default(), + Dependencies::default(), /* implicit deps */ ); let (graph, _) = dep_graph_builder .get_graph(