-
Notifications
You must be signed in to change notification settings - Fork 29
feat: [v0.8-develop, experimental] split up interfaces by type [1/N] #58
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
Conversation
src/interfaces/IPlugin.sol
Outdated
| /// @param value The call value. | ||
| /// @param data The calldata sent. | ||
| function preRuntimeValidationHook(uint8 functionId, address sender, uint256 value, bytes calldata data) | ||
| function runtimeValidationFunction(uint8 functionId, address sender, uint256 value, bytes calldata data) |
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.
Would naming the functions runtimeValidation and userOpValidation be more succinct and consistent?
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.
Yeah, it would be. We could switch them to be in the verb form of validateUserOp and validateRuntime, but it would be an overload of the function name validateUserOp due to the different parameters compared to 4337's IAccount with validateUserOp. What do you think of validateUserOp and validateRuntime?
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.
validateUserOp and validateRuntime look good to me. If we switch to verb forms, should we also update other functions for consistency?
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.
Updated to validateUserOp and validateRuntime. Which other functions were you thinking of renaming?
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.
For example, preUserOpValidationHook, but I can't think of a better name at the moment, haha.
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.
On function overloading, I'd be against it if it were on the same contract, since that would cause some ABI parsing issues (at least with viem/hardhat when I tried last time). But these are on plugins so it could be okay. Still might be confusing in communication if they're the same name.
Just riffing, and don't know if we want to address all of these here, but thoughts on:
onInstall
onUninstall
onValidateUserOp
onValidateRuntime or onValidateRuntimeTx
onBeforeValidateUserOp
onBeforeValidateRuntime or onBeforeValidateRuntimeTx
onBeforeExecute
onAfterExecute
Convention follows HTML event handlers (e.g., onBeforeUnload, onUnload).
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 feel like there's a difference in connotation between "callback" functions and "handler" functions - e.g. onInstall is something that fires on installation, but it doesn't check any return value other than success/failure. While, functions like validateUserOp do have a return value, and the return value has some contextual meaning. I know technically validateRuntime doesn't have a return value, but it still feels like it has a different use case than a callback.
Separately, I think we should move refactors like this to another PR - don't want to overload a single change with too much.
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.
Initially, I thought appending function after a function name was a bit redundant. However, it might be more effective to apply different naming conventions consistently according to their types. Agreed we should probably handle the renaming in a follow up PR if needed.
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.
(maybe on*** is suitable for passive functions, while handle*** works well for proactive 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.
Fine with revisiting renaming later!
Motivation
Currently,
IPluginimplements both functions necessary for all plugins likepluginManifest(), and all functions a plugin could possibly define across the different plugin types. This means that a plugin implementing one type would need to provide stubs of functions to conform to the solidity interface, even if those functions go unused. It also makes it more expensive to introduce any new plugin functions, since all plugins would need to implement it.Solution
Introduce new interfaces
IValidation,IValidationHook,IExecutionHookto organize possible plugin functions.Update
BasePlugin,UpgradeableModularAccount, and tests for these new interfaces.We also implicitly required plugins to support ERC-165, but did not actually include that in the
IPlugininterface. This makes that requirement more obvious to readers.