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

[3/n][vm-rewrite][Move] Update native context extensions to support Cloning #21067

Open
wants to merge 1 commit into
base: tzakian/vm-rewrite-adapter-2
Choose a base branch
from

Conversation

tzakian
Copy link
Contributor

@tzakian tzakian commented Feb 3, 2025

This updates the NativeContextExtensions struct to be Cloneable. This updates the Box<dyn Tid<'a>> to a Rc<dyn Tid<'a>> and the extension is responsible for handling interior mutability.

As a helper struct the NativeContextMut was added to allow for easy writing/handling of native extensions that need interior mutability.

NB: The code in the PR may not be working as future PRs will build on top of this. In particular, for this PR, the changes to the object runtime/sui-adapter/sui-execution natives will be needed.

@tzakian tzakian requested a review from cgswords February 3, 2025 20:54
Copy link

vercel bot commented Feb 3, 2025

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 Feb 4, 2025 8:32pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Feb 4, 2025 8:32pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Feb 4, 2025 8:32pm

…loning, and let extension determine how to handle interior mutability.

This updates the `NativeContextExtensions` struct to be `Clone`able.
This updates the `Box<dyn Tid<'a>>` to a `Rc<dyn Tid<'a>>` and the
extension is responsible for handling interior mutability.

As a helper struct the `NativeContextMut` was added to allow for easy
writing/handling of native extensions that need interior mutability.

NB: The code in the PR may not be working as future PRs will build on
top of this. In particular, for this PR, the changes to the object
runtime/sui-adapter/sui-execution natives will be needed.
///
/// Note that this is _not_ threadsafe. If you need threadsafe access to the `T` you will need to
/// handle that within `T'`s type (just like in the previous implementation of the
/// `NativeContextExtensions`).
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a little confused. It appears we are making it so that all mutability needs to be explicit when building up the native context extension, whereas before everything was arbitrarily mutable. What is the motivation for this change?

Copy link
Contributor

@cgswords cgswords left a comment

Choose a reason for hiding this comment

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

LGTM, modulo understanding the motivation for this change.

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