-
Notifications
You must be signed in to change notification settings - Fork 25
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: [v0.8-develop, experimental] multi-validation in calldata #52
Conversation
e210379
to
56e9e72
Compare
56e9e72
to
2a73e35
Compare
@@ -38,7 +39,7 @@ abstract contract AccountLoupe is IAccountLoupe { | |||
config.plugin = _storage.selectorData[selector].plugin; | |||
} | |||
|
|||
config.validationFunction = _storage.selectorData[selector].validation; | |||
config.defaultValidationFunction = toFunctionReference(_storage.selectorData[selector].validations.at(0)); |
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.
(small nit) maybe primaryValidationFunction
?
Awesome I like it!! I wonder if we should perhaps embed the concept of the default validation function a bit deeper into the standard, i.e. it is not implicitly specified by being the first entry in the list, but explicitly through a new storage field in the If we would also add a new native function Perhaps the standard default validation function for function selectors a plugin introduces can be specified by the plugin manifest. Also, in case a plugin installs the first validation function, e.g. for a native selector on initial configuration, it could be automatically promoted to the default validation function. The Could flesh this out more, but for now wondering if I’m heading towards over-engineering it or if I’m being reasonable here. Edit: Ah, just realized this idea has some overlap with erc6900/resources#37, only that I'm proposing having the default validation configurable for each selector, not on a plugin level. |
Also, as far as I'm seeing it, the security implications do not just affect |
Closing, superseded by #62. |
Motivation
As described in erc6900/resources#4, supporting multiple validation functions at once has been a long-standing goal of ERC-6900.
Proposed Solution
This PR implements the first suggestion described in the issue above, implementing a new native function called
executeWithValidation(FunctionReference validation, bytes calldata data)
.Note that this does not implement the function
executeWithContext
, where additional data can be made available to validation plugins, because the current validation interface does not support out-of-band extra data, beyond what's in the user operation for UO validation and calldata for RT validation.Account behavior changes:
executeWithValidation
is put intouserOp.callData
, user op validation will rely on the provided validation function, if it is installed and made available to the actual execution function selector being called within thedata
parameter.executeWithValidation
is called directly, runtime validation will rely on the provided validation function, if it is installed and made available to the actual execution function selector being called within thedata
parameter.executeWithvalidation
forwards the call indata
to itself with a self-call (not self-delegatecall).execute
andexecuteBatch
- no change is made to those functions here, if we wish to pursue this form of multi-validation, we will have to address that eventually.MultiValidation.t.sol
.Additional discussion
Reasons for choosing a calldata-based encoding of validation selection
Ramifications of choosing calldata to specify validation switching
executeWithValidation
function format.executeWithValidation
is useful, is that this is how we make use of contract interfaces that the account supports through execution function. I.e. in tests, we may wrap the account with a different interface likeSingleOwnerPlugin(account1).transferOwnership(...)
, or frontends may use the plugin abi to generate function calls on the account.executeWithValidation
.Ramifications of multi-validation in general
MultiValidation.t.sol
: we have to define a new version ofSingleOwnerPlugin
with the execution function names changed:transferOwnership
->transferOwnership2
,owner
->owner2
.execute
/executeBatch
is not a plugin?userOp.signature
, then it could break composability.Conclusion
Doing multi-validation while supporting runtime validation in its current form introduces some added complexities that we had previously not discovered: the requirement to put validation selection into calldata, which itself leads to an additional requirement of having a default validation per selector. We may want to consider changing how we handle runtime validation to make multi-validation support easier.
Additionally, multi-validation introduces association complexities to pre-validation hooks, regardless of the switching mechanism chosen. Pre-validation hooks make the most sense to be associated with validation functions, rather than execution selectors; however, doing so is difficult with the current parameter format for
installPlugin
dependencies, and requires changes there as well.And finally, the use of execution functions as the exclusive way to do for plugin state management makes it impossible to install two instances of the same validation plugin at the same time. This is a big composability break, and we should consider removing the check in standard execute functions to be non-plugin contracts.