-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[sui-mode][move-compiler] Greatly improve shared_owned lint accuracy #19330
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Skipped Deployments
|
// utils | ||
//************************************************************************************************** | ||
|
||
pub fn calls_special_function(special: &[(&str, &str, &str)], cfg: &ImmForwardCFG) -> bool { |
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.
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 |
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.
Is there an .exp file missing for this one?
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.
No, they are negative cases so they do not trigger the lint
@@ -95,11 +110,14 @@ impl SimpleAbsIntConstructor for ShareOwnedVerifier { | |||
{ | |||
return None; | |||
} | |||
Some(ShareOwnedVerifierAI) | |||
if !calls_special_function(SHARE_FUNCTIONS, cfg) { |
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.
Is this an optimization or it actually helps with accuracy?
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.
Optimization
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.
I wonder if it's worth an entirely separate visit and visitor modifications, but certainly a non-blocking issue for me
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
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)) |
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.
Would it be better to do this filtering step when building uid_holders
, disregarding phantom types when building it?
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.
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 { |
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.
Can args[0]
here ever panic?
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.
Not at this point, but maybe above. I'll change
else { | ||
return; | ||
}; | ||
let Some(transferred_kind) = self.sui_info().transferred.get(&tn).copied() else { |
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.
Is the copy here necessary, or can we get away with a borrow?
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.
I'll immediately copy it below, but doing so brings it inline with the other Loc usages here, so I'll do that, thanks!
…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:
Description
Test plan
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.