Skip to content

Conversation

@adamegyed
Copy link
Contributor

@adamegyed adamegyed commented May 17, 2024

Motivation

Currently, IPlugin implements both functions necessary for all plugins like pluginManifest(), 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, IExecutionHook to 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 IPlugin interface. This makes that requirement more obvious to readers.

@adamegyed adamegyed changed the title feat: [v0.8-develop, experimental] split up interfaces by type feat: [v0.8-develop, experimental] split up interfaces by type [1/N/ May 17, 2024
@adamegyed adamegyed changed the title feat: [v0.8-develop, experimental] split up interfaces by type [1/N/ feat: [v0.8-develop, experimental] split up interfaces by type [1/N] May 17, 2024
@adamegyed adamegyed marked this pull request as ready for review May 21, 2024 18:46
@adamegyed adamegyed requested a review from a team May 21, 2024 23:30
/// @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)
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Collaborator

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).

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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)

Copy link
Collaborator

@jaypaik jaypaik left a 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!

@adamegyed adamegyed merged commit ed804c3 into v0.8-develop May 31, 2024
@adamegyed adamegyed deleted the adam/split-up-interfaces branch May 31, 2024 15:30
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.

4 participants