-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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][cli] Support safe module republishing with breaking changes ch… #6753
Conversation
Can't add @mengxu-fb as a reviewer for some reason, but definitely want your opinion! |
language/tools/move-cli/src/main.rs
Outdated
let deps = self.get_compilation_deps()?; | ||
let to_compile_filenames = move_lang::find_move_filenames(to_compile, true)?; | ||
// convert /path/to/File.move to File.move | ||
let file_names: Vec<&str> = to_compile_filenames.iter().map(|s| get_stem(s)).flatten().collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe using a Set
here instead of a Vec
?
language/tools/move-cli/src/main.rs
Outdated
// exclude any filenames in `deps` that do not match File.move | ||
// Note: this is best-effort in at least two ways: | ||
// (1) It will wrongly filter modules in the same name under different addresses (e.g., 0x1/M.move and 0x2/M.move) | ||
// (2) It will fail to filter modules with the same filename, but different module names (e.g., 0x1/M in both M1.move and M2.move) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(3) It may cause modules to be lost? (e.g., 0x1/M and 0x1/N in the deps' M.move
but only 0x1/M in the updated M.move
(although I guess this should not be an issue for stdlib modules).
Thanks Sam for pinning me here. The changes LGTM, and I'll leave it to others to stamp it :) I think given what the CLI has, the file exclusion can only be best-effort and never perfect. I wish we had compiler-side change to support module updates directly, say, in, |
6dcf2c9
to
a1c75d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just a couple small things
language/tools/move-cli/src/main.rs
Outdated
@@ -91,6 +93,11 @@ enum Command { | |||
/// If set, modules will not override existing ones in storage | |||
#[structopt(long = "no-republish")] | |||
no_republish: bool, | |||
/// By default, code that might cause breaking changes for bytecode | |||
/// linking or data layout compatibility checks will not be published. | |||
/// Set this flag to ignore breakng changes checks and publish anyway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
/// Set this flag to ignore breakng changes checks and publish anyway | |
/// Set this flag to ignore breaking changes checks and publish anyway |
language/tools/move-cli/src/main.rs
Outdated
let new_api = Module::new(m); | ||
let compat = Compatibility::check(&old_api, &new_api); | ||
if !compat.is_fully_compatible() { | ||
println!("Breaking change detected--publishing aborted. Re-run with --ignore-breaking-changes to publish anyway.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly a larger question for the CLI as well, but I'm thinking this should probably be an eprintln!
instead since this is a warning/error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good call. I'll do that for now, and in the future I'd like to get rid of all print
's and turn them into writes to a buffer. I think we need to do this in order to run CLI tests concurrently in the same process.
a1c75d0
to
49119d5
Compare
/land |
…ecks - If the CLI is trying to compile `M.move`, the logic for finding compilation deps now removes `M.move` from the deps list. More generally, any files directly or transitively reachable from the compilation targets are removed from the deps list. This fixes the annoying "duplicate definition" warning that you used to get when trying to re-publish a module - Before a `move publish`, the CLI runs the bytecode linking and data layout compatibility checks and reports an error if the code to be published could cause a breaking change to either linking or data layout - Added tests for republishing, running `move check M.move` after publishing `M.move`, and the breaking changes checks Closes: #6753
Cluster Test Result
❗ Cluster Test failed - non-zero exit code for Repro cmd:
|
💔 Test Failed - Build images and run cluster test |
/land |
/land |
@sblackshear 💡 This PR is already queued for landing |
This command does a bunch of sanity checks to ensure that the storage directory is well-formed. For now: - All modules verify - All modules link - All resources deserialize w.r.t the current version of their declaring module It does this in the obvious way: iterating through the global storage, collecting each module/resource, and doing the check. This is useful for detecting breaking changes (both code and data layout) after-the-fact, as well as bugs in the CLI. I was motivated to create this check when I noticed a bug where `move publish` sometimes publishes a module `M` without publishing library modules. If you run `move doctor` on such a state, it would catch the issue. I am planning to add `move doctor` to a bunch of the publish tests once I fix this bug. It will also be useful for testing the `--ignore-breaking-changes` flag in diem#6753.
This command does a bunch of sanity checks to ensure that the storage directory is well-formed. For now: - All modules verify - All modules link - All resources deserialize w.r.t the current version of their declaring module It does this in the obvious way: iterating through the global storage, collecting each module/resource, and doing the check. This is useful for detecting breaking changes (both code and data layout) after-the-fact, as well as bugs in the CLI. I was motivated to create this check when I noticed a bug where `move publish` sometimes publishes a module `M` without publishing library modules. If you run `move doctor` on such a state, it would catch the issue. I am planning to add `move doctor` to a bunch of the publish tests once I fix this bug. It will also be useful for testing the `--ignore-breaking-changes` flag in diem#6753.
…ecks
M.move
, the logic for finding compilation deps now removesM.move
from the deps list.More generally, any files directly or transitively reachable from the compilation targets are removed from the deps list. This
fixes the annoying "duplicate definition" warning that you used to get when trying to re-publish a module
move publish
, the CLI runs the bytecode linking and data layout compatibility checks and reports an error if thecode to be published could cause a breaking change to either linking or data layout
move check M.move
after publishingM.move
, and the breaking changes checks