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] Fix toml issues with move-execution #17130

Merged
merged 20 commits into from
Apr 16, 2024
Merged

Conversation

tnowacki
Copy link
Contributor

Description

  • The move execution crates were not included in the external-crates/move/Cargo.toml, leading to all sorts of issues

Test plan

  • CI

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

@tnowacki tnowacki requested a review from a team April 11, 2024 22:31
@tnowacki tnowacki requested a review from ronny-mysten as a code owner April 11, 2024 22:31
Copy link

vercel bot commented Apr 11, 2024

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

Name Status Preview Comments Updated (UTC)
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 16, 2024 8:47pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Apr 16, 2024 8:47pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Apr 16, 2024 8:47pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Apr 16, 2024 8:47pm

@tnowacki
Copy link
Contributor Author

@amnn or @dariorussi, do you know if I need to update any scripts for execution cuts to reflect these changes in the future? (though we will need to fix the issues with the stdlib before changing any such scripts)

Copy link
Contributor

@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.

Amazing, thanks for tackling this. I've left comments on how to align this with how the cut script automates this process, so that future cuts all get tests and are included in the workspace.

Cargo.toml Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming/hoping this was done because you flattened v0 as well to make it easier to make other fixes (rather than it having always been broken), because this should be covered by tests...

@@ -155,6 +158,23 @@ move-vm-test-utils = { path = "crates/move-vm-test-utils" }
move-vm-types = { path = "crates/move-vm-types" }
prover_bytecode = { path = "crates/move-stackless-bytecode", package="move-stackless-bytecode" }

# v0
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't want to make these workspace deps. Instead, we should follow the pattern that we use for other versioned crates, which is to update the toml files of the packages that depend on them to refer to them at their versioned path, but their unversioned name.

The reason for this is that it's much easier to automate (the script doesn't need to look at rust source files and find all references to the latest version and rename that to the versioned form).

See for example:

move-bytecode-verifier = { path = "../move-bytecode-verifier", package = "move-bytecode-verifier-v1" }

Comment on lines 6 to 8
"move-execution/v0/crates/*",
"move-execution/v1/crates/*",
"move-execution/v2/crates/*",
Copy link
Contributor

Choose a reason for hiding this comment

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

Automating this is going to be ...tricky. The cut tool figures out which packages should be included or excluded from the root workspace here:

fn update_workspace(&self) -> Result<()> {

But it doesn't currently understand how to handle multiple workspaces, ...or glob patterns. One thing you could do is piggyback off the logic we have in the wrapper script, that updates TOML files when a new cut is introduced, here:

def update_toml(feature, toml_path):

This looks for comments in TOML files that contain "$CUT" and adds a line above them with "$CUT" replaced with the cut name, see e.g.

sui-adapter-latest = { path = "latest/sui-adapter" }
sui-adapter-v0 = { path = "v0/sui-adapter" }
sui-adapter-v1 = { path = "v1/sui-adapter" }
sui-adapter-v2 = { path = "v2/sui-adapter" }
# sui-adapter-$CUT = { path = "$CUT/sui-adapter" }
sui-move-natives-latest = { path = "latest/sui-move-natives" }
sui-move-natives-v0 = { path = "v0/sui-move-natives" }
sui-move-natives-v1 = { path = "v1/sui-move-natives" }
sui-move-natives-v2 = { path = "v2/sui-move-natives" }
# sui-move-natives-$CUT = { path = "$CUT/sui-move-natives" }
sui-verifier-latest = { path = "latest/sui-verifier" }
sui-verifier-v0 = { path = "v0/sui-verifier" }
sui-verifier-v1 = { path = "v1/sui-verifier" }
sui-verifier-v2 = { path = "v2/sui-verifier" }
# sui-verifier-$CUT = { path = "$CUT/sui-verifier" }

This is maybe a little more brittle, but I think it's the fastest way to get unblocked without losing the automation support.

Copy link
Contributor

Choose a reason for hiding this comment

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

Two comments here: I'm guessing that this crate is not included in the list of crates to cut right now, here:

def cut_command(f):
"""Arguments for creating the cut for 'feature'."""
return [
*["./target/debug/cut", "--feature", f],
*["-d", f"sui-execution/latest:sui-execution/{f}:-latest"],
*["-d", f"external-crates/move:external-crates/move/move-execution/{f}"],
*["-p", "sui-adapter-latest"],
*["-p", "sui-move-natives-latest"],
*["-p", "sui-verifier-latest"],
*["-p", "move-bytecode-verifier"],
*["-p", "move-stdlib"],
*["-p", "move-vm-runtime"],
]

But we should do that to make sure all future cuts get this crate and it's properly fixed up (Adding a new -p flag with the crate name should suffice).

Also as per the earlier comment about its dependencies, this is where we would need to change the move-bytecode-verifier dependency from a workspae dependency to a path dependency with a customised package name (see my earlier comment on the workspace Cargo.toml).

Copy link
Contributor

Choose a reason for hiding this comment

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

...and then all the source files can be left alone.

@tnowacki
Copy link
Contributor Author

@amnn thanks for all the guidance!
I think I have addressed the concerns, but am not entirely convinced I did it correctly.

Copy link
Contributor

@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.

LGTM! Note the comment about workspace deps -- they are fine to be there, but if you needed to add them, then that's a worrying sign (probably something is set up incorrectly, bypassing versioning), so it's probably best to remove them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it just luck of the draw that this is considered a file addition instead of a copy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to do git mv with then restoring the previous file. This was the result :(

Not sure if there is anything else to do

Copy link
Contributor

Choose a reason for hiding this comment

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

In this file, the changes to members is correct, but I don't think you should need the changes to workspace dependencies -- generally, if a crate is versioned in that way, we other crates should depend on it by path, or through some multiplexing crate (which we don't have within the Move workspace, but for sui it's the sui-execution crate).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to remove them at one point, but it did not work. Let me try again now that things are all good across the board

Copy link
Contributor

Choose a reason for hiding this comment

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

I can take a look tomorrow as well, thanks for these fixes!

Copy link
Contributor

Choose a reason for hiding this comment

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

(...never mind, I see it's fixed! Sorry, got confused by Github)

@tnowacki tnowacki enabled auto-merge (squash) April 16, 2024 20:46
@tnowacki tnowacki merged commit 1578af2 into MystenLabs:main Apr 16, 2024
43 of 44 checks passed
@tnowacki tnowacki deleted the fixtests branch April 16, 2024 21:50
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