-
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] default validation #63
Conversation
This would be very cool because I think it would enable a fairly straight forward path to compatibility with ERC7579's validator plugin (default validation acting as 7579's validator plugin) |
The introduction of default validation has a lot of reasons to exist outside of compatibility - better support for semi-modular accounts and cheaper account deployments. ERC7579-style validators don't make sense organizationally for a modular account, and even ZD Kernel is shifting away from it. I've previously outlined reasons why keeping some identifier or switching mechanism is needed here: #41 (comment) And you can see how Kernel is ditching the 7579 validator model for lack of flexibility here, introducing a |
/// with user install configs. | ||
/// @dev This function is only callable once, and only by the EntryPoint. | ||
|
||
function initializeDefaultValidation(address plugin, uint8 functionId, bytes calldata installData) |
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.
nice
Did a first pass - overall this makes 6900 accounts cheaper to deploy while maintaining flexibility in deciding which native functions the default validation can cover, which is great. Would prefer if another reviewer took a look just in case I missed some things though Are there differences in the validation functions used per selector v.s. a default validation function? Not a strong opinion, but IMO it's quite dangerous to allow plugins to specify being a default validator, think it should be an option in install configs instead |
Yeah I agree that could be risky. In the current PR it doesn't allow that, it depends on the user calling |
73f6768
to
84b44c4
Compare
Just my 2️⃣ cents, I feel like the end user would probably prefer to control the validations themselves rather than relying on the plugin implementation. Ideally, the account should be protected by default validations. If a specific execution function's validation is overridden by a plugin, then that plugin's validation should take precedence. However, when it comes to features, the situation might be different. The end user would probably prefer to have account features extended by plugins rather than account itself. |
e487a9f
to
48aaa70
Compare
Updated all naming of "shared" to "default" |
manifest.executionFunctions[0] = ManifestExecutionFunction({ | ||
executionSelector: this.onERC721Received.selector, | ||
isPublic: true, | ||
allowDefaultValidation: false |
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.
In the spirit of simplifying plugin dev work, allowDefaultValidation
can be omitted in this case.
In reality, both of those two flags will default to false if not set. We should document this somewhere.
function _installValidation( | ||
address plugin, | ||
uint8 functionId, | ||
bool isDefault, |
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.
Is this necessary? Is the goal to separate validation installation from other plugin installations?
Would it be easier to only separate default validation installation from all other plugin installations (include non default validation installations).
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.
These are not final interfaces, they're side doors to the install path because we haven't fully implemented user-supplied install configs yet. More detail in IPluginManager
: https://github.com/erc6900/reference-implementation/blob/adam/default-validation/src/interfaces/IPluginManager.sol
@@ -39,6 +39,8 @@ struct SelectorData { | |||
// Note that even if this is set to true, user op validation will still be required, otherwise anyone could | |||
// drain the account of native tokens by wasting gas. | |||
bool isPublic; |
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.
This field being true
also indicates the function is not state-change, right? Might be worth adding it to the docs.
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.
Technically, it can still be state-changing, it's just that usually this will only be used for view
functions. See this PR comment for more context: #61
revert UserOpValidationFunctionMissing(selector); | ||
} | ||
} else { | ||
// Not default validation, but per-selector |
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.
Minor, during the installation, it seems like we also install the default validation
for (uint256 i = 0; i < selectors.length; ++i) {
bytes4 selector = selectors[i];
if (!_storage.selectorData[selector].validations.add(toSetValue(validationFunction))) {
revert ValidationAlreadySet(selector, plugin, functionId);
}
}
should we check getAccountStorage().selectorData[selector].validations.contains()
for both default and non-default?
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.
That path in the installation is used if the user wishes to install a validation both as a default validation and for some specific selectors. If the user manually adds selectors that are already usable from default validation (e.g. execute
), then the cost savings of default validation go away. Similarly, checking the per-selector storage for the default validation increases costs due to the storage reads without providing a new form of checking.
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 see, that makes sense!
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.
lgtm!
Motivation
erc6900/resources#37
By introducing a "default" validation function pool, we can reduce plugin installation costs, particularly for ownership plugins, by allowing execution functions to opt-in to a default validation pool.
This also addresses some incompatibilities between ownership plugins and semi-modular accounts, by removing the need for a plugin to know each native function implemented by an account.
Solution
While the motivation is clear, I think there are a lot of possible ways to address the issue. This is one example of how we can address it.
This PR does the following:
allowDefaultValidation
, indicating whether the defining plugin believes it should be accessible by any validation added to the "pool of default validation functions".installValidation
/uninstallValidation
, that does a reduced-scope version ofinstallPlugin
for only a specific validation function. The user is able to control the domain of this validation function by specifying individual selectors, and whether or not the plugin should be in the default pool.New Todos