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(cli): hardcode table ID with codegen #2229

Merged
merged 7 commits into from
Feb 2, 2024
Merged

Conversation

holic
Copy link
Member

@holic holic commented Feb 1, 2024

doing this as a precursor to #2166 and found that this had a gas improvement in the hot path!

Copy link

changeset-bot bot commented Feb 1, 2024

🦋 Changeset detected

Latest commit: 74c08c3

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

This PR includes changesets to release 30 packages
Name Type
@latticexyz/cli Patch
@latticexyz/common Patch
@latticexyz/store Patch
@latticexyz/world-modules Patch
@latticexyz/world Patch
create-mud Patch
@latticexyz/block-logs-stream Patch
@latticexyz/config Patch
@latticexyz/dev-tools Patch
@latticexyz/faucet Patch
@latticexyz/protocol-parser Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/react Patch
@latticexyz/abi-ts Patch
@latticexyz/ecs-browser Patch
@latticexyz/gas-report Patch
@latticexyz/network Patch
@latticexyz/noise Patch
@latticexyz/phaserx 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

@holic holic changed the title feat(cli): codegen hardcodes table ID feat(cli): hardcode table ID with codegen Feb 1, 2024
@holic holic marked this pull request as ready for review February 1, 2024 19:46
@holic holic requested review from alvrs and yonadaa as code owners February 1, 2024 19:46
ResourceId constant _tableId = ResourceId.wrap(
bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("store"), bytes16("StoreHooks")))
);
ResourceId constant _tableId = ResourceId.wrap(0x746273746f726500000000000000000053746f7265486f6f6b73000000000000);
Copy link
Member Author

@holic holic Feb 1, 2024

Choose a reason for hiding this comment

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

I don't mind this being a bit obscure since it's codegen, but if we feel like this magic constant should be clarified to end-users, we could add some codegen'ed comments above this explaining what's in this hex value (so we still get clarity along with gas benefits)

Comment on lines 23 to 22
ResourceId constant _tableId = ResourceId.wrap(
bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Multi")))
);
ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000004d756c74690000000000000000000000);
Copy link
Member

Choose a reason for hiding this comment

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

can we add a comment above these that explains this hex value?

Something like

// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Multi", typeId: RESOURCE_TABLE });`

@holic holic force-pushed the holic/hardcode-table-id branch from 5b707f7 to 74c08c3 Compare February 2, 2024 11:20
@holic holic merged commit a35c05e into main Feb 2, 2024
11 checks passed
@holic holic deleted the holic/hardcode-table-id branch February 2, 2024 11:39
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