-
Notifications
You must be signed in to change notification settings - Fork 189
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, store): stop loading schema from storage, require schema as an argument #1174
Merged
Merged
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0a4dc5f
feat(store): add write methods that allow passing in a schema
alvrs b98e759
feat(store): change codegen to use methods with schema parameter
alvrs 3cd2cfc
feat(store): remove methods that implicitly load schema from storage
alvrs 8f8480a
feat(world): align methods with store to require schema to be passed in
alvrs f42a651
chore: rebuild artifacts
alvrs fd8e0f1
fix(cli): pass in schema to read system table
alvrs 37a4e56
remove stale files
alvrs 6af72f5
chore: update gas report
alvrs 63f54a8
fix test and gas-report
alvrs 86220bf
refactors
alvrs 840d930
fix e2e tests
alvrs 70a19fe
update gas report
alvrs b670d84
Create few-mirrors-reflect.md
alvrs 176d029
update project codegen tables
alvrs d871f3b
Update few-mirrors-reflect.md
alvrs b141c1f
run prettier
alvrs cb37445
clean up trace
alvrs d5ed69d
update pnpm
alvrs 67143bf
refactor trace
alvrs 102e83c
fix trace
alvrs b087930
Merge branch 'main' into alvrs/schema-methods
alvrs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
"@latticexyz/cli": major | ||
"@latticexyz/store": major | ||
"@latticexyz/world": major | ||
"create-mud": patch | ||
--- | ||
|
||
All `Store` methods now require the table's value schema to be passed in as an argument instead of loading it from storage. | ||
This decreases gas cost and removes circular dependencies of the Schema table (where it was not possible to write to the Schema table before the Schema table was registered). | ||
|
||
```diff | ||
function setRecord( | ||
bytes32 table, | ||
bytes32[] calldata key, | ||
bytes calldata data, | ||
+ Schema valueSchema | ||
) external; | ||
``` | ||
|
||
The same diff applies to `getRecord`, `getField`, `setField`, `pushToField`, `popFromField`, `updateInField`, and `deleteRecord`. | ||
|
||
This change only requires changes in downstream projects if the `Store` methods were accessed directly. In most cases it is fully abstracted in the generated table libraries, | ||
so downstream projects only need to regenerate their table libraries after updating MUD. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does the argument ordering here make sense? I usually order args by specificity and would kind of expect
valueSchema
to be further ahead in the list of arguments (before or aftertable
perhaps).Unless it's an optional arg, then it being at the end makes a bit more sense.
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.
i agree with ordering by specificity but would defer this refactor until after this current stack of PRs is merged since they touch lots of the same places in the code and changing it here would likely lead to massive merge conflicts in the upstream branches