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-compiler][sui-mode] Add init and one-time witness rules #13335

Merged
merged 5 commits into from
Aug 18, 2023

Conversation

tnowacki
Copy link
Contributor

@tnowacki tnowacki commented Aug 9, 2023

Description

  • Added init and one-time witness rules to the compiler's Sui mode

Test Plan

  • Migrated tests

If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.

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

In this release, the Move compiler will now error on incorrect declarations (or usage) of init functions and one-time witnesses.

@vercel
Copy link

vercel bot commented Aug 9, 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 Aug 18, 2023 7:02pm
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 18, 2023 7:02pm
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Aug 18, 2023 7:02pm
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Aug 18, 2023 7:02pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Aug 18, 2023 7:02pm
sui-wallet-kit ⬜️ Ignored (Inspect) Visit Preview Aug 18, 2023 7:02pm

Copy link
Contributor

@awelc awelc left a comment

Choose a reason for hiding this comment

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

A couple nits but otherwise LGTM!

@@ -0,0 +1,12 @@
warning[W09004]: unnecessary trailing semicolon
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit. Since we seem to be testing bool field here, is the trailing semi warning really necessary here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missed this, thanks!


// Find the first invalid field in a one-time witness type, if any.
// First looks for a non-boolean field, otherwise looks for any field after the first.
fn invalid_otw_field_loc(fields: &Fields<Type>) -> Option<Loc> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit. It took me a bit to parse it for correctness (which I think it is, and I am just slow...) but it probably wouldn't hurt adding a multi-field test.

@vercel vercel bot temporarily deployed to Preview – mysten-ui August 18, 2023 19:02 Inactive
true
};
if valid_fields {
let name = mdef.structs.get_full_key_(&self.upper_module()).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to factor out this specific operation into a function or otherwise signpost that this is the way we find our OTW?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I follow. What is it you want to break out into a separate function?

@tnowacki
Copy link
Contributor Author

@cgswords, I'm going to land this since it is a rather large refactor.
Please ping me or make a follow up PR if you think anything can be refactored to be made more clear :) I'm often really bad at gauging that since I wrote like all of the code involved for the compiler, so it all makes sense to me lol

@tnowacki tnowacki merged commit 77a9e0d into MystenLabs:main Aug 18, 2023
@tnowacki tnowacki deleted the sm-typing-2 branch August 18, 2023 20:39
damirka pushed a commit that referenced this pull request Aug 22, 2023
## Description 

- Added init and one-time witness rules to the compiler's Sui mode

## Test Plan 

- Migrated tests

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [X] 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

In this release, the Move compiler will now error on incorrect
declarations (or usage) of `init` functions and one-time witnesses.
damirka pushed a commit that referenced this pull request Aug 23, 2023
## Description 

- Added init and one-time witness rules to the compiler's Sui mode

## Test Plan 

- Migrated tests

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [X] 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

In this release, the Move compiler will now error on incorrect
declarations (or usage) of `init` functions and one-time witnesses.
randall-Mysten pushed a commit that referenced this pull request Sep 6, 2023
## Description 

- Added init and one-time witness rules to the compiler's Sui mode

## Test Plan 

- Migrated tests

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [X] 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

In this release, the Move compiler will now error on incorrect
declarations (or usage) of `init` functions and one-time witnesses.
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.

3 participants