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

feat(world-module-metadata): add metadata module #3026

Merged
merged 24 commits into from
Aug 14, 2024
Merged

Conversation

holic
Copy link
Member

@holic holic commented Aug 13, 2024

part of #2981

Copy link

changeset-bot bot commented Aug 13, 2024

🦋 Changeset detected

Latest commit: 43dba06

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@latticexyz/cli Patch
@latticexyz/world-module-metadata Patch
@latticexyz/world-modules Patch
mock-game-contracts Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/dev-tools Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/protocol-parser Patch
@latticexyz/query Patch
@latticexyz/react Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/store Patch
@latticexyz/utils Patch
@latticexyz/world Patch
ts-benchmarks Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@holic holic force-pushed the holic/metadata-module branch from 7640a80 to 9866564 Compare August 14, 2024 15:01
world.registerFunctionSelector(metadataSystemId, "setResource(bytes32,bytes32,string)");
}

world.transferOwnership(namespace, _msgSender());
Copy link
Member Author

@holic holic Aug 14, 2024

Choose a reason for hiding this comment

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

this pattern feels a little weird to me, but curious to hear what you think:

on first install, metadata module creates metadata namespace, registers tables/systems, hands ownership back to original caller

on second install (idempotent, would upgrade systems or add tables), you'd first need to hand ownership of the namespace to the module, then it hands it back after install

should the world or something else own the metadata namespace? if so, how would you perform an upgrade to the metadata module?

or maybe we should consider the metadata module more of a "locked in" thing, rename it to something more specific like "resource tag module" and if we want more metadata, we add as another module and namespace rather than trying to figure out how to upgrade this one?

Copy link
Member

Choose a reason for hiding this comment

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

i think this pattern is fine! makes it possible to upgrade, which is nice

@holic holic changed the title WIP metadata module feat(world-module-metadata): add metadata module Aug 14, 2024
@holic holic marked this pull request as ready for review August 14, 2024 16:44
@holic holic requested a review from alvrs as a code owner August 14, 2024 16:44
world.installModule(metadataModule, new bytes(0));

// Transferring the namespace to the module and installing should be a no-op/idempotent and the module will return namespace ownership.
// TODO: is this a security concern? could someone frontrun by putting a tx in between the two calls below?
Copy link
Member

Choose a reason for hiding this comment

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

you can always make it atomic by doing both via a batchcall. But even without i don't think there is a security concern here, the module would just own the namespace, but unless the module has functions to do something malicious with or is upgradable, another tx in between couldn't do anything else with it

* To avoid circular dependencies, we run a very similar `build` step as `cli` package here.
*/

// TODO: move tablegen/worldgen to CLI commands from store/world we can run in package.json instead of a custom script
Copy link
Member

Choose a reason for hiding this comment

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

wanna open an issue for this? seems like a "good first issue"

Copy link
Member Author

Choose a reason for hiding this comment

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

done: #3030

alvrs
alvrs previously approved these changes Aug 14, 2024
@holic holic merged commit fad4e85 into main Aug 14, 2024
13 checks passed
@holic holic deleted the holic/metadata-module branch August 14, 2024 17:35
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