Skip to content

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

///
/// 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 Author

Choose a reason for hiding this comment

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

In the discussions we had about how we wanted to change this, the consensus that I gathered is that we wanted to move to this model where the native context extensions do not make any guarantees about mutability, or directly support interior mutability itself, but instead the decision around how to (or not to) support any type of mutability would be a per-extension decisions, and the extension would need to be explicit about how, and if, it will support mutability.

I think this is generally a better place to be as it makes it much clearer from the perspective of a user of the native extensions about how/if you want to support mutability for the extension (do you want a Mutex for some reason? Maybe no mutability, etc).

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.

Copy link
Contributor

@tnowacki tnowacki left a comment

Choose a reason for hiding this comment

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

LGTM

…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.
…pport Cloning, and let extension determine how to handle interior mutability.
…s to support Cloning, and let extension determine how to handle interior mutability.
@tzakian
Copy link
Contributor Author

tzakian commented Mar 19, 2025

merged into the bella-ciao branch. Closing.

@tzakian tzakian closed this Mar 19, 2025
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