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 lock: derive toolchain edition and flavor from manifest #16885

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

rvantonder
Copy link
Contributor

@rvantonder rvantonder commented Mar 26, 2024

Description

Ensures toolchain versioning records edition/flavor derived from Move.toml when available. This was not the case before, because I was under the impression that BuildConfig reflects the current edition (source and comment) but this is not the case: compiler_config is really the function that merges both BuildConfig flags (specified on the command line) and Move.toml with edition. The result of that computation (PackageConfig) is also discarded after compilation / resolution graph uses. So, for simplicity, and without needing to rely on the resolution graph computed value, this PR updates toolchain versioning to record edition in a similar way to compiler_config: by parsing the manifest and merging extracted values.

Test Plan

Updated test(s).


If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section.

Type of Change (Check all that apply)

  • protocol change
  • user-visible impact
  • breaking change for a client SDKs
  • breaking change for FNs (FN binary must upgrade)
  • breaking change for validators or node operators (must upgrade binaries)
  • breaking change for on-chain data layout
  • necessitate either a data wipe or data migration

Release notes

  • The Move.lock will be populated with the edition corresponding to that in the Move.toml, if it exists.
  • The Move.lock will be generated and populated with toolchain versioning information on sui client publish.

Copy link

vercel bot commented Mar 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 1, 2024 10:26pm
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 1, 2024 10:26pm
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Apr 1, 2024 10:26pm
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Apr 1, 2024 10:26pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Apr 1, 2024 10:26pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Apr 1, 2024 10:26pm

@rvantonder rvantonder closed this Mar 27, 2024
@rvantonder rvantonder reopened this Mar 27, 2024
Comment on lines +339 to +357
let path = &SourcePackageLayout::try_find_root(path)
.map_err(|e| anyhow!("Unable to find package root for {}: {e}", path.display()))?;

// Resolve edition and flavor from `Move.toml` or assign defaults.
let manifest_string =
std::fs::read_to_string(path.join(SourcePackageLayout::Manifest.path()))?;
let toml_manifest = parse_move_manifest_string(manifest_string.clone())?;
let root_manifest = parse_source_manifest(toml_manifest)?;
let edition = root_manifest
.package
.edition
.or(self.default_edition)
.unwrap_or_default();
let flavor = root_manifest
.package
.flavor
.or(self.default_flavor)
.unwrap_or_default();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

main change: look at Move.toml for edition / flavor values.

Comment on lines -166 to -177
);
if let Ok(ref compiled) = result {
compiled
.package
.compiled_package_info
.build_flags
.update_lock_file_toolchain_version(&path, env!("CARGO_PKG_VERSION").into())
.map_err(|e| SuiError::ModuleBuildFailure {
error: format!("Failed to update Move.lock toolchain version: {e}"),
})?;
}
result
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also updated in this PR: the toolchain update is lifted into sui-move/src/build.rs and sui/src/client_commands respectively. This ensures that Move.lock is updated for a sui client publish command even when sui move build has never been called before (indeed, this build function doesn't get called on sui client publish).

@rvantonder rvantonder requested review from amnn and a team March 27, 2024 02:36
@rvantonder rvantonder changed the title move lock: derive toolchain edition from manifest move lock: derive toolchain edition, flavor from manifest Mar 27, 2024
@rvantonder rvantonder changed the title move lock: derive toolchain edition, flavor from manifest move lock: derive toolchain edition and flavor from manifest Mar 27, 2024
Copy link
Member

@amnn amnn left a comment

Choose a reason for hiding this comment

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

The change seems reasonable, but got me thinking about the recursive case E.g. package A depends on package B, and:

  1. A specifies a toolchain in its manifest (different from the default).
  2. B specifies a toolchain in its manifest (different from the default).
  3. Both A and B specify different toolchains.

I would expect that in case 1, B should be built with the default toolchain, and in case 2 and 3 it should always be built with the toolchain version that it specifies in its own manifest, regardless of how A is configured.

Earlier we were talking about a model where everything except the builds could recover the information they needed about a package just from its lock file. But IIUC, when we build B as part of A's build, we don't modify B's lock file, so we won't be able to use A's lock file alone to understand what toolchains were used in its build. Is that a problem?

@rvantonder rvantonder requested a review from amnn March 28, 2024 17:45
@rvantonder
Copy link
Contributor Author

Addressed offline--this PR doesn't focus on a recursive lock file model, it is something to revisit later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants