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(world): add FunctionSignatures offchain table #1575

Merged
merged 5 commits into from
Sep 22, 2023

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Sep 22, 2023

The FunctionSelectors offchain table now stores a mapping from function selector to signature for all methods registered in the World. This will enable the automatic generation of interfaces for a given world address in the future.

@changeset-bot
Copy link

changeset-bot bot commented Sep 22, 2023

🦋 Changeset detected

Latest commit: cdc056e

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

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

@alvrs
Copy link
Member Author

alvrs commented Sep 22, 2023

@@ -23,9 +23,9 @@ interface IWorldRegistrationSystem {

function registerRootFunctionSelector(
Copy link
Member

@holic holic Sep 22, 2023

Choose a reason for hiding this comment

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

Should this be just “register root function”? And the non root one “register function”?

Copy link
Member Author

Choose a reason for hiding this comment

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

i personally find it more intuitive to keep the selector, since what happens is that a new function selector is added to the world contract (it's debatable, but there isn't really a new function added to the world, the function is part of the system and it was already possible to call it before a function selector was registered for it)

Copy link
Member

Choose a reason for hiding this comment

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

but we are effectively adding a function to the world, regardless of how it’s implemented

I kinda like that “register function” communicates “world is mutable/extendable”

but happy to keep as is if you feel strongly

Copy link
Member Author

@alvrs alvrs Sep 22, 2023

Choose a reason for hiding this comment

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

In my mind we're just adding a "link" to an existing function by adding a new "function selector" to the World here. The World was extended when the system was registered (and it's even cheaper to call a function via the World's call function than going the indirection over the "function selector link" in the World)

Copy link
Member

Choose a reason for hiding this comment

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

ohh I see, we're aliasing a function's name? I thought this is what system registration used to enable you to call the system methods via the world

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.

Beaut!

holic
holic previously approved these changes Sep 22, 2023
Base automatically changed from alvrs/func-selectors to main September 22, 2023 19:33
@alvrs alvrs dismissed holic’s stale review September 22, 2023 19:33

The base branch was changed.

@alvrs alvrs force-pushed the alvrs/func-selector-preimage branch from d15144d to 4c9608c Compare September 22, 2023 19:37
@alvrs alvrs changed the title feat(world): add FunctionSignatures offchain table, change registerRootFunctionSelector function to accept signature instead of selector feat(world): add FunctionSignatures offchain table Sep 22, 2023
@alvrs alvrs marked this pull request as ready for review September 22, 2023 19:49
@alvrs alvrs requested a review from dk1a as a code owner September 22, 2023 19:49
Copy link
Member Author

@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.

✅ (only gas report changed since last approval)

@alvrs alvrs merged commit e5d208e into main Sep 22, 2023
10 checks passed
@alvrs alvrs deleted the alvrs/func-selector-preimage branch September 22, 2023 20:01
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