-
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
[Move] Add shared mutable object support #722
Conversation
Sweet, V2 is 100+ lines less than V1! |
e4f0e14
to
163d20b
Compare
Quick Q on the systems side @lxfind : do we allow shared objects to be deleted? If so it makes the safety / liveness checks more expensive / complex. If a shared object can never be deleted then life is simpler. |
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.
Nice one! See question on delete & transfer!
@@ -48,6 +48,7 @@ pub fn all_natives( | |||
), | |||
("Transfer", "transfer_internal", transfer::transfer_internal), | |||
("Transfer", "freeze_object", transfer::freeze_object), | |||
("Transfer", "share_object", transfer::share_object), |
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.
Do we allow shared objects to be transferred?
There's nothing in the current programmability model that prevents deletion, transfer, or wrapping of shared objects. If you have a shared However, we can make any or all of these illegal via:
This isn't the best UX because you might have deleted a shared object in the middle of a tx, then continued executing for some time.
I'm sure there are several other options and am very curious to hear @lxfind's ideas. But perhaps the first thing to align on is which subset of {deletion, transfer, wrap} we want to support for shared objects. |
// to take turns to place the marker, there won't be a singificant overhead in practice. | ||
// As we can see, by using shared mutable object, the implementation is much | ||
// simpler than the other implementation. | ||
module Games::TicTacToeV2 { |
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.
One thing I'm wondering about (and this is philosophical/for the future): if we want to support both "modes" of tic tac toe, what is the best way to engineer this?
- Fully separate modules [current approach]
- Separate modules that share a common library
- Single module with some
_async
functions that can only be called in single-owner mode, some_sync
functions that can only be called in shared mode, and (hopefully) a large number of common functions
My instinct is that (2) is probably a cleaner approach than (1) (should lead to less code/test/Move prover spec duplication), but (3) may be a bridge too far. But at some point, we should try them all and see how it shakes out.
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.
It was somewhat surprising that these two approaches don't share much code at all. The primary reason is that the data storage model changed from storing objects as data into storing primitive data directly. So every function changed because of that. The only things that are still sharable are probably the constants.
It may be worth explaining in TestScenario.move that scenario's object pool contains both "per-address" objects as well as "shared objects" (only the former is implied at this point). The reason I think this could be useful is that it may not super-obvious that after |
/// can access and mutate. This is irreversible, i.e. once an object | ||
/// is shared, it will stay shared forever. | ||
/// Shared mutable object is not yet fully supported in Sui, which is being | ||
/// actively worked on and should be suppored very soon. This API is exposed |
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.
Are we going to have shared objects by GDC? The comment explaining the status is obviously there but if we are not I wonder if we should still postpone releasing tests for not-yet-fully-supported features to avoid confusion (e.g., people trying this with wallet CLI).
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 we won't have shared objects support in Sui by GDC.
The idea is to be able to put more Move examples that do interesting things (many of them would need shared object support) by GDC though.
At the moment shared object isn't allowed in Sui (it's only enabled in Move). So it's up to us to decide what we want to allow latter. |
163d20b
to
2a036eb
Compare
See dtolnay/anyhow#250 The `backtrace` feature is unified against the various anyhow versions we use.
See dtolnay/anyhow#250 The `backtrace` feature is unified against the various anyhow versions we use.
This PR adds support to use shared mutable object in Move.
Shared mutable object is not fully supported in Sui yet, as the sequencer is still being developed. However adding the support and library in Move will allow us to start writing interesting contracts using shared object.
This PR also writes a new version of TicTacToe that uses shared object, which provides an example for people to compare with the version that doesn't.