Skip to content

Conversation

tnowacki
Copy link
Contributor

Description

  • The share_owned lint now uses type information to try to determine if an object is "fresh"
    • It assumes an object is fresh if it it comes from a function with not reachable UID inputs. Since in that case, the object could wrapped or coming from a dynamic field
  • Improved filtering to skip this analysis in some cases

Test plan

  • New tests

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:
  • REST API:

@tnowacki tnowacki requested a review from a team September 11, 2024 23:22
Copy link

vercel bot commented Sep 11, 2024

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

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 12, 2024 9:45pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 9:45pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 9:45pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 9:45pm

// utils
//**************************************************************************************************

pub fn calls_special_function(special: &[(&str, &str, &str)], cfg: &ImmForwardCFG) -> bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These will be generalized a bit in the next PR

@@ -0,0 +1,106 @@
// object is re shared, but it is never transferred and doesn't have public transfer
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an .exp file missing for this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, they are negative cases so they do not trigger the lint

return None;
}
Some(ShareOwnedVerifierAI)
if !calls_special_function(SHARE_FUNCTIONS, cfg) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an optimization or it actually helps with accuracy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Optimization

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it's worth an entirely separate visit and visitor modifications, but certainly a non-blocking issue for me

@awelc awelc self-requested a review September 12, 2024 18:29
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.

LGTM

Comment on lines +258 to +266
if self.sui_info().uid_holders.contains_key(&(m, n)) {
return true;
}
let phantom_positions = phantom_positions(self.info, &m, &n);
phantom_positions
.into_iter()
.zip(targs)
.filter(|(is_phantom, _)| !*is_phantom)
.any(|(_, t)| self.can_hold_obj_base(t))
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 be better to do this filtering step when building uid_holders, disregarding phantom types when building it?

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 can't really since I need to do this per-type instantiation.

f: &ModuleCall,
args: Vec<Value>,
) {
let Value::NotFreshObj(not_fresh_loc) = &args[0] else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can args[0] here ever panic?

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 at this point, but maybe above. I'll change

else {
return;
};
let Some(transferred_kind) = self.sui_info().transferred.get(&tn).copied() else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the copy here necessary, or can we get away with a borrow?

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'll immediately copy it below, but doing so brings it inline with the other Loc usages here, so I'll do that, thanks!

@tnowacki tnowacki enabled auto-merge (squash) September 12, 2024 21:44
@tnowacki tnowacki merged commit 8656e4a into MystenLabs:main Sep 12, 2024
44 checks passed
suiwombat pushed a commit that referenced this pull request Sep 16, 2024
…19330)

## Description 

- The share_owned lint now uses type information to try to determine if
an object is "fresh"
- It assumes an object is fresh if it it comes from a function with not
reachable UID inputs. Since in that case, the object could wrapped or
coming from a dynamic field
- Improved filtering to skip this analysis in some cases 

## Test plan 

- New tests 

---

## 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:
- [ ] REST API:
valeriyr added a commit to iotaledger/iota that referenced this pull request Feb 3, 2025
[sui-mode][move-compiler] Greatly improve shared_owned lint accuracy #19330
MystenLabs/sui#19330
valeriyr added a commit to iotaledger/iota that referenced this pull request Feb 14, 2025
…sion (#4559)

* mainnet-v1.39.4 external-crates

* fix: license headers

* fix(move-trace-format): updated authors

* fix(move-analyzer): several fixes for SVCode extension after update

* fix: fix workspace build after the external crates updating

* feat: create the protocol version `3`

* fix(external-crates): reverted `Identifier` serialization

* fix(iota-e2e-tests): fix the `basic_read_cmd_snapshot_tests` test

* fix: added missed changed from the upstream PR #17991

[move][test_scenario] Fix bug in test_scenario where we weren't returning allocated tickets (#17991)
MystenLabs/sui#17991

* fix: added missed changed from the upstream PR #19330

[sui-mode][move-compiler] Greatly improve shared_owned lint accuracy #19330
MystenLabs/sui#19330

* fix: added missed changed from the upstream PR 16523

move toolchain: fix multiple issues with bytecode dependencies
MystenLabs/sui#16523

* cargo fmt

* fix(move-analyzer): the extension tests were fixed

* fix(iota-framework): compiled packages update

* fix(iota-framework-snapshots): snapshots update

* fix: test snapshots

* fix: clippy

* fix(move-analyzer): the extension tests fix

* fix(external-crates): tests baseline

* fix(move-analyzer): the `completion` test is ignored

* fix(move-analyzer): bump the vscode extension version to 1.1.0

* feat: bump iota to v0.10.0-alpha

* fix(iota): shell tests after update

* fix(iota-json-rpc-tests): fixed the `get_committee_info` test

* fix(iota-adapter-transactional-tests): `large_enum_v2` -> `large_enum_v3`

* fix(iota-types): remove the `test-utils` feature

* fix: added `move-trace-format` to `external-crates-filters.yml`

* fix(iota-protocol-config): the version `4` history message

* fix(docs): update the Rust examples `Cargo.lock` file

* fix(external-crates): the `packages.md` file formatting

* fix(iota-move-build): removed extra assert from the `development_mode_not_allowed` test
@tnowacki tnowacki deleted the shared branch October 10, 2025 16:44
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