-
Notifications
You must be signed in to change notification settings - Fork 131
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
[Feature Request] TypeTable #158
Comments
I like this proposal, a couple of thoughts:
|
|
I think this is a cool idea and would love to see it fleshed out more. My experience with Move in Sui and the demand for tables elsewhere have made me question the prudence of using a type-indexed data structure as the top-level schema for global storage, but I think type-indexed maps can still be very useful in some cases. |
Definitely a cool idea! I had been thinking for a while how a table system could replace global storage, and its rather tricky. The spots you will run into without always realizing is reference safety. It is easy to set something up without realizing it is unsafe, which is why it took us a while to build a static reference safety check in Move (and the first version of that still had dynamic reference checks for global storage references). For example in this setup
(But maybe, @jolestar, you realized this and this is why |
Interesting thought @tnowacki and it reminds me what we need to think about if we actually would like to replace borrow_global and friends with TypeTable. The API @jolestar is suggesting would not run into this problem because we always have a reference from which we derive subreferences, i.e. we do have But how is this thing 'bootstrapped'? From somewhere you need to get a root reference to start with. Without additional measures, you can't get rid of borrow_global to obtain that root reference. One alternative would be what Sui does, and also Async Move, and EVM Move (soonish). Top level entry points like transactions get passed in the root references from the environment. Only then we can make borrow_global obsolete... |
Sorry, I wasn't specific enough in my reply, I now see how that was confusing (I'll edit my comment above). |
🚀 Feature Request
Motivation
I have mentioned the idea of TypeTable in the documentation of Table, and I describe it in more detail here.
According to the implementation of Table(#150), we get:
But this Table can only use type K's value as the key, not type K as the key like borrow_global.
So I suggest introducing TypeTable with the basic operations described below:
Now, we can define a AccountStorage struct in Move:
Then we bind the table when Account create, such as:
and move_to(siger) = Account::move_to(siger), global_storage operation can been eliminate.
This feature can implement via an extension like Table and the backend storage is the same as Table, but TypeTable needs the same security guarantees as borrow_global.
We have two approaches to achieving this goal:
The text was updated successfully, but these errors were encountered: