-
Notifications
You must be signed in to change notification settings - Fork 1
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
Module Management #15
Conversation
Refactor: simplifying and updating nomenclature for Modules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks good. I have a few smallish changes.
@@ -0,0 +1,37 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually hoping to avoid having JS packages in this repo, but it may be unavoidable.
I was planning to use forge fmt
instead of prettier for formatting, but there isn't a linter equivalent to replace solhint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can shift it over to forge fmt
, at least
src/modules/Modules.sol
Outdated
address module = _getModuleIfInstalled(veecode_); | ||
|
||
// Check that the function is not prohibited | ||
bytes4 functionSelector = bytes4(callData_[:4]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally like the idea of having the Parent be able to call functions in the course of operations, but restrict them from being called out of scope. I don't know if this is the right pattern though.
There are a few different options.
- We could have a function on the Module that returns a list of functions that are callable externally, similar to
requestPermissions
on Default modules. We could call itgovernanceFunctions
or something. You could then check your calldata against that prior to executing inexecOnModule
. These could be stored on install or fetched at the beginning of this function. - Having a variable on the Parent contract that is set when the
execOnModule
function is entered. Modules could have a modifier that checks whether this variable is set on the parent contract. This could be used to separateonlyParent
andonlyGovernance
functionality. Requires a re-entrant call back to Parent, but probably not an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2 seems more simple, as it would just be a modifier attached to the protected functions, e.g.
modifier noGovernance() {
if (Module(owner).isExecOnModule()) revert NoGovernance();
_;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this - please take a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onlyInternal
modifier added, along with the infra to support it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the implementation is close, but not quite there.
I think we only need one execOnModule
function, but with the format of execOnModuleInternal
. To be more explicit on this:
The idea is that there are standard functions on the Auction
, Derivative
, etc. modules that are called in the general user flows, such as purchase
. We don't want those to be able to be called by governance via execOnModule
. They could be if the only access control is onlyParent
. However, some functions like setMinDuration
should be callable by governance.
Therefore, there are two groups:
- Restricted functions only callable by AuctionHouse outside of
execOnModule
. - Restricted functions that should be accessible by Governance via
execOnModule
.
I would then propose the following refactor:
- change
isExecOnModuleInternal
toisExecOnModule
- delete
execOnModule
as currently written and replace with theexecOnModuleInternal
, renamed to justexecOnModule
onlyInternal
modifier should check ifisExecOnModule
and fail if it is true.
We would then use onlyInternal
for case 1 above and onlyParent
for case 2 (Governance type functions).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok that makes sense! I've pushed the changes.
src/modules/Modules.sol
Outdated
address module = _getModuleIfInstalled(veecode_); | ||
|
||
// Check that the function is not prohibited | ||
bytes4 functionSelector = bytes4(callData_[:4]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the implementation is close, but not quite there.
I think we only need one execOnModule
function, but with the format of execOnModuleInternal
. To be more explicit on this:
The idea is that there are standard functions on the Auction
, Derivative
, etc. modules that are called in the general user flows, such as purchase
. We don't want those to be able to be called by governance via execOnModule
. They could be if the only access control is onlyParent
. However, some functions like setMinDuration
should be callable by governance.
Therefore, there are two groups:
- Restricted functions only callable by AuctionHouse outside of
execOnModule
. - Restricted functions that should be accessible by Governance via
execOnModule
.
I would then propose the following refactor:
- change
isExecOnModuleInternal
toisExecOnModule
- delete
execOnModule
as currently written and replace with theexecOnModuleInternal
, renamed to justexecOnModule
onlyInternal
modifier should check ifisExecOnModule
and fail if it is true.
We would then use onlyInternal
for case 1 above and onlyParent
for case 2 (Governance type functions).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Going to merge.
Completes #9
Implements: