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

Disable --test flag when publishing package using Sui client #13786

Merged
merged 3 commits into from
Sep 18, 2023

Conversation

rockbmb
Copy link
Contributor

@rockbmb rockbmb commented Sep 14, 2023

Description

This PR disables the use of the --test flag when executing sui client publish.
It closes #13679, following discussion in that thread.

Test Plan

I've added a test to ./crates/sui/tests/cli_tests.rs that verifies the --test flag will no longer be accepted with client publish, along with an error message explaining why.


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 Sui CLI now returns a new error message if you try to compile and publish a package in test mode using the sui client publish --test command.

@vercel
Copy link

vercel bot commented Sep 14, 2023

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 Sep 16, 2023 0:02am
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 16, 2023 0:02am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Sep 16, 2023 0:02am
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Sep 16, 2023 0:02am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Sep 16, 2023 0:02am

@rockbmb
Copy link
Contributor Author

rockbmb commented Sep 14, 2023

@tzakian Hey, two questions

  1. I can't add you as a reviewer, could you kindly do so for me, please?
  2. Regarding the Release notes section of the PR description I have to fill out, is there anything in particular I should write?

Thanks!

@tzakian
Copy link
Contributor

tzakian commented Sep 14, 2023

Thank you for the PR @rockbmb! I will take a look at this and may add some other reviewers as well :)

In terms of release notes just describing what this prevents is good enough (and will get picked up). E.g., "Added error to Sui CLI when trying to publish a package compiled in test mode"

@@ -732,6 +732,17 @@ impl SuiClientCommands {
serialize_signed_transaction,
lint,
} => {
if build_config.test_mode {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While the solution presented in this PR works, a user running sui client publish --help will still see --test in the list of available flags.

In order to remove this entirely, I can see two solutions:

  1. BuildConfig is duplicated into a struct without a test_mode field, and used here
  2. The test_mode flag is extracted into a different structure BuildConfigNoTest that two fields: it, and athe original BuildConfig

Both feel like overengineering, so I chose this approach instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense to me as well -- agreed that the other options feel a bit like overengineering as well.

Copy link
Contributor

@tzakian tzakian left a comment

Choose a reason for hiding this comment

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

Thanks for the PR (and thank you for the additional test too!).

Only minor nit is on the exact wording of the error message and removing the example, but otherwise this looks great to me! Once that's fixed I think this can go in.

@@ -732,6 +732,17 @@ impl SuiClientCommands {
serialize_signed_transaction,
lint,
} => {
if build_config.test_mode {
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense to me as well -- agreed that the other options feel a bit like overengineering as well.

return Err(SuiError::ModulePublishFailure {
error: "The `publish` subcommand should not be used with the `--test` flag\n\
\n\
Library code in published packages must not depend on test code.\n\
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
Library code in published packages must not depend on test code.\n\
Code in published packages must not depend on test code.\n\

Comment on lines 740 to 741
In order to fix this and publish the package without `--test`, search for, and remove \
instances of e.g. test modules declared as `friend`s of modules from `sources/`.".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I would most likely rephrase the last part of this a bit as the way tests can be defined (and how modules could depend on other test-only code) can differ, e.g., you can have test-only modules under sources/, and even though this is an example at the end I worry it may put blinders on folks and how they look at fixing this issue.

What do you think of maybe something like:

In order to fix this and publish the package without `--test` remove any non-test dependencies on test-only code. You can ensure all test-only dependencies have been removed by compiling the package normally with `sui move build`. 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me.

Copy link
Contributor

@tzakian tzakian left a comment

Choose a reason for hiding this comment

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

This looks good to me. Thank you for the fix, and following up with the changes!

@tzakian tzakian merged commit 0041229 into MystenLabs:main Sep 18, 2023
36 checks passed
@rockbmb rockbmb deleted the sui-client-publish-test-flag branch September 18, 2023 21:24
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.

Error when publishing packages via sui client publish --test
2 participants