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

Revisit decision around mapping function selectors to resources vs directly to systems #1135

Closed
Tracked by #444
alvrs opened this issue Jul 10, 2023 · 1 comment
Closed
Tracked by #444
Assignees

Comments

@alvrs
Copy link
Member

alvrs commented Jul 10, 2023

Instead of mapping to a resource, the function selector could map direcly to a system function, which would save one sload per call, but add some complexity to upgrading systems. See WorldRegistrationSystem.registerFunctionSelector

@alvrs alvrs converted this from a draft issue Jul 10, 2023
@alvrs alvrs added this to the Contracts stable milestone Jul 10, 2023
@alvrs alvrs mentioned this issue Jul 10, 2023
22 tasks
@alvrs
Copy link
Member Author

alvrs commented Sep 1, 2023

If we wanted to map function selectors directly to system addresses we'd introduce a lot of additional complexity:

  • duplicating the access control logic: if a system is not registered as openAccess, we'd have to load the resource selector from storage and perform access control checks based on it.
  • duplicating the logic when to call a system via delegatecall or call (which is currently determined based on the resource selector). Probably would have to store it as a flag in the function selector table, so there is not a single source of truth anymore for whether a system is a root system.
  • increased complexity for upgrades: instead of just pointing the resource selector to a new address, we now would have to set up a reverse mapping for which function selectors are registered for a given address, and change all those references to the new address too
  • increased "conceptual complexity" - instead of once concept for systems (resource selector) we would have two concepts and two sources of truth (ie "a system is a root system if it is registered in the root namespace or if there is a flag in the function selector table saying so")

To avoid all of this complexity I think it's a worthwhile tradeoff to accept a single additional sload and keep pointing function selectors to resource selectors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

1 participant