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,store): add ERC165 checks for all registration methods #1458

Merged
merged 9 commits into from
Sep 12, 2023

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Sep 12, 2023

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Sep 12, 2023

🦋 Changeset detected

Latest commit: a709876

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

This PR includes changesets to release 28 packages
Name Type
@latticexyz/store Major
@latticexyz/world Major
@latticexyz/cli 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

@alvrs
Copy link
Member Author

alvrs commented Sep 12, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@@ -0,0 +1,21 @@
[
Copy link
Member

Choose a reason for hiding this comment

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

I added .gitattributes in another PR but might be worth adding here to land it sooner to suppress these codegen diffs for now:
https://github.com/latticexyz/mud/pull/1354/files#diff-618cd5b83d62060ba3d027e314a21ceaf75d36067ff820db126642944145393e


// ERC-165 Interface ID (see https://eips.ethereum.org/EIPS/eip-165)
bytes4 constant SYSTEM_HOOK_INTERFACE_ID = ISystemHook.onBeforeCallSystem.selector ^
ISystemHook.onAfterCallSystem.selector;
Copy link
Member

Choose a reason for hiding this comment

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

I noticed IModule above includes ERC165.supportsInterface.selector but this does not. Any reason?

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, should be included

IStoreHook.onBeforeSetField.selector ^
IStoreHook.onAfterSetField.selector ^
IStoreHook.onBeforeDeleteRecord.selector ^
IStoreHook.onAfterDeleteRecord.selector;
Copy link
Member

Choose a reason for hiding this comment

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

same here, seems to be missing ERC165.supportsInterface.selector?

holic
holic previously approved these changes Sep 12, 2023
IWorldContextConsumer._msgSender.selector ^
IWorldContextConsumer._msgValue.selector ^
IWorldContextConsumer._world.selector ^
ERC165.supportsInterface.selector;
Copy link
Member

Choose a reason for hiding this comment

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

is it necessary to define the inherited selectors as well as our own?

and if so would it be easier to do the whole interface ID instead of each selector (caveat: I don't know what the bitshifting is doing here)?

bytes4 constant DELEGATION_CONTROL_INTERFACE_ID = IDelegationControl.verify.selector ^
  WORLD_CONTEXT_CONSUMER_INTERFACE_ID ^
  ERC165_INTERFACE_ID;

Copy link
Member Author

Choose a reason for hiding this comment

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

agree this is cleaner, and should work since ^ (bitwise XOR) is commutative and associative

dk1a
dk1a previously approved these changes Sep 12, 2023
bytes4 constant ERC165_INTERFACE_ID = ERC165.supportsInterface.selector;

// See https://eips.ethereum.org/EIPS/eip-165
interface ERC165 {
Copy link
Member

Choose a reason for hiding this comment

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

should it be IERC165 for consistency?

Copy link
Member Author

Choose a reason for hiding this comment

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

agree

Comment on lines 13 to 17
function _msgSender() external view returns (address);
function _msgValue() external view returns (uint256);
function _world() external view returns (address);
Copy link
Member

Choose a reason for hiding this comment

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

why are these needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

need them to be public to be part of the interface to be able to distinguish a WorldContextConsumer contract

Base automatically changed from alvrs/fix-access-control to main September 12, 2023 21:14
@alvrs alvrs dismissed stale reviews from dk1a and holic September 12, 2023 21:14

The base branch was changed.

@alvrs
Copy link
Member Author

alvrs commented Sep 12, 2023

merging since there were no significant changes since the last approval, just implementation of review feedback and rebasing

@alvrs alvrs merged commit b9e562d into main Sep 12, 2023
10 checks passed
@alvrs alvrs deleted the alvrs/erc-165 branch September 12, 2023 21:48
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.

None yet

3 participants