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(store,world): use user-types for ResourceId, FieldLayout and Schema in table libraries #1586

Merged
merged 15 commits into from Sep 24, 2023

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Sep 24, 2023

Thanks to #1566 we can now use the real user-types in table libraries and don't need to manually wrap/unwrap everywhere

@changeset-bot
Copy link

changeset-bot bot commented Sep 24, 2023

🦋 Changeset detected

Latest commit: 55ddc6d

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

This PR includes changesets to release 29 packages
Name Type
@latticexyz/store-sync Patch
@latticexyz/store Patch
@latticexyz/world Patch
@latticexyz/dev-tools Patch
@latticexyz/store-indexer Patch
@latticexyz/cli Patch
@latticexyz/react Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/ecs-browser Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/network Patch
@latticexyz/noise Patch
@latticexyz/phaserx Patch
@latticexyz/protocol-parser Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
@latticexyz/services Patch
@latticexyz/solecs Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/std-client Patch
@latticexyz/std-contracts Patch
@latticexyz/store-cache Patch
@latticexyz/utils 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

"gasUsed": 10240
"gasUsed": 5609
Copy link
Member Author

Choose a reason for hiding this comment

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

these gas changes come from not loading the _tableId and _keyTuple from storage in the gas test

Copy link
Member

Choose a reason for hiding this comment

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

same for all tests or just this one? I noticed some other gas improvements below

Copy link
Member Author

Choose a reason for hiding this comment

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

wrapping/unwrapping in itself should not significantly impact gas, so i think most of the gas variation in here comes from the changed gas tests

holic
holic previously approved these changes Sep 24, 2023
Copy link
Member

@holic holic left a comment

Choose a reason for hiding this comment

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

So nice!

@alvrs alvrs changed the base branch from main to alvrs/user-types-internal-type September 24, 2023 14:12
Comment on lines +79 to +84
// TODO: adjust when schemas are automatically resolved
export const schemasTable = {
...storeConfig.tables.Tables,
valueSchema: resolveUserTypes(storeConfig.tables.Tables.valueSchema, storeConfig.userTypes),
};

Copy link
Member Author

Choose a reason for hiding this comment

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

kind of annoying, but we need this workaround for now to land the contract changes (until we have a better way to resolve the user type config with strong types)

Copy link
Member

@holic holic Sep 24, 2023

Choose a reason for hiding this comment

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

hopefully coming in #1561 (but still a lot of work left to do)

dk1a
dk1a previously approved these changes Sep 24, 2023
Comment on lines +136 to +137
ResourceId tableId = _tableId;
bytes32[] memory keyTuple = _keyTuple;
Copy link
Member

Choose a reason for hiding this comment

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

we could use immutable too, it's about as convenient as storage, but without the gas overhead. It's only useful for constant-like values tho

holic
holic previously approved these changes Sep 24, 2023
Base automatically changed from alvrs/user-types-internal-type to main September 24, 2023 22:53
@alvrs alvrs dismissed stale reviews from holic and dk1a September 24, 2023 22:53

The base branch was changed.

@alvrs alvrs merged commit 22ee447 into main Sep 24, 2023
10 checks passed
@alvrs alvrs deleted the alvrs/resource-type-table branch September 24, 2023 23:09
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.

None yet

3 participants