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
The spec is not explicit about how the account should treat overlapping hooks (identical hooks that are applied on the same execution function selector by one or more plugins). Although reuse of hook functions across plugins may be uncommon, allowing overlaps helps in the case where multiple plugins opt to use the short-circuit magic value
FunctionReference._PRE_HOOK_ALWAYS_DENY
as a way to protect a particular function.This is also a step toward potentially allowing multiple validation functions to be applied to a given selector.
Solution
Use an EnumerableMap to keep track of the number of overlaps, to be able to keep the account in a consistent state when overlapping hooks are uninstalled.
When running the hooks, the following strategy is applied.
Additional changes
vm.expectCall
with thecount
parameter.isEmpty()
toFunctionReferenceLib
and updated code to use it over direct comparisons.