[DRAFT] feat: [v0.8-develop, experimental] stateful composable validation #84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
We've done a lot of research into composable stateless validation, and why it's useful. It is also possible to do composable stateful validation, this branch explores one potential way to pursue this
Solution
In a very basic sense, one way to enable validation composition is to allow validations to tell the account to send out another call to
validateUserOpto some other validation plugin, and use that as part of the validity calculation.However, validation functions currently assume:
If we implemented "validation forwarding" in a naive way where a validation can call back into the account to perform another validation, some of these assumptions may be hard to enforce - what if the calling validation modified the user op or the hash?
So, rather than allowing a callback, what if a validation function was allowed to return a list of additional validation functions that must be run, and coalesce the result of all of these "chained" validation functions? Each validation function within this could then further chain calls, allowing arbitrary composition of validation functions.
Essentially, this allows a validation to return "conditional validity" - aka "validate this user op only if you ALSO validate it using these other validation function(s)".
This PR implements this "validation chaining" mechanism, and has a demonstration using an ECDSA validation plugin and a composable multisig plugin. For simplicity, the multisig plugin requires all owners to sign, instead of specifying a threshold, but one could be implemented with a threshold, too.
TODOs
This PR is a proof-of-concept, and leaves out some necessary details: