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

[sui framework] eliminate polymorphic delete in Transfer::delete_chil… #2179

Merged
merged 1 commit into from
May 24, 2022

Conversation

sblackshear
Copy link
Collaborator

…d_object

  • Get rid of Transfer::delete_child_object_internal, which allowed deletion of a Move object without the drop ability (bad)
  • Adjust Transfer::delete_child_object to take the VersionedID of the child object rather than the object itself. This allows a Move programmer to delete a child object and ChildRef in the same transaction, but without exposing a polymorphic delete.
  • Refactored test of this function. This was the only call site
  • Changed the dynamic checks for dangling reference detection in the adapter. This is the biggest change here--please review carefully. The dynamic check previously complained if a child was deleted in the same tx as its parent, but that is too strict for the new implementation of Transfer::delete_child_object.

Copy link
Contributor

@lxfind lxfind 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 taking care of this!

Comment on lines 469 to 472
Some((Owner::ObjectOwner(parent_id), _)) => {
parents_to_delete.insert(parent_id);
state_view.delete_object(obj_id, id.version(), DeleteKind::Normal)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not quite follow this change. The reason it was implemented this way is because of line 494 where DeleteChildObject is handled separately (which signals that a child object is deleted together with a child ref, hence it's safe). Not sure if you could achieve the same without it.
I think you could make the ID::delete call a separate internal call to distinguish the case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ahh I see how the old scheme worked now. Your suggested fix makes sense.

@sblackshear sblackshear force-pushed the fix_polymorphic_delete branch 2 times, most recently from a9504fe to ad029d5 Compare May 24, 2022 06:49
…d_object

- Get rid of `Transfer::delete_child_object_internal`, which allowed deletion of a Move object without the `drop` ability (bad)
- Adjust `Transfer::delete_child_object` to take the `VersionedID` of the child object rather than the object itself. This allows a Move programmer to delete a child object and `ChildRef` in the same transaction, but without exposing a polymorphic delete.
- Refactored test of this function. This was the only call site
- Changed the dynamic checks for dangling reference detection in the adapter. This is the biggest change here--please review carefully. The dynamic check previously complained if a child was deleted in the same tx as its parent, but that is too strict for the new implementation of `Transfer::delete_child_object`.
@sblackshear sblackshear force-pushed the fix_polymorphic_delete branch from ad029d5 to 079c3d3 Compare May 24, 2022 14: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.

2 participants