Skip to content
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] remove plugin dependencies #86

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

adamegyed
Copy link
Contributor

Motivation

Dependencies were used only to assign validation functions to execution functions defined in a plugin. Seeing how we intend to allow more user-controlled configuration of validation functions, we no longer have a good use for dependencies. Dependencies also add a lot of complexity to plugin install, uninstall, and the manifest.

Note that we don't yet have a finalized plan for what to do with the discrepancy between installValidation and installPlugin - this PR is just a simplification step towards finding the actual solution.

Solution

Remove dependencies as a parameter to installPlugin, and the corresponding storage fields.

After this change, the PluginData struct would only hold one parameter manifestHash. To simplify, combine the pluginData mapping and the enumerable set of plugins into an enumerable map, where the key is the plugin address and the value is the manifest hash.

Change the structs in the plugin manifest to hold a simplified representation of validation functions - only defining a function id, flags for global use + signature validation, and an optional list of selectors.

Update all usage of the installPlugin function and definitions of validation functions in manifests.

Future work

This PR still allows plugins to define validation functions. It is not clear to me whether we should allow manifests to define validation functions, given how we intend to treat the "function id" parameter as more of an "entity id" parameter, which interferes with the static nature of the manifest. We could consider only allowing manifests to define "runtime call" permissions, similar to the "permitted calls" list, if we decide to keep the manifest in a similar form to this.

It also doesn't merge installValidation and installPlugin. It would be nice to de-duplicate work here, but so far the manifest-based installation of plugins conflicts with the user-defined installation of validation functions and validation-associated hooks.

@adamegyed adamegyed requested a review from a team June 27, 2024 14:31
@adamegyed adamegyed force-pushed the adam/refactor-validation-mapping branch from 364e06b to b78c45b Compare June 27, 2024 19:29
@adamegyed adamegyed force-pushed the adam/axe-dependencies branch from b98930a to e6d9980 Compare June 27, 2024 19:29
@adamegyed adamegyed force-pushed the adam/refactor-validation-mapping branch from b78c45b to 05cea78 Compare June 27, 2024 20:11
@adamegyed adamegyed force-pushed the adam/axe-dependencies branch from e6d9980 to eb68744 Compare June 27, 2024 20:12
@@ -47,8 +41,7 @@ struct AccountStorage {
uint8 initialized;
bool initializing;
// Plugin metadata storage
EnumerableSet.AddressSet plugins;
mapping(address => PluginData) pluginData;
EnumerableMap.AddressToUintMap pluginManifestHashes;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not AddressToBytes32Map?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it doesn't exist: https://docs.openzeppelin.com/contracts/5.x/api/utils#EnumerableMap

This is the only map that has address as a key type.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use a newer version!

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 think it is the newest version, haha

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot be, it is in v5.1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's not released yet, check under the releases tab. I'd prefer to avoid using pre-release content, but we should update this when 5.1 is released.

Comment on lines +83 to +87
if (mv.isDefault) {
_storage.validationData[validationFunction].isDefault = true;
}

if (mv.isSignatureValidation) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep validation installation in plugin installation? If not, not worth adding new code in.

We talked about only keeping it in one place. While experimenting with validationId, validation installation within plugin installation is almost impossible.

  • It require unique onInstall data (an extra validationId) that is not required by other plugin installation.
  • We might generate false positive validations due to unable to match the validationIds for selectors actually just using the same validation.

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 think it's worth considering removing validation install via the manifest completely - this PR doesn't do that yet though, it just removes dependencies.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that we don't need to add more code in here like checking isSignatureValidation since we plan to remove validation install here altogether. No big deal either way.

@adamegyed adamegyed force-pushed the adam/refactor-validation-mapping branch from 05cea78 to 4cfa5bf Compare June 28, 2024 15:31
@adamegyed adamegyed force-pushed the adam/axe-dependencies branch from eb68744 to 1a3809a Compare June 28, 2024 15:32
@adamegyed adamegyed force-pushed the adam/refactor-validation-mapping branch from 4cfa5bf to 509ba03 Compare June 28, 2024 18:39
@adamegyed adamegyed force-pushed the adam/axe-dependencies branch from 1a3809a to 7e5fc4f Compare June 28, 2024 18:39
@adamegyed adamegyed force-pushed the adam/refactor-validation-mapping branch from 509ba03 to 1bfd893 Compare July 10, 2024 15:46
Base automatically changed from adam/refactor-validation-mapping to v0.8-develop July 10, 2024 15:55
@adamegyed adamegyed force-pushed the adam/axe-dependencies branch from 7e5fc4f to eaf3a53 Compare July 10, 2024 16:53
@adamegyed adamegyed merged commit cfa31b1 into v0.8-develop Jul 10, 2024
3 checks passed
@adamegyed adamegyed deleted the adam/axe-dependencies branch July 10, 2024 17:17
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.

2 participants