-
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
Change Object to be a module package #163
Conversation
Do we have all modules in a package in the same fastx object, or do we have an index object for the package, pointing to other object containing the modules? |
The current design is to have all modules in the same fastx object. Having an index object would have the benefit of avoiding gigantic objects, seems doable to me and is a good idea. |
It does complicate a few things when it comes to address resolution. They should show the same abstraction to the client, so I would probably go with this first, and think about the indexing. |
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.
Great stuff!
Actually, big immutable objects are not so much of an issue, since we can aggressively cache them if they ever become an issue. |
All tests pass. Ready for review. |
Thanks for acting on this quickly @lxfind |
Previously, an
Object
can be either a Move object, or a Move module.Each module has an internal address (because Move expects it). In Diem, such address is simply where the module is published to, and multiple modules can be published to the same address.
However in FastX, since each module has a different address, even modules from the same package will have different addresses. This makes it extremely inconvenient to program with dependencies, because when you have dependencies to modules from the same package, you have to use different addresses to refer them. For instance, FastX::ObjectBasics has a different address than FastX::Transfer, which has a different address than FastX::Coin, and etc.
This PR changes the
Object
(in the modules case) to be a package, which is a collection of modules that are published together and belong to the same address. To facilitate fast lookup, it is in the form of a map from module name to the underline serialized module.To summarize the list of changes made by this PR:
Package(MovePackage)
instead ofModule(Vec<u8>)
, which is defined asBTreeMap<String, Vec<u8>>
. When fetching the ID of the Package, it picks the ID of the first module in it, as all modules share the same address in the same package.generate_module_ids
in adapter is changed togenerate_package_info_map
. It goes over all modules, group them by address to generate a list of packages, each package has a new id.