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

Allow direct plugin calls with validation & permission hooks #90

Merged
merged 26 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fe5af61
feat: initial impl of simple plugin direct calls with validation hooks
Zer0dot Jul 10, 2024
b11b7b4
chore: remove unused import, formatting
Zer0dot Jul 10, 2024
222243e
chore: slight refactor for codesize
Zer0dot Jul 11, 2024
e1adaca
feat: add direct call selectors to plugin manifest and installation
Zer0dot Jul 11, 2024
1d45b2e
feat: test basic direct plugin call functionality
Zer0dot Jul 11, 2024
883eff5
test: extra scenario test, minor renaming
Zer0dot Jul 11, 2024
691dd31
refactor: migrate direct call installation to installValidation
Zer0dot Jul 12, 2024
4a99058
chore: cleanup comments
Zer0dot Jul 12, 2024
efc111f
chore: slight cleanup and renaming
Zer0dot Jul 13, 2024
2a58118
test: add permission hooks to direct plugin call tests
Zer0dot Jul 15, 2024
d614b0e
chore: update permission hook uninstallation to handle full execution…
Zer0dot Jul 15, 2024
f0b8321
refactor: refactor while to for loop for permission hook uninstallation
Zer0dot Jul 16, 2024
43a3e5c
chore: document direct-call flow
Zer0dot Jul 16, 2024
e615bc2
refactor: consolidate pre-runtime-hooks into internal function
Zer0dot Jul 16, 2024
b537f07
Merge branch 'v0.8-develop' into zer0dot/direct-plugin-calls
Zer0dot Jul 16, 2024
b3b834f
chore: remove unused import
Zer0dot Jul 16, 2024
4aa008c
chore: remove unused imports
Zer0dot Jul 16, 2024
ae26e5f
chore: linting changes
Zer0dot Jul 16, 2024
a09ffb2
chore: remove unused struct and using for statements
Zer0dot Jul 16, 2024
a978cd7
feat: use _checkIfValidationAppliesCallData() rather than manually ch…
Zer0dot Jul 16, 2024
ad4fcb6
chore: rename missing validation error to encapsulate runtime as well
Zer0dot Jul 17, 2024
d263656
chore: fix function ordering
Zer0dot Jul 17, 2024
0f04d85
chore: double linter max line-length for test error strings
Zer0dot Jul 17, 2024
32c39fb
Merge branch 'v0.8-develop' into zer0dot/direct-plugin-calls
Zer0dot Jul 17, 2024
a425c9b
chore: formatting
Zer0dot Jul 17, 2024
4a29ae3
chore: rename old function to modern naming (functionReference => plu…
Zer0dot Jul 17, 2024
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
7 changes: 3 additions & 4 deletions src/account/UpgradeableModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@
// Check that the provided validation function is applicable to the selector
if (isGlobal) {
if (!_globalValidationAllowed(selector) || !_storage.validationData[validationFunction].isGlobal) {
revert UserOpValidationFunctionMissing(selector);
revert UserOpValidationFunctionMissing(selector); //TODO: Update this error as it can be runtime
Zer0dot marked this conversation as resolved.
Show resolved Hide resolved
// validation too
}
} else {
// Not global validation, but per-selector
Expand Down Expand Up @@ -711,7 +712,7 @@
* 4. Run the pre-permissionHooks associated with this caller-sig combination, and return the
* post-permissionHooks to run later.
*/
function _checkPermittedCallerAndAssociatedHooks()

Check warning on line 715 in src/account/UpgradeableModularAccount.sol

View workflow job for this annotation

GitHub Actions / Run Linters

Function order is incorrect, internal function can not go after internal view function (line 689)
internal
returns (PostExecToRun[] memory, PostExecToRun[] memory)
{
Expand All @@ -727,9 +728,7 @@
FunctionReference directCallValidationKey =
FunctionReferenceLib.pack(msg.sender, _SELF_PERMIT_VALIDATION_FUNCTIONID);

if (!_storage.validationData[directCallValidationKey].selectors.contains(toSetValue(msg.sig))) {
revert ExecFromPluginNotPermitted(msg.sender, msg.sig);
}
_checkIfValidationAppliesCallData(msg.data, directCallValidationKey, false);

// Direct call is allowed, run associated permission & validation hooks

Expand Down
6 changes: 2 additions & 4 deletions test/account/DirectCallsFromPlugin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ contract DirectCallsFromPluginTest is AccountTestBase {
);
}

function _buildDirectCallDisallowedError(bytes4 selector) internal view returns (bytes memory) {
return abi.encodeWithSelector(
UpgradeableModularAccount.ExecFromPluginNotPermitted.selector, address(_plugin), selector
);
function _buildDirectCallDisallowedError(bytes4 selector) internal pure returns (bytes memory) {
return abi.encodeWithSelector(UpgradeableModularAccount.UserOpValidationFunctionMissing.selector, selector);
}
}
3 changes: 1 addition & 2 deletions test/account/PermittedCallPermissions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ contract PermittedCallPermissionsTest is AccountTestBase {
function test_permittedCall_NotAllowed() public {
vm.expectRevert(
abi.encodeWithSelector(
UpgradeableModularAccount.ExecFromPluginNotPermitted.selector,
address(permittedCallerPlugin),
UpgradeableModularAccount.UserOpValidationFunctionMissing.selector,
ResultCreatorPlugin.bar.selector
)
);
Expand Down
Loading