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): expose getStaticField and getDynamicField on IStore and use it in codegen tables #1521

Merged
merged 7 commits into from
Sep 16, 2023

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Sep 16, 2023

Fixes #1519
Followup to #1512

  • Uses the new Storage.loadField utility to separate getField into getStaticField and getDynamicField for better gas performance
  • Expose getStaticField and getDynamicField on IStore
  • Update codegen to use the respective method

thanks @Boffee for finding this optimization

@changeset-bot
Copy link

changeset-bot bot commented Sep 16, 2023

🦋 Changeset detected

Latest commit: 66522b7

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

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

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

@@ -572,12 +572,49 @@ library StoreCore {
FieldLayout fieldLayout
) internal view returns (bytes memory) {
if (fieldIndex < fieldLayout.numStaticFields()) {
return StoreCoreInternal._getStaticField(tableId, keyTuple, fieldIndex, fieldLayout);
return StoreCoreInternal._getStaticFieldBytes(tableId, keyTuple, fieldIndex, fieldLayout);
Copy link
Member Author

Choose a reason for hiding this comment

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

We still need a method that returns the field as dynamic bytes memory with the correct length here

bytes32 tableId,
bytes32[] calldata keyTuple,
uint8 fieldIndex,
FieldLayout fieldLayout
Copy link
Member

@holic holic Sep 16, 2023

Choose a reason for hiding this comment

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

do you think it would make sense to flip these last two args? (might be a bigger refactor for other methods though)

Copy link
Member Author

Choose a reason for hiding this comment

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

added an issue to get back to this: #1521 (comment) (i remember we had talked about moving the Schema argument to another location too before it got replaced by FieldLayout)

@alvrs alvrs merged commit 55ab88a into main Sep 16, 2023
10 checks passed
@alvrs alvrs deleted the alvrs/static-dynamic-field branch September 16, 2023 21: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.

expose getStaticField and getDynamicField on StoreCore
2 participants