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

[3/n permissions] feat: add execute user op #69

Merged
merged 4 commits into from
Jun 19, 2024

Conversation

howydev
Copy link
Collaborator

@howydev howydev commented Jun 10, 2024

changes:

  1. Add executeUserOp
  2. If hooks require UO context, enforce that calls are made to executeUserOp in UO validation
  3. Send abi.encode(PackedUserOperation) if UO context is required, else send abi.encodePacked(msg.sender, msg.value, msg.data)
  4. Add permission hook installation/uninstallation via installValidation and uninstallValidation

Copy link
Contributor

@adamegyed adamegyed left a comment

Choose a reason for hiding this comment

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

Looks good overall, had a few questions for changes earlier in the stack. Would be nice to have a test verifying that a hook gets an entire user op, too.

@@ -197,7 +230,7 @@ contract UpgradeableModularAccount is
}

PostExecToRun[] memory postExecHooks =
_doPreExecHooks(_storage.selectorData[selector].executionHooks, data);
_doPreHooks(_storage.selectorData[selector].executionHooks, data, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think `executeFromPlugin shouldn't exist in this PR, right? The permissions were removed in #67 on your stack, and #65 on mine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not rebased on top of that yet!

@@ -224,9 +257,10 @@ contract UpgradeableModularAccount is
}

// Run any pre exec hooks for this selector
PostExecToRun[] memory postExecHooks = _doPreExecHooks(
PostExecToRun[] memory postExecHooks = _doPreHooks(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, the executeFromPluginExternal path should be gone in an earlier PR.

Comment on lines +559 to +539
(FunctionReference hookFunction, bool isPreHook, bool isPostHook, bool requireUOContext) =
toExecutionHook(key);

if (!isPackedUO && requireUOContext) {
revert RequireUserOperationContext();
}

if (isPreHook) {
bytes memory preExecHookReturnData = _runPreExecHook(hookFunction, data);
bytes memory preExecHookReturnData;

if (isPackedUO) {
if (requireUOContext) {
preExecHookReturnData = _runPreExecHook(hookFunction, data);
} else {
PackedUserOperation memory uo = abi.decode(data, (PackedUserOperation));
preExecHookReturnData =
_runPreExecHook(hookFunction, abi.encodePacked(msg.sender, msg.value, uo.callData));
}
} else {
preExecHookReturnData =
_runPreExecHook(hookFunction, abi.encodePacked(msg.sender, msg.value, data));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Slight preference for not using nested if/else branches, and instead early-terminating with a continue; statement to reduce indent depth, but this is just stylistic. The workflow itself looks good for handling the different possible cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The difference is mostly bytecode size by reducing JUMPs? I think this is more readable, will leave it because its RI, but production accounts should consider making this change

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah no I think it should be equivalent, I meant it as a readability nit.

@howydev howydev force-pushed the howy/add-permission-hooks branch from b183d5a to f3ad732 Compare June 17, 2024 21:15
@howydev howydev force-pushed the howy/add-permission-hooks branch 3 times, most recently from 7d9f003 to 3c65bc6 Compare June 17, 2024 22:35
@howydev howydev force-pushed the howy/add-execUO branch 2 times, most recently from de53ae8 to 8e244e6 Compare June 18, 2024 17:52
@howydev howydev marked this pull request as ready for review June 18, 2024 17:57
@howydev howydev changed the title [DRAFT] [3/n permissions] feat: add execute user op [3/n permissions] feat: add execute user op Jun 18, 2024
@howydev howydev force-pushed the howy/add-permission-hooks branch from 4f8c2dc to 5d2c4ff Compare June 19, 2024 19:49
Base automatically changed from howy/add-permission-hooks to howy/remove-permissions June 19, 2024 20:00
@howydev howydev merged commit eb19185 into howy/remove-permissions Jun 19, 2024
@howydev howydev deleted the howy/add-execUO branch June 19, 2024 20:01
@howydev
Copy link
Collaborator Author

howydev commented Jul 23, 2024

addresses: erc6900/resources#50

@howydev
Copy link
Collaborator Author

howydev commented Jul 23, 2024

addresses erc6900/resources#35

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