Skip to content

Conversation

@adamegyed
Copy link
Contributor

@adamegyed adamegyed commented May 21, 2024

Motivation

To allow for multiple validation functions per selector, we need a way to deal with overlapping values. The "always allow in runtime" magic value for validation poses a problem, where it could create additional overlapping values, similar to the "always deny" validation hook.

Solution

Instead of doing another special-casing in the validation storage, we can add a property to the definition of an execution function to indicate whether or not the function requires validation.

This is a more logical organization, because the implementer of a function should know whether it is a sensitive function or not. It avoids having to define validation functions for each of these, which simplifies most plugin manifests.

Although this will most often be applied to view functions, this PR avoids restricting it to only view functions and to using staticcall - there may be legitimate non-view functions that can be called by anyone, and allowing them comes at no incremental cost.

Future work

This introduces a new struct to the manifest, even though the fields within it would easily fit within a single word. The spec should pack these in the future, once we are more certain of its format.

@adamegyed adamegyed changed the title feat: [v0.8-develop, experimental]: move runtime validation always allow to execution function definition feat: [v0.8-develop, experimental]: move runtime validation always allow to execution function definition [4/N] May 21, 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
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.

Generally really like this simplification too. Would be great to get rid of the last magic value if possible too...

// The selector to install
bytes4 executionSelector;
// If true, the function won't need runtime validaiton, and can be called by anyone.
bool isPublic;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps isUnprotected or isUnguarded (or something else similar) is clearer?

Or maybe even isRuntimeUnprotected?

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 good ideas. I also thought of needsValidation, but I thought the intuition around isPublic might be simpler.

Copy link
Contributor

Choose a reason for hiding this comment

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

Using a name that includes runtime might help reduce user errors

// The selector to install
bytes4 executionSelector;
// If true, the function won't need runtime validaiton, and can be called by anyone.
bool isPublic;
Copy link
Contributor

Choose a reason for hiding this comment

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

Using a name that includes runtime might help reduce user errors

@adamegyed adamegyed force-pushed the adam/remove-plugin-call-restriction branch from c179b20 to f2ebe06 Compare May 29, 2024 20:56
@adamegyed adamegyed force-pushed the adam/simplify-rt-allowed-calls branch from c83ac72 to e871784 Compare May 29, 2024 21:01
@adamegyed adamegyed force-pushed the adam/remove-plugin-call-restriction branch from f2ebe06 to 34ccb35 Compare May 31, 2024 18:30
@adamegyed adamegyed force-pushed the adam/simplify-rt-allowed-calls branch from 96934cc to 77ce9ff Compare May 31, 2024 18:31
@adamegyed adamegyed force-pushed the adam/remove-plugin-call-restriction branch from 34ccb35 to 7d9b2f1 Compare May 31, 2024 18:34
Base automatically changed from adam/remove-plugin-call-restriction to v0.8-develop May 31, 2024 18:44
@adamegyed adamegyed force-pushed the adam/simplify-rt-allowed-calls branch from 77ce9ff to f48ccd7 Compare May 31, 2024 18:48
@adamegyed adamegyed merged commit 0923c21 into v0.8-develop May 31, 2024
@adamegyed adamegyed deleted the adam/simplify-rt-allowed-calls branch May 31, 2024 18:49
adamegyed added a commit that referenced this pull request Jul 26, 2024
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