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

refactor(store): order load function arguments [N-02] #2033

Merged
merged 6 commits into from
Jan 10, 2024

Conversation

yonadaaa
Copy link
Contributor

@yonadaaa yonadaaa commented Dec 6, 2023

Arguments are now in the same order as the store function.

Copy link

changeset-bot bot commented Dec 6, 2023

🦋 Changeset detected

Latest commit: d2ef9b6

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

This PR includes changesets to release 30 packages
Name Type
@latticexyz/store Patch
@latticexyz/cli Patch
@latticexyz/dev-tools Patch
@latticexyz/react Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/world-modules Patch
@latticexyz/world 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

Copy link
Member

@alvrs alvrs left a comment

Choose a reason for hiding this comment

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

i think aligning the order is a good call and i think the storagePointer, offset, length, memoryPointer order makes sense, so it would be:

store(uint256 storagePointer, uint256 offset, bytes memory data)
store(uint256 storagePointer, uint256 offset, uint256 length, uint256 memoryPointer)
load(uint256 storagePointer, uint256 offset, uint256 length)
load(uint256 storagePointer, uint256 offset, uint256 length, uint256 memoryPointer) 

unfortunately this also means we need to adjust it in all consuming libraries and need to be very careful because the types are all uint256 so the compiler won't help us

@yonadaaa
Copy link
Contributor Author

yonadaaa commented Jan 8, 2024

@alvrs this was easier because most consumers call the functions with named arguments. Do we want to align the order there for consistency? ie.

bytes memory data = Storage.load({ storagePointer: storagePointer, length: 34, offset: 31 });

VS

bytes memory data = Storage.load({ storagePointer: storagePointer, offset: 31, length: 34 });

@alvrs
Copy link
Member

alvrs commented Jan 9, 2024

no need to change the order in consumers with named arguments imo!

@holic
Copy link
Member

holic commented Jan 9, 2024

if we have fewer than a ~dozen call sites, would vote to align order for consistency, even though it's not technically necessary

@yonadaaa
Copy link
Contributor Author

Agreeing with Frolic I have aligned the order on the named arguments also

"gasUsed": 245
"gasUsed": 2300
Copy link
Member

Choose a reason for hiding this comment

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

do we know where this is coming from? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

given that this increase isn't showing up in ~every other gas report, I am guessing something unrelated is going on

@alvrs alvrs merged commit 9f8b84e into main Jan 10, 2024
11 checks passed
@alvrs alvrs deleted the yonadaaa/load-args-order branch January 10, 2024 17:58
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.

3 participants