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

chore: rename validation associated hooks to module entity associated hooks #212

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/account/AccountStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct ValidationStorage {
ValidationFlags validationFlags;
// The validation hooks for this validation function.
HookConfig[] validationHooks;
// Execution hooks to run with this validation function.
// Execution hooks associated with this entity, to be run when this validation is used.
EnumerableSet.Bytes32Set executionHooks;
// The set of selectors that may be validated by this validation function.
EnumerableSet.Bytes32Set selectors;
Expand Down
38 changes: 19 additions & 19 deletions src/account/ReferenceModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ contract ReferenceModularAccount is
// Wraps execution of a native function with runtime validation and hooks
// Used for upgradeTo, upgradeToAndCall, execute, executeBatch, installExecution, uninstallExecution
modifier wrapNativeFunction() {
(PostExecToRun[] memory postValidatorExecHooks, PostExecToRun[] memory postSelectorExecHooks) =
(PostExecToRun[] memory postExecHooksForEntity, PostExecToRun[] memory postExecHooksForSelector) =
_checkPermittedCallerAndAssociatedHooks();

_;

_doCachedPostExecHooks(postSelectorExecHooks);
_doCachedPostExecHooks(postValidatorExecHooks);
_doCachedPostExecHooks(postExecHooksForSelector);
_doCachedPostExecHooks(postExecHooksForEntity);
}

constructor(IEntryPoint anEntryPoint) {
Expand All @@ -115,7 +115,7 @@ contract ReferenceModularAccount is
if (execModule == address(0)) {
revert UnrecognizedFunction(msg.sig);
}
(PostExecToRun[] memory postValidatorExecHooks, PostExecToRun[] memory postSelectorExecHooks) =
(PostExecToRun[] memory postExecHooksForEntity, PostExecToRun[] memory postExecHooksForSelector) =
_checkPermittedCallerAndAssociatedHooks();

// execute the function, bubbling up any reverts
Expand All @@ -128,8 +128,8 @@ contract ReferenceModularAccount is
}
}

_doCachedPostExecHooks(postSelectorExecHooks);
_doCachedPostExecHooks(postValidatorExecHooks);
_doCachedPostExecHooks(postExecHooksForSelector);
_doCachedPostExecHooks(postExecHooksForEntity);

return execReturnData;
}
Expand All @@ -144,7 +144,7 @@ contract ReferenceModularAccount is

ModuleEntity userOpValidationFunction = ModuleEntity.wrap(bytes24(userOp.signature[:24]));

PostExecToRun[] memory postValidatorExecHooks =
PostExecToRun[] memory postExecHooksForEntity =
_doPreHooks(getAccountStorage().validationStorage[userOpValidationFunction].executionHooks, msg.data);

(bool success, bytes memory result) = address(this).call(userOp.callData[4:]);
Expand All @@ -156,7 +156,7 @@ contract ReferenceModularAccount is
}
}

_doCachedPostExecHooks(postValidatorExecHooks);
_doCachedPostExecHooks(postExecHooksForEntity);
}

/// @inheritdoc IModularAccount
Expand Down Expand Up @@ -207,8 +207,8 @@ contract ReferenceModularAccount is

_doRuntimeValidation(runtimeValidationFunction, data, authorization[25:]);

// If runtime validation passes, run exec hooks associated with the validator
PostExecToRun[] memory postValidatorExecHooks =
// If runtime validation passes, run exec hooks associated with the entity
PostExecToRun[] memory postExecHooksForEntity =
_doPreHooks(getAccountStorage().validationStorage[runtimeValidationFunction].executionHooks, data);

// Execute the call
Expand All @@ -220,7 +220,7 @@ contract ReferenceModularAccount is
}
}

_doCachedPostExecHooks(postValidatorExecHooks);
_doCachedPostExecHooks(postExecHooksForEntity);

return returnData;
}
Expand Down Expand Up @@ -365,7 +365,7 @@ contract ReferenceModularAccount is
isGlobalValidation ? ValidationCheckingType.GLOBAL : ValidationCheckingType.SELECTOR
);

// Check if there are execution hooks associated with the validator, and revert if the call isn't to
// Check if there are execution hooks associated with the entity, 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
Expand Down Expand Up @@ -549,16 +549,16 @@ contract ReferenceModularAccount is
* directly call.
* - Yes: Continue
* - No: Revert, the caller is not allowed to call this selector
* 3. If there are runtime validation hooks associated with this caller-sig combination, run them.
* 4. Run the pre executionHooks associated with this caller-sig combination, and return the
* 3. If there are runtime validation hooks associated with this entity, run them.
* 4. Run the pre executionHooks associated with this entity, and return the
* post executionHooks to run later.
*/
function _checkPermittedCallerAndAssociatedHooks()
internal
returns (PostExecToRun[] memory, PostExecToRun[] memory)
{
AccountStorage storage _storage = getAccountStorage();
PostExecToRun[] memory postValidatorExecutionHooks;
PostExecToRun[] memory postExecHooksForEntity;

// We only need to handle execution hooks when the sender is not the entry point or the account itself,
// and the selector isn't public.
Expand All @@ -582,16 +582,16 @@ contract ReferenceModularAccount is
_doPreRuntimeValidationHook(preRuntimeValidationHooks[i].moduleEntity(), msg.data, "");
}

// Execution hooks associated with the validator
postValidatorExecutionHooks =
// Execution hooks associated with the entity
postExecHooksForEntity =
_doPreHooks(_storage.validationStorage[directCallValidationKey].executionHooks, msg.data);
}

// Exec hooks associated with the selector
PostExecToRun[] memory postSelectorExecutionHooks =
PostExecToRun[] memory postExecHooksForSelector =
_doPreHooks(_storage.executionStorage[msg.sig].executionHooks, msg.data);

return (postValidatorExecutionHooks, postSelectorExecutionHooks);
return (postExecHooksForEntity, postExecHooksForSelector);
}

function _execUserOpValidation(
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.20;
// Index marking the start of the data for the validation function.
uint8 constant RESERVED_VALIDATION_DATA_INDEX = type(uint8).max;

// Maximum number of validation-associated hooks that can be registered.
// Maximum number of entity associated hooks that can be registered.
uint8 constant MAX_VALIDATION_ASSOC_HOOKS = type(uint8).max;

// Magic value for the Entity ID of direct call validation.
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IExecutionHookModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface IExecutionHookModule is IModule {
/// be more than one.
/// @param sender The caller address.
/// @param value The call value.
/// @param data The calldata sent. For `executeUserOp` calls of validation-associated hooks, hook modules
/// @param data The calldata sent. For `executeUserOp` calls of entity associated hooks, hook modules
/// should receive the full calldata.
/// @return Context to pass to a post execution hook, if present. An empty bytes array MAY be returned.
function preExecutionHook(uint32 entityId, address sender, uint256 value, bytes calldata data)
Expand Down
Loading