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): change requireOwnerOrSelf to requireOwner #1457

Merged
merged 4 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: 51b7b05

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

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

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@@ -19,12 +19,16 @@ import { NAMESPACE, MODULE_NAME, SYSTEM_NAME, TABLE_NAME } from "./constants.sol
contract UniqueEntityModule is IModule, WorldContextConsumer {
Copy link
Member

@holic holic Sep 12, 2023

Choose a reason for hiding this comment

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

should this and others use is Module instead of is IModule? oops, confused this with the other PR

ResourceSelector.from(ROOT_NAMESPACE, CORE_SYSTEM_NAME),
coreSystem,
true
funcSelectorAndArgs: abi.encodeCall(
Copy link
Member

Choose a reason for hiding this comment

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

not blocking this PR but would it make more sense to call this calldata?

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 use funcSelectorAndArgs in a couple places, could consider changing that to callData (calldata wouldn't work because it's a reserved word). Let's track in an issue!

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -58,68 +59,68 @@ contract KeysInTableHook is IStoreHook {

function onBeforeDeleteRecord(bytes32 tableId, bytes32[] memory key, Schema) public {
bytes32 keysHash = keccak256(abi.encode(key));
(bool has, uint40 index) = UsedKeysIndex.get(tableId, keysHash);
(bool has, uint40 index) = UsedKeysIndex.get(UsedKeysIndexTableId, tableId, keysHash);
Copy link
Member

Choose a reason for hiding this comment

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

does StoreSwitch not work here anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume it's cause they got namespaced?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah exactly, it's not using the root namespace anymore but we don't support separate namespaces in the config yet, so need to do it manually here for now by creating a separate table 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.

i think technically it doesn't have to be namespaced though but could continue using the root namespace since we only support installing it as root module for now anyway

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted this change. Had originally started to refactor the module to support non-root installations but then realized it would be a bigger change because we need to register a store hook on an arbitrary table.

);
if (!success) revertWithBytes(returnData);
Copy link
Member

@holic holic Sep 12, 2023

Choose a reason for hiding this comment

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

would it make sense to move this pattern into a lib for the commonly used methods for ergonomics?

WorldRoot.registerStoreHook(world, ...)
WorldRoot.registerSystem(world, ...)

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 it would be more ergonomic to use, but unfortunately more gas expensive because of all the parameters that need to be passed around in memory, and that library would be pretty painful to maintain (because it would have to include all the function signatures of all systems of IBaseWorld which includes all the functions the CoreModule registers)

dk1a
dk1a previously approved these changes Sep 12, 2023

function getName() public pure returns (bytes16) {
return MODULE_NAME;
}

function installRoot(bytes memory args) public {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it ok that installRoot won't delegatecall anything here?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah this module doesn't require any root access, it's just registering the table and system in its own namespace

@alvrs
Copy link
Member Author

alvrs commented Sep 12, 2023

no major changes since last approvals, going ahead with mege

@alvrs alvrs merged commit 51914d6 into main Sep 12, 2023
9 checks passed
@alvrs alvrs deleted the alvrs/fix-access-control branch September 12, 2023 21:14
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