Skip to content

Commit

Permalink
fix: change all permission hooks to require UO context
Browse files Browse the repository at this point in the history
  • Loading branch information
howydev committed Jun 27, 2024
1 parent de54b5d commit 2481e1f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/account/AccountStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ struct ValidationData {
bool isDefault;
// Whether or not this validation is a signature validator.
bool isSignatureValidation;
// How many execution hooks require the UO context.
uint8 requireUOHookCount;
// The pre validation hooks for this function selector.
EnumerableSet.Bytes32Set preValidationHooks;
// Permission hooks for this validation function.
Expand Down
1 change: 1 addition & 0 deletions src/account/PluginManager2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ abstract contract PluginManager2 {

for (uint256 i = 0; i < permissionFunctions.length; ++i) {
ExecutionHook memory permissionFunction = permissionFunctions[i];
permissionFunction.requireUOContext = true;

if (
!_storage.validationData[validationFunction].permissionHooks.add(toSetValue(permissionFunction))
Expand Down
12 changes: 6 additions & 6 deletions src/account/UpgradeableModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ contract UpgradeableModularAccount is
// Revert if the provided `authorization` less than 21 bytes long, rather than right-padding.
FunctionReference runtimeValidationFunction = FunctionReference.wrap(bytes21(authorization[:21]));

if (getAccountStorage().validationData[runtimeValidationFunction].requireUOHookCount > 0) {
if (getAccountStorage().validationData[runtimeValidationFunction].permissionHooks.length() > 0) {
revert RequireUserOperationContext();
}

Expand Down Expand Up @@ -401,12 +401,12 @@ contract UpgradeableModularAccount is

_checkIfValidationApplies(selector, userOpValidationFunction, isDefaultValidation);

// Check if there are exec hooks associated with the validator that require UO context, and revert if the
// call isn't to `executeUserOp`
// This check must be here because if context isn't passed, we wouldn't be able to get the exec hooks
// associated with the validator
// Check if there are permission hooks associated with the validator, and revert if the call isn't to
// `executeUserOp`
// This check must be here because if context isn't passed, we can't tell in execution which hooks should
// have ran
if (
getAccountStorage().validationData[userOpValidationFunction].requireUOHookCount > 0
getAccountStorage().validationData[userOpValidationFunction].permissionHooks.length() > 0
&& bytes4(userOp.callData[:4]) != this.executeUserOp.selector
) {
revert RequireUserOperationContext();
Expand Down

0 comments on commit 2481e1f

Please sign in to comment.